⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb_ep0.cpp

📁 USB 1.1 PHY的代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		state.write(next_state.read());}void usb_ep0::ep0_statemachine(void) {	next_state.write(state.read());	get_hdr.write(false);	data_sel.write(ZERO_DATA);	fifo_we_d.write(false);	in_size_0.write(false);	in_size_1.write(false);	in_size_2.write(false);	rom_sel.write(false);	switch (state.read()) {// synopsys full_case parallel_case		case EP0_IDLE:	// Wait for setup token/////////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state IDLE (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						if (ctrl_setup.read())							next_state.write(EP0_GET_HDR);						if (get_status.read())							next_state.write(EP0_GET_STATUS);						if (clear_feature.read())							next_state.write(EP0_CLEAR_FEATURE);						if (set_feature.read())							next_state.write(EP0_SET_FEATURE);						if (set_address.read())							next_state.write(EP0_SET_ADDRESS);						if (get_descriptor.read())							next_state.write(EP0_GET_DESCRIPTOR);						if (set_descriptor.read())							next_state.write(EP0_SET_DESCRIPTOR);						if (get_config.read())							next_state.write(EP0_GET_CONFIG);						if (set_config.read())							next_state.write(EP0_SET_CONFIG);						if (get_interface.read())							next_state.write(EP0_GET_INTERFACE);						if (set_interface.read())							next_state.write(EP0_SET_INTERFACE);						if (synch_frame.read())							next_state.write(EP0_SYNCH_FRAME);						if (v_set_int.read())							next_state.write(EP0_V_SET_INT);						if (v_set_feature.read())							next_state.write(EP0_V_SET_INT);						if (v_get_status.read())							next_state.write(EP0_V_GET_STATUS);						break;		case EP0_GET_HDR:	// Retrieve setup header/////////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state GET_HDR (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						get_hdr.write(true);						if (hdr_done.read())							next_state.write(EP0_IDLE);						break;		case EP0_GET_STATUS:	// Actions for supported commands/////////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state GET_STATUS (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						// Return to host						// 1 for device						// 0 for interface						// 0 for endpoint						if (bm_req_recp.read() == 0)							data_sel.write(ZERO_ONE_DATA);						else							data_sel.write(ZERO_DATA);						in_size_2.write(true);						if (!fifo_full.read()) {							fifo_we_d.write(true);							if (write_done_r.read())								next_state.write(EP0_WAIT_IN_DATA);						}						break;		case EP0_V_GET_STATUS://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state V_GET_STATUS (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						data_sel.write(VEND_DATA);						in_size_2.write(true);						if (!fifo_full.read()) {							fifo_we_d.write(true);							if (write_done_r.read())								next_state.write(EP0_WAIT_IN_DATA);						}						break;		case EP0_CLEAR_FEATURE://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state CLEAR_FEATURE (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						// Just ignore this for now						next_state.write(EP0_STATUS_IN);						break;		case EP0_SET_FEATURE://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state SET_FEATURE (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						// Just ignore this for now						next_state.write(EP0_STATUS_IN);						break;		case EP0_SET_ADDRESS://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state SET_ADDRESS (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						// Done elsewhere						next_state.write(EP0_STATUS_IN);						break;		case EP0_GET_DESCRIPTOR://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state GET_DESCRIPTOR (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						if ((wValue.read().range(15, 8) == 1) ||								(wValue.read().range(15, 8) == 2) ||								(wValue.read().range(15, 8) == 3))							rom_sel.write(true);						else							next_state.write(EP0_IDLE);						if (rom_done.read())							next_state.write(EP0_IDLE);						break;		case EP0_SET_DESCRIPTOR://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state SET_DESCRIPTOR (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						// This doesn't do anything since we do not support						// setting the descriptor						next_state.write(EP0_IDLE);						break;		case EP0_GET_CONFIG://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state GET_CONFIG (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						// Send one byte back that indicates current status						in_size_1.write(true);						data_sel.write(CONFIG_DATA);						if (!fifo_full.read()) {							fifo_we_d.write(true);							next_state.write(EP0_WAIT_IN_DATA);						}						break;		case EP0_SET_CONFIG://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state SET_CONFIG (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						// Done elsewhere						next_state.write(EP0_STATUS_IN);						break;		case EP0_GET_INTERFACE://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state GET_INTERFACE (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						// Return interface 0						in_size_1.write(true);						if (!fifo_full.read()) {							fifo_we_d.write(true);							next_state.write(EP0_WAIT_IN_DATA);						}						break;		case EP0_SET_INTERFACE://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state SET_INTERFACE (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						// Just ignore this for now						next_state.write(EP0_STATUS_IN);						break;		case EP0_SYNCH_FRAME://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state SYNCH_FRAME (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						// Return Frame current frame number						data_sel.write(SYNC_FRAME_DATA);						in_size_2.write(true);						if (!fifo_full.read()) {							fifo_we_d.write(true);							if (write_done_r.read())								next_state.write(EP0_WAIT_IN_DATA);						}						break;		case EP0_V_SET_INT://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state V_SET_INT (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						// Done elsewhere						next_state.write(EP0_STATUS_IN);						break;		case EP0_WAIT_IN_DATA://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state WAIT_IN_DATA (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						if (ctrl_in.read())							next_state.write(EP0_STATUS_OUT);						break;		case EP0_STATUS_IN://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state STATUS_IN (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						in_size_0.write(true);						if (ctrl_in.read())							next_state.write(EP0_IDLE);						break;		case EP0_STATUS_OUT://///////////////////////////////////////////////////////////////////////// DEBUG INFORMATIONS/////////////////////////////////////////////////////////////////////////#ifdef USBF_VERBOSE_DEBUG	cout << "EP0: Entered state STATUS_OUT (" << sc_simulation_time() << ")" << endl;#endif///////////////////////////////////////////////////////////////////////						if (ctrl_out.read())							next_state.write(EP0_IDLE);						break;	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -