CN112559429B - System and method for monitoring data based on USB - Google Patents
System and method for monitoring data based on USB Download PDFInfo
- Publication number
- CN112559429B CN112559429B CN202011537834.8A CN202011537834A CN112559429B CN 112559429 B CN112559429 B CN 112559429B CN 202011537834 A CN202011537834 A CN 202011537834A CN 112559429 B CN112559429 B CN 112559429B
- Authority
- CN
- China
- Prior art keywords
- module
- usb
- data
- transaction
- usb interface
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
- G06F13/4282—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
- G06F13/4286—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus using a handshaking protocol, e.g. RS232C link
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F13/00—Interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F13/38—Information transfer, e.g. on bus
- G06F13/42—Bus transfer protocol, e.g. handshake; Synchronisation
- G06F13/4282—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus
- G06F13/4291—Bus transfer protocol, e.g. handshake; Synchronisation on a serial bus, e.g. I2C bus, SPI bus using a clocked protocol
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2213/00—Indexing scheme relating to interconnection of, or transfer of information or other signals between, memories, input/output devices or central processing units
- G06F2213/0042—Universal serial bus [USB]
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Transfer Systems (AREA)
Abstract
Description
技术领域Technical field
本发明涉及一种基于USB数据侦听系统及方法,属于电子与通信技术领域,特别提供一种将侦听到的图像数据用基于单片机、CPLD或FPGA底板做实时处理。The invention relates to a USB data interception system and method, which belongs to the field of electronics and communication technology. In particular, it provides a method for real-time processing of intercepted image data based on a microcontroller, CPLD or FPGA backplane.
背景技术Background technique
随着数码产品不断发展和普及,设备之间的数据交流也变得更加高频化和高速化,USB协议成为了各种设备间数据传输的主流协议之一。支持USB协议的设备不仅仅是在我们的日常生活中很常见,在科学研究中也非常的普遍,例如:各类外接检测装置、仪器仪表、望远镜、各类信号分析仪等都配有符合USB标准的接口。USB总线是常见的外部总线标准中的一种,用于USB总线模型中的主机和设备之间的数据交换和交流。USB接口因为高速稳定、即插即用、接口规范统一以及使用方便等优点,成为现代数据传输的主流趋势之一。USB接口标准有三种:USB 1.1,USB 2.0和USB 3.0。虽然现在USB3.0接口的设备很多,但目前市场中还是USB2.0设备占有份额高于3.0。With the continuous development and popularization of digital products, data exchanges between devices have become more frequent and high-speed, and the USB protocol has become one of the mainstream protocols for data transmission between various devices. Devices that support the USB protocol are not only common in our daily lives, but also very common in scientific research. For example, various external detection devices, instruments, telescopes, various signal analyzers, etc. are all equipped with USB-compliant devices. Standard interface. The USB bus is one of the common external bus standards and is used for data exchange and communication between the host and the device in the USB bus model. The USB interface has become one of the mainstream trends in modern data transmission due to its advantages of high speed, stability, plug-and-play, unified interface specifications, and ease of use. There are three USB interface standards: USB 1.1, USB 2.0 and USB 3.0. Although there are many devices with USB 3.0 interfaces, the market share of USB 2.0 devices is currently higher than 3.0.
USB是一种便捷的,点对点的数据传输方式,但该协议不支持三个设备间的数据传输。若需要实现对USB 2.0总线上数据的实时侦听和采集功能,需要开发一个特定的设备或系统来完成这个任务。目前市场上出售的USB协议分析仪可以实现基于计算机的数据监听和分析功能。少数的文献中也是将侦听到的数据最终上传到PC端。而在计算机上通过软件实现的对USB接口的实时收发数据的监听和采集,没有很好的便携性和通用性,不同的计算机需要进行多次配置和调试;并且脱离了上位机软件的辅助,将不能够正常工作。目前并没有一种对USB 2.0总线上的两个方向的数据进行实时侦听、采集,并处理组合成一个USB事务发给底板电路,供底板电路去使用的系统。USB is a convenient, point-to-point data transmission method, but this protocol does not support data transmission between three devices. If you need to implement real-time listening and collection functions of data on the USB 2.0 bus, you need to develop a specific device or system to complete this task. USB protocol analyzers currently on the market can realize computer-based data monitoring and analysis functions. In a few documents, the intercepted data is finally uploaded to the PC. However, the monitoring and collection of real-time sending and receiving data of the USB interface implemented through software on the computer does not have good portability and versatility. Different computers require multiple configurations and debugging; and it is separated from the assistance of the host computer software. will not work properly. Currently, there is no system that listens and collects data in both directions on the USB 2.0 bus in real time, processes and combines it into a USB transaction and sends it to the backplane circuit for use by the backplane circuit.
发明内容Contents of the invention
本发明要解决的技术问题是:本发明提供一种基于USB数据侦听系统及方法,系统使用USB接口芯片侦听总线双向数据,使用FPGA将数据组合成USB事务发送给底板电路。The technical problem to be solved by the present invention is: the present invention provides a USB data listening system and method. The system uses a USB interface chip to listen to bus bidirectional data, and uses FPGA to combine the data into USB transactions and send them to the backplane circuit.
本发明技术方案是:一种基于USB数据侦听系统,包括FPGA模块1、USB接口芯片模块2、IO扩展口模块3、USB接口A11、USB接口B12;The technical solution of the present invention is: a USB data listening system, including an FPGA module 1, a USB interface chip module 2, an IO expansion port module 3, a USB interface A11, and a USB interface B12;
所述USB接口芯片模块2通过USB接口A11、USB接口B12的USB总线无侵入式的连接主设备9和从设备10;USB接口芯片模块2还与FPGA模块1连接,FPGA模块1包括ULPI接口模块4、包分解模块5、事务组合模块6、传输模块7、时钟模块8;时钟模块8均分别与USB接口芯片模块2、ULPI接口模块4、包分解模块5、事务组合模块6、传输模块7连接;所述IO扩展口模块3连接着FPGA模块1的传输模块7;IO扩展口模块3与底板电路对接。The USB interface chip module 2 connects the master device 9 and the slave device 10 non-invasively through the USB bus of USB interface A11 and USB interface B12; the USB interface chip module 2 is also connected to the FPGA module 1, and the FPGA module 1 includes a ULPI interface module 4. Packet decomposition module 5, transaction combination module 6, transmission module 7, clock module 8; clock module 8 is respectively connected with USB interface chip module 2, ULPI interface module 4, packet decomposition module 5, transaction combination module 6, and transmission module 7 Connection; the IO expansion port module 3 is connected to the transmission module 7 of the FPGA module 1; the IO expansion port module 3 is connected to the baseboard circuit.
作为本发明的进一步方案,所述ULPI接口模块4为ULPI PHY接口模块,与USB接口芯片模块2建立协议层的联系,并把数据完整输出给包分解模块5;包分解模块5用于将USB数据包缓存到RAM,并把包信息存入FIFO中缓存;事务组合模块6用于USB事务处理,将若干个相关联的令牌包、数据包、握手包组合成一个USB事务并提供EN信号;时钟模块8由USB接口芯片模块2输入,控制着ULPI接口模块4、包分解模块5、事务组合模块6、传输模块7的时钟;传输模块7用于将组合好的USB事务、提供给底板电路的同步时钟和EN信号组合通过IO扩展口模块3输出给底板电路,当EN信号为高时,每一个同步时钟周期就会输出USB事务中的一个字节。As a further solution of the present invention, the ULPI interface module 4 is a ULPI PHY interface module, which establishes protocol layer contact with the USB interface chip module 2, and outputs complete data to the packet decomposition module 5; the packet decomposition module 5 is used to decompose the USB The data packet is cached in RAM, and the packet information is stored in the FIFO cache; the transaction combination module 6 is used for USB transaction processing, combining several associated token packets, data packets, and handshake packets into a USB transaction and providing the EN signal ; The clock module 8 is input by the USB interface chip module 2 and controls the clocks of the ULPI interface module 4, packet decomposition module 5, transaction combination module 6, and transmission module 7; the transmission module 7 is used to provide the combined USB transactions to the base board The circuit's synchronous clock and EN signal combination is output to the backplane circuit through IO expansion port module 3. When the EN signal is high, one byte in the USB transaction will be output in each synchronous clock cycle.
一种基于USB数据侦听方法,所述方法包括:A USB data listening method, the method includes:
USB接口芯片模块2通过USB接口A11、USB接口B12的USB总线无侵入式截取主设备9和从设备10之间的信号并发送给FPGA模块1处理,FPGA模块1将处理完后的数据组合成一个USB事务从IO扩展口模块3输出给底板电路;底板电路根据事务的头文件筛选所需要的数据去使用。The USB interface chip module 2 non-intrusively intercepts the signals between the master device 9 and the slave device 10 through the USB bus of the USB interface A11 and the USB interface B12 and sends it to the FPGA module 1 for processing. The FPGA module 1 combines the processed data into A USB transaction is output from IO expansion port module 3 to the backplane circuit; the backplane circuit filters the required data for use based on the header file of the transaction.
作为本发明的进一步方案,每个USB事务输出时,前4个字节为事务信息头,4字节的事务信息头格式为:As a further solution of the present invention, when each USB transaction is output, the first 4 bytes are the transaction information header, and the 4-byte transaction information header format is:
第1个字节:tid[7:0],表示该事务的类型;The first byte: tid[7:0], indicating the type of transaction;
第2个字节:addr[6:0],表示该事务对应的设备地址;The second byte: addr[6:0], indicating the device address corresponding to the transaction;
第3个字节:低4位为ep[3:0],表示该事务对应的端点号,高4位为len[3:0];The third byte: the lower 4 bits are ep[3:0], indicating the endpoint number corresponding to the transaction, and the upper 4 bits are len[3:0];
第4个字节:len[11:4],len[11:0]表示该事务对应的数据长度;The fourth byte: len[11:4], len[11:0] indicates the data length corresponding to the transaction;
后面跟随0~1024字节的事务数据。Followed by 0 to 1024 bytes of transaction data.
本发明的工作原理是:The working principle of the present invention is:
基于USB数据侦听系统及方法使用底板5V供电。由于各个模块使用电压不同,所以使用2路AMS1117低压降线性电源芯片分别产生3.3V,1.2V,供整体使用。Based on the USB data listening system and method, the baseboard 5V power supply is used. Since each module uses different voltages, 2-way AMS1117 low-voltage drop linear power supply chips are used to generate 3.3V and 1.2V respectively for overall use.
所述USB接口A11用于连接进行USB通讯的主设备9、USB接口B12用于连接进行USB通讯的从设备10。两个USB接口的DM和DP直接与USB接口芯片模块2相连,并加1kΩ的的保护电阻与FPGA相连;VBUS加100kΩ电阻与FPGA模块1相连,并加了100kΩ下拉电阻。The USB interface A11 is used to connect the master device 9 that performs USB communication, and the USB interface B12 is used to connect the slave device 10 that performs USB communication. The DM and DP of the two USB interfaces are directly connected to the USB interface chip module 2, and a 1kΩ protection resistor is added to connect to the FPGA; VBUS is connected to the FPGA module 1 with a 100kΩ resistor, and a 100kΩ pull-down resistor is added.
所述USB接口芯片模块2所使用芯片是基于UTMI+等级3封装而成接口为ULPI接口的USB3300;ULPI使用12个引脚将完整的OTG主机/设备PHY连接到系统级芯片上。一条8位双向数据总线,时钟为60MHz,允许FPGA模块1访问这个内部寄存器阵列,并将USB数据包传输到物理层。剩下的3个管脚用于控制数据流和仲裁数据总线。8位数据总线的方向由ULPI接口模块4的DIR输出控制。另一个输出NXT用于控制进出设备的数据流。最后,输入到ULPI接口模块4的STP终止传输,并用于启动和从挂起状态恢复。The chip used in the USB interface chip module 2 is USB3300 encapsulated based on UTMI+ level 3 and the interface is the ULPI interface; ULPI uses 12 pins to connect the complete OTG host/device PHY to the system-level chip. An 8-bit bidirectional data bus, clocked at 60MHz, allows FPGA module 1 to access this internal register array and transmit USB packets to the physical layer. The remaining 3 pins are used to control data flow and arbitrate the data bus. The direction of the 8-bit data bus is controlled by the DIR output of ULPI interface module 4. The other output, NXT, is used to control the flow of data to and from the device. Finally, the STP input to ULPI interface module 4 terminates the transfer and is used to initiate and resume from the suspend state.
USB3300使用内部晶体驱动器和锁相环子系统提供无噪声、稳定的480MHz参考时钟,PHY在发送和接收期间使用该时钟。USB3300需要一个稳定的、无噪声的24MHz晶体或时钟作为频率基准。USB3300可以使用晶体或外部时钟振荡器作为24MHz基准。晶体连接到USB3300引脚。一旦480MHz锁相环锁定到正确的频率,它将用60MHz时钟驱动CLKOUT引脚。该芯片ULPI接口信号电平为3.3V。工作于高速480Mbps速度模式。The USB3300 uses an internal crystal driver and phase-locked loop subsystem to provide a noise-free, stable 480MHz reference clock that is used by the PHY during transmit and receive. The USB3300 requires a stable, noise-free 24MHz crystal or clock as a frequency reference. The USB3300 can use a crystal or an external clock oscillator as the 24MHz reference. The crystal is connected to the USB3300 pins. Once the 480MHz phase locked loop is locked to the correct frequency, it drives the CLKOUT pin with the 60MHz clock. The chip's ULPI interface signal level is 3.3V. Works in high-speed 480Mbps speed mode.
DIR即Direction,用于控制数据总线的传输方向;当USB接口芯片向FPGA传输数据时候,驱动DIR为高;没有数据传输时,驱动为低并监视FPGA端的控制信号;同时,USB接口芯片会在不能接收数据时驱动DIR为高。NXT即Next,USB接口芯片会在传输数据时控制该信号;当FPGA发送数据到USB接口芯片,USB接口芯片接收到数据时会马上拉高NXT;随后FPGA会在下一个时钟周期时将下一字节放到数据总线上;相应的,当USB接口芯片正在发送数据给FPGA,NXT代表此时有新字节数据要发送给FPGA。STP即Stop,当FPGA置STP有效时在一个时钟周期内,停止总线上当前的数据流;如果FPGA正在传输数据到USB接口芯片,STP会保持为每个数据包的最后一位的数据。DIR is Direction, used to control the transmission direction of the data bus; when the USB interface chip transmits data to the FPGA, the driver DIR is high; when there is no data transmission, the driver is low and monitors the control signal on the FPGA side; at the same time, the USB interface chip will Drive DIR high when data cannot be received. NXT is Next. The USB interface chip will control this signal when transmitting data; when the FPGA sends data to the USB interface chip, the USB interface chip will immediately pull NXT high when receiving the data; then the FPGA will send the next word in the next clock cycle. The program is put on the data bus; correspondingly, when the USB interface chip is sending data to the FPGA, NXT means that there are new bytes of data to be sent to the FPGA at this time. STP means Stop. When the FPGA sets STP valid, it stops the current data flow on the bus within one clock cycle; if the FPGA is transmitting data to the USB interface chip, STP will remain the last bit of data in each data packet.
ULPI接口支持两种基本操作模式:同步模式和低功耗模式。同步模式,所有信号都相对于60MHz时钟发生变化。低功耗模式,时钟在暂停状态下关闭,数据总线的下两位包含线路状态[1:0]信号。ULPI增加了低功耗模式,这是一种中断输出,当OTG比较器或ID引脚改变状态时,允许链路接收异步中断。在同步模式下,数据在CLKOUT的上升沿传输。数据总线的方向由DIR的状态决定。当DIR为高电平时,PHY正在驱动数据[7:0]。当DIR低电平时,链路正在驱动数据[7:0]。因为USB使用位填充编码,所以需要一些允许PHY限制USB传输数据的方法。ULPI信号NXT用于请求链路层将下一个字节放置在数据总线上。当链路寻址PHY时,单个ULPI协议块对ULPI 8位双向总线进行解码。链路必须使用DIR输出来确定ULPI数据总线的方向。USB3300是“总线仲裁员”。ULPI协议块将数据/命令路由到发送器或ULPI寄存器阵列。The ULPI interface supports two basic operating modes: synchronous mode and low power mode. Synchronous mode, all signals vary relative to the 60MHz clock. In low-power mode, the clock is turned off in the pause state, and the next two bits of the data bus contain the line status [1:0] signal. ULPI adds a low-power mode, an interrupt output that allows the link to receive asynchronous interrupts when the OTG comparator or ID pin changes state. In synchronous mode, data is transferred on the rising edge of CLKOUT. The direction of the data bus is determined by the state of DIR. When DIR is high, the PHY is driving Data[7:0]. When DIR is low, the link is driving data[7:0]. Because USB uses bit-stuffing encoding, some method is needed to allow the PHY to limit the data transferred over USB. The ULPI signal NXT is used to request the link layer to place the next byte on the data bus. When the link addresses the PHY, a single ULPI protocol block decodes the ULPI 8-bit bidirectional bus. The link must use the DIR output to determine the direction of the ULPI data bus. USB3300 is the "bus arbitrator". The ULPI protocol block routes data/commands to the transmitter or the ULPI register array.
USB接口芯片模块2将数据差分信号还原成为电平信号并需要解码NRZI码流,然后识别出填充位。将数据转化为位宽为8位的数据通过USB接口芯片模块2的D0~D7发送给FPGA模块1。The USB interface chip module 2 restores the data differential signal to a level signal and needs to decode the NRZI code stream, and then identify the stuffing bits. The data is converted into data with a bit width of 8 bits and sent to the FPGA module 1 through D0~D7 of the USB interface chip module 2.
所述FPGA模块1所使用的核心芯片为Xilinx公司Spartan6系列的XC6SLX9-2TQG144C芯片,搭配FPGA外围电路连接至FPGA芯片。如FPGA的配置芯片SPI-Flash,用于储存FPGA配置bit流;供电电路主要给FPGA芯片和SPI-Flash提供需要的+5V、+3.3V和+1.2V电压;时钟使用USB接口芯片模块2输出的60MHz时钟作为模块的系统时钟。并配置了两个指示灯,LED_1电源点亮红色指示灯,提醒接通后电源。LED_2事务指示灯,每输出一次有效USB事务,蓝色指示灯亮一次。FPGA模块1一端与IO扩展口模块3相连,一端与USB接口芯片模块2相连。将本装置接入底板,将底板上电后,由底板提供5V电压和复位信号。FPGA模块1中的ULPI接口模块4向USB接口芯片模块2的寄存器写入初始控制命令TX CMD。将USB接口A11连接进行USB通讯的主设备9、USB接口B12用于连接进行USB通讯的从设备10。USB接口芯片模块2开始侦听总线上的差分电路,并把差分信号还原成为电平信号传入FPGA模块1。所述ULPI接口模块4为ULPI PHY接口模块,与USB接口芯片模块2建立协议层的联系,并把数据完整输出给包分解模块5。包分解模块5将USB数据包缓存到RAM,并把包信息存入FIFO中缓存。事务组合模块6用于USB事务处理,将几个相关联的令牌包、数据包、握手包组合成一个USB事务并提供EN信号;时钟模块8由USB接口芯片模块2输入,使用了基础时钟管理模块(DCM)和FPGA内部的全局时钟分配网络紧密结合,可以用来分频倍频,消除时钟延迟差,并控制着ULPI接口模块4、包分解模块5、事务组合模块6、传输模块7的时钟,并将时钟信号输出,可调节输出的时钟信号相位,使输出给底板的信号时序达到最佳。传输模块7用于将组合好的USB事务、提供给底板的同步时钟和EN信号组合通过IO扩展口模块3输出给底板,当EN信号为高时,每一个同步时钟周期就会有一个字节的USB事务输出。The core chip used in the FPGA module 1 is the XC6SLX9-2TQG144C chip of Xilinx's Spartan6 series, which is connected to the FPGA chip with the FPGA peripheral circuit. For example, the FPGA configuration chip SPI-Flash is used to store the FPGA configuration bit stream; the power supply circuit mainly provides the required +5V, +3.3V and +1.2V voltages to the FPGA chip and SPI-Flash; the clock uses the USB interface chip module 2 output The 60MHz clock serves as the system clock of the module. Two indicator lights are configured. The LED_1 power supply lights up the red indicator light to remind the power supply to be turned on. LED_2 transaction indicator light, every time a valid USB transaction is output, the blue indicator light lights up once. One end of the FPGA module 1 is connected to the IO expansion port module 3, and the other end is connected to the USB interface chip module 2. Connect this device to the baseboard, and after powering on the baseboard, the baseboard provides 5V voltage and reset signal. The ULPI interface module 4 in the FPGA module 1 writes the initial control command TX CMD to the register of the USB interface chip module 2. The USB interface A11 is connected to the master device 9 that performs USB communication, and the USB interface B12 is used to connect the slave device 10 that performs USB communication. The USB interface chip module 2 begins to listen to the differential circuit on the bus, and restores the differential signal into a level signal and transmits it to the FPGA module 1. The ULPI interface module 4 is a ULPI PHY interface module, establishes protocol layer contact with the USB interface chip module 2, and outputs complete data to the packet decomposition module 5. The packet decomposition module 5 caches the USB data packets into RAM and stores the packet information in the FIFO for cache. The transaction combination module 6 is used for USB transaction processing, combining several associated token packets, data packets, and handshake packets into a USB transaction and providing the EN signal; the clock module 8 is input by the USB interface chip module 2 and uses the basic clock The management module (DCM) is closely integrated with the global clock distribution network inside the FPGA, which can be used to divide and multiply frequencies, eliminate clock delay differences, and control the ULPI interface module 4, packet decomposition module 5, transaction combination module 6, and transmission module 7 clock and output the clock signal. The phase of the output clock signal can be adjusted to optimize the timing of the signal output to the backplane. The transmission module 7 is used to output the combined USB transaction, the synchronization clock and the EN signal provided to the backplane to the backplane through the IO expansion port module 3. When the EN signal is high, there will be one byte for each synchronization clock cycle. USB transaction output.
本发明工作过程为:The working process of the present invention is:
将本装置接入底板,将底板上电后,由底板提供5V电压和复位信号。使用2路LDO低压降线性电源芯片分别产生3.3V,1.2V电压供装置使用。复位后,FPGA模块1中的ULPI接口模块4向USB接口芯片模块2的寄存器写入初始控制命令TX CMD。要写入寄存器,FPGA模块1中的ULPI接口模块4需等到DIR低,在第一个时钟周期,在数据总线上驱动TXD CMD。在第三个时钟周期,USB接口芯片模块2将驱动NXT高。在下一个上升时钟边缘,ULPI接口模块4将写入寄存器数据。在第五个时钟周期,USB接口芯片模块2将接受寄存器数据,并且ULPI接口模块4将驱动总线上的空闲,并驱动STP为高,以发送数据包结束的信号。最后,在第六个时钟周期,USB接口芯片模块2将把数据锁存到寄存器中,并驱动NXT为低。ULPI接口模块4将拉低STP。NXT用于控制ULPI接口模块4何时驱动总线上的寄存器数据。由于USB接口芯片模块2从ULPI接口模块4接收数据,所以整个事务中DIR都是低电平。STP用于结束事务,在STP低电平后数据被寄存。写入操作完成后,ULPI接口模块4必须在数据总线上驱动ULPI空闲00h,否则USB接口芯片模块2可以将总线值解码为ULPI命令。Connect this device to the baseboard, and after powering on the baseboard, the baseboard provides 5V voltage and reset signal. Use 2-way LDO low-voltage drop linear power supply chips to generate 3.3V and 1.2V voltages for device use. After reset, the ULPI interface module 4 in the FPGA module 1 writes the initial control command TX CMD to the register of the USB interface chip module 2. To write to the register, ULPI interface module 4 in FPGA module 1 waits until DIR is low and, on the first clock cycle, drives TXD CMD on the data bus. In the third clock cycle, USB interface chip module 2 will drive NXT high. On the next rising clock edge, ULPI interface module 4 will write the register data. In the fifth clock cycle, the USB interface chip module 2 will accept the register data, and the ULPI interface module 4 will drive idle on the bus and drive STP high to send the signal of the end of the data packet. Finally, in the sixth clock cycle, USB interface chip module 2 will latch the data into the register and drive NXT low. ULPI interface module 4 will pull STP low. NXT is used to control when ULPI interface module 4 drives register data on the bus. Since the USB interface chip module 2 receives data from the ULPI interface module 4, DIR is low during the entire transaction. STP is used to end the transaction, and the data is registered after STP is low. After the write operation is completed, the ULPI interface module 4 must drive ULPI idle 00h on the data bus, otherwise the USB interface chip module 2 can decode the bus value into an ULPI command.
将USB接口A11连接进行USB通讯的主设备9、USB接口B12连接进行USB通讯的从设备10。USB接口芯片模块2开始侦听总线上的差分电路,并把差分信号还原成为电平信号传入FPGA。在传输期间,USB接口芯片模块2将使用NXT来控制进入USB接口芯片模块2的数据流速率。如果USB接口芯片模块2管道已满或位填充导致数据管道过度填充,则NXT无效(低电平),并且ULPI接口模块4将保留数据上的值,直到NXT有效(高电平)。当ULPI接口模块4中STP有效而NXT无效时,USB传输结束。由于USB接口芯片模块2期望在此状态下从ULPI接口模块4中获取另一个字节,因此ULPI接口模块4无法具有NXT无效的STP有效信号,The USB interface A11 is connected to the master device 9 for USB communication, and the USB interface B12 is connected to the slave device 10 for USB communication. The USB interface chip module 2 begins to listen to the differential circuit on the bus, and restores the differential signal into a level signal and transmits it to the FPGA. During transmission, the USB interface chip module 2 will use NXT to control the data flow rate entering the USB interface chip module 2. If the USB interface chip module 2 pipe is full or bit stuffing causes the data pipe to be overfilled, NXT is invalid (low level), and ULPI interface module 4 will retain the value on the data until NXT is valid (high level). When STP is valid and NXT is invalid in ULPI interface module 4, USB transmission ends. Since USB interface chip module 2 expects to get another byte from ULPI interface module 4 in this state, ULPI interface module 4 cannot have an STP valid signal with NXT invalid,
一旦USB接口芯片模块2完成传输,DP/DM线路返回空闲状态,RXD CMD返回到链路,这样可以通过线路状态更新内部数据包计时。Once the USB interface chip module 2 completes the transmission, the DP/DM line returns to the idle state and the RXD CMD returns to the link so that the internal packet timing can be updated through the line status.
全速或低速情况下,一旦STP有效,每个FS/LS位转换将生成一个RXD CMD,因为位时间相对较慢。At full speed or low speed, once STP is active, each FS/LS bit transition will generate an RXD CMD because the bit time is relatively slow.
USB接口芯片模块2让DIR有效以使USB接口芯片模块2从ULPI接口模块4控制数据总线。同一周期中DIR和NXT有效中包含Rxactive有效的附加信息。当NXT无效和DIR有效时,RXD CMD数据被传输到FPGA模块1。USB接收数据包的最后一个字节传输到USB接口芯片模块2后,线路状态将返回空闲状态。The USB interface chip module 2 asserts DIR so that the USB interface chip module 2 controls the data bus from the ULPI interface module 4 . The validity of DIR and NXT in the same cycle contains additional information about the validity of Rxactive. When NXT is invalid and DIR is valid, RXD CMD data is transmitted to FPGA module 1. After the last byte of the USB received data packet is transmitted to the USB interface chip module 2, the line status will return to the idle state.
ULPI全速接收机根据UTMI/ULPI规范运行。在全速情况下,NXT信号将仅在数据总线具有有效的接收数据字节时有效。当NXT低而DIR高时,RXD命令在数据总线上驱动。ULPI full speed receiver operates according to UTMI/ULPI specifications. At full speed, the NXT signal will only be valid when the data bus has valid receive data bytes. When NXT is low and DIR is high, the RXD command is driven on the data bus.
在全速下,在DP/DM线路状态转换为空闲状态之前,USB接口芯片模块2不会在RXDCMD中发出Rxactive无效的信号。这可防止FPGA模块1违背两个全速位时间的最小改变时间。At full speed, USB interface chip module 2 will not send an Rxactive invalid signal in RXDCMD before the DP/DM line state transitions to the idle state. This prevents FPGA module 1 from violating the minimum change time of two full-speed bit times.
当ULPI接口模块4将包开始信号传到包分解模块5时,将8位并行数据存入8位宽的RAM中,每存一个字节,计数一次可以得到包的长度。将前三组8位数据存入三个宽度为8寄存器当中,当一个完整的包传输结束后,将每一个包的信息组合成一个数据存入FIFO中缓存。如果包的长度为三并且第一组数据为令牌包的PID(包识别字段),判断这个包为令牌包,则把前三组保存到寄存器里的8位数据存入宽度为64位FIFO中的前24位缓存。其中前1~8位为这个包的PID,9~15位是设备的地址,16~19位是设备的端点数据,剩下的5位是CRC检验位。如果包的长度大于3并且第一组数据为数据包的PID,则判断这个包为数据包。把第一组数据(PID)保存到64位FIFO中的1~8位;把这个包的长度减三(除去一个字节的PID和两个字节的CRC校验位,为这个包数据的长度)保存到64位FIFO中的25~36位;把这个数据包在RAM中的首地址加一(第一个字节是PID,从第二个字节起为这个包的数据,最后两个字节为这个包的CRC)保存到64位FIFO中的37~48位。如果包的长度为一并且第一组数据为握手包的PID,判断为这个包为握手包,把第一组数据(PID)保存到64位FIFO中的第一位。把这些数据保存FIFO中缓存是为了便于接下来事务组合模块6处理。When the ULPI interface module 4 transmits the packet start signal to the packet decomposition module 5, the 8-bit parallel data is stored in the 8-bit wide RAM. Each time a byte is stored, the length of the packet can be obtained by counting once. Store the first three groups of 8-bit data into three registers with a width of 8. When a complete packet transmission is completed, the information of each packet is combined into one data and stored in the FIFO cache. If the length of the packet is three and the first group of data is the PID (packet identification field) of the token packet, it is judged that the packet is a token packet, and the first three groups of 8-bit data saved in the register are stored in a width of 64 bits The first 24 bits in the FIFO are cached. The first 1 to 8 bits are the PID of this packet, the 9 to 15 bits are the device address, the 16 to 19 bits are the endpoint data of the device, and the remaining 5 bits are the CRC check bits. If the length of the packet is greater than 3 and the first set of data is the PID of the data packet, the packet is judged to be a data packet. Save the first set of data (PID) to bits 1 to 8 in the 64-bit FIFO; reduce the length of this packet by three (removing the one-byte PID and two-byte CRC check bits) to obtain the length of this packet data. length) is saved to 25 to 36 bits in the 64-bit FIFO; add one to the first address of this data packet in RAM (the first byte is the PID, the second byte from the second byte onwards is the data of this packet, and the last two Bytes are the CRC of this packet) and are saved to bits 37~48 in the 64-bit FIFO. If the length of the packet is one and the first set of data is the PID of the handshake packet, it is judged that the packet is a handshake packet, and the first set of data (PID) is saved to the first bit of the 64-bit FIFO. The purpose of storing these data in the FIFO cache is to facilitate subsequent processing by the transaction combination module 6.
事务组合模块6中,当上一个事务的数据处理完并传输至底板后,如果FIFO中有数据,则判断这个FIFO中的64位数据的前8位,前8位为PID(包识别码)。如果是令牌包的PID,则将PID数据放进令牌包PID寄存器,并把此64位数据中地址放进地址寄存器,端点数据放进端点寄存器。如果是数据包的PID,则将PID数据放进数据包PID寄存器,并把此64位数据中数据长度放进数据长度寄存器,把数据在RAM中的地址放进数据RAM地址寄存器。如果是握手包的PID,则将PID数据放进握手包PID寄存器。根据三个PID寄存器,可以确定这次传输的是什么事务,并且将这次事务命名成相应的一个8位的事务标识符(TID)码,并将这次事务的地址、端点,长度组合成一个事务信息头。传输模块7用于将组合好的USB事务、提供给底板的同步时钟和EN信号组合通过IO扩展口模块3输出给底板,当EN信号为高时,每一个同步时钟周期就会输出USB事务中的一个字节,前4个字节为事务信息头,4字节的事务信息头格式为:In the transaction combination module 6, after the data of the previous transaction is processed and transmitted to the backplane, if there is data in the FIFO, the first 8 bits of the 64-bit data in the FIFO are judged, and the first 8 bits are the PID (Packet Identification Code) . If it is the PID of the token packet, put the PID data into the token packet PID register, put the address in the 64-bit data into the address register, and put the endpoint data into the endpoint register. If it is the PID of the data packet, put the PID data into the data packet PID register, put the data length in the 64-bit data into the data length register, and put the address of the data in RAM into the data RAM address register. If it is the PID of the handshake packet, put the PID data into the handshake packet PID register. According to the three PID registers, it is possible to determine what transaction is transmitted this time, and name this transaction into a corresponding 8-bit transaction identifier (TID) code, and combine the address, endpoint, and length of this transaction into A transaction header. The transmission module 7 is used to output the combined USB transaction, the synchronous clock and the EN signal provided to the base plate to the base plate through the IO expansion port module 3. When the EN signal is high, the USB transaction will be output in each synchronous clock cycle. A byte of , the first 4 bytes are the transaction information header, and the 4-byte transaction information header format is:
第1个字节:tid[7:0],表示该事务的类型;The first byte: tid[7:0], indicating the type of transaction;
第2个字节:addr[6:0],表示该事务对应的设备地址;The second byte: addr[6:0], indicating the device address corresponding to the transaction;
第3个字节:低4位为ep[3:0],表示该事务对应的端点号,高4位为len[3:0];The third byte: the lower 4 bits are ep[3:0], indicating the endpoint number corresponding to the transaction, and the upper 4 bits are len[3:0];
第4个字节:len[11:4],len[11:0]表示该事务对应的数据长度;The fourth byte: len[11:4], len[11:0] indicates the data length corresponding to the transaction;
后面跟随着通过数据RAM地址寄存器读出的相应长度的事务数据。并将地址、端点、PID等寄存器清零。This is followed by the corresponding length of transaction data read through the data RAM address register. And clear the address, endpoint, PID and other registers to zero.
数据输出到底板后,底板可根据头信息筛选所需要的信息,本设计专门用来筛选图像信息。After the data is output to the base plate, the base plate can filter the required information based on the header information. This design is specially used to filter image information.
本发明的有益效果是:The beneficial effects of the present invention are:
1、当图像数据从USB通信的主从设备时,如果需要将数据用基于单片机、CPLD或FPGA底板做实时分析、处理、或者暂存时,可以将本系统连接底板系统使用。省去了再从PC端传入底板电路,提高了速度并减少了人力浪费。1. When image data is communicated from a USB master-slave device, if the data needs to be analyzed, processed, or temporarily stored based on a microcontroller, CPLD or FPGA backplane, this system can be connected to the backplane system. It eliminates the need to transfer the circuit from the PC to the backplane, which increases the speed and reduces the waste of manpower.
2、本发明可以不通过PC机,在接入USB传输线后,对USB总线上的数据进行无侵入式USB数据实时侦听并传给底板使用。2. The present invention can perform non-intrusive real-time listening of USB data on the USB bus after connecting to the USB transmission line without using a PC and transmit it to the base board for use.
3、本发明设备简单易用,成本较低,且面积较小便于携带,有很强的实用性。3. The equipment of the present invention is simple and easy to use, has low cost, is small in area and easy to carry, and has strong practicability.
4、本发明也可以侦听其他数据,只需要在代码中稍作修改即可。4. The present invention can also listen to other data, and only needs to be slightly modified in the code.
5、本发明将几个包整合成一个事务,将没有用的数据舍弃,而且将所有事务分类,底板电路可以清楚的得到该事务的类型、该事务对应的设备地址、该事务对应的端点号、该事务对应的数据长度。底板电路可以根据这些条件来获取自己想要的数据,很方便的得到自己想要的结果。5. The present invention integrates several packages into one transaction, discards useless data, and classifies all transactions. The backplane circuit can clearly obtain the type of the transaction, the device address corresponding to the transaction, and the endpoint number corresponding to the transaction. , the data length corresponding to the transaction. The baseboard circuit can obtain the data you want based on these conditions, and easily get the results you want.
附图说明Description of the drawings
图1是本发明的原理框图;Figure 1 is a functional block diagram of the present invention;
图2是本发明的USB接口芯片到FPGA芯片中DATA数据的双向导通的电路图;Figure 2 is a circuit diagram for bidirectional communication of DATA data from the USB interface chip of the present invention to the FPGA chip;
图3是本发明的包分解模块和事务组合模块数据传输的流程图;Figure 3 is a flow chart of data transmission of the packet decomposition module and transaction combination module of the present invention;
图4是本发明向底板传输的底板接收状态机。Figure 4 is a base board receiving state machine that transmits to the base board according to the present invention.
图1中各标号:1-FPGA模块,2-USB接口芯片模块,3-IO扩展口模块,4-ULPI接口模块,5-包分解模块,6-事务组合模块,7-传输模块,8-时钟模块,9-主设备,10-从设备,11-USB接口A,12-USB接口B。Each label in Figure 1: 1-FPGA module, 2-USB interface chip module, 3-IO expansion port module, 4-ULPI interface module, 5-packet decomposition module, 6-transaction combination module, 7-transmission module, 8- Clock module, 9-master device, 10-slave device, 11-USB interface A, 12-USB interface B.
具体实施方式Detailed ways
下面结合附图和具体实施例,对本发明作进一步说明。The present invention will be further described below in conjunction with the accompanying drawings and specific embodiments.
实施例1:如图1-4所示,一种基于USB数据侦听系统,包括FPGA模块1、USB接口芯片模块2、IO扩展口模块3、USB接口A11、USB接口B12;Embodiment 1: As shown in Figure 1-4, a USB data listening system includes FPGA module 1, USB interface chip module 2, IO expansion port module 3, USB interface A11, and USB interface B12;
所述USB接口芯片模块2通过USB接口A11、USB接口B12的USB总线无侵入式的连接主设备9和从设备10;USB接口芯片模块2还与FPGA模块1连接,FPGA模块1包括ULPI接口模块4、包分解模块5、事务组合模块6、传输模块7、时钟模块8;时钟模块8均分别与USB接口芯片模块2、ULPI接口模块4、包分解模块5、事务组合模块6、传输模块7连接;所述IO扩展口模块3连接着FPGA模块1的传输模块7;IO扩展口模块3与底板电路对接。The USB interface chip module 2 connects the master device 9 and the slave device 10 non-invasively through the USB bus of USB interface A11 and USB interface B12; the USB interface chip module 2 is also connected to the FPGA module 1, and the FPGA module 1 includes a ULPI interface module 4. Packet decomposition module 5, transaction combination module 6, transmission module 7, clock module 8; clock module 8 is respectively connected with USB interface chip module 2, ULPI interface module 4, packet decomposition module 5, transaction combination module 6, and transmission module 7 Connection; the IO expansion port module 3 is connected to the transmission module 7 of the FPGA module 1; the IO expansion port module 3 is connected to the baseboard circuit.
作为本发明的进一步方案,所述ULPI接口模块4为ULPI PHY接口模块,与USB接口芯片模块2建立协议层的联系,并把数据完整输出给包分解模块5;包分解模块5用于将USB数据包缓存到RAM,并把包信息存入FIFO中缓存;事务组合模块6用于USB事务处理,将若干个相关联的令牌包、数据包、握手包组合成一个USB事务并提供EN信号;时钟模块8由USB接口芯片模块2输入,控制着ULPI接口模块4、包分解模块5、事务组合模块6、传输模块7的时钟;传输模块7用于将组合好的USB事务、提供给底板电路的同步时钟和EN信号组合通过IO扩展口模块3输出给底板电路,当EN信号为高时,每一个同步时钟周期就会输出USB事务中的一个字节。As a further solution of the present invention, the ULPI interface module 4 is a ULPI PHY interface module, which establishes protocol layer contact with the USB interface chip module 2, and outputs complete data to the packet decomposition module 5; the packet decomposition module 5 is used to decompose the USB The data packet is cached in RAM, and the packet information is stored in the FIFO cache; the transaction combination module 6 is used for USB transaction processing, combining several associated token packets, data packets, and handshake packets into a USB transaction and providing the EN signal ; The clock module 8 is input by the USB interface chip module 2 and controls the clocks of the ULPI interface module 4, packet decomposition module 5, transaction combination module 6, and transmission module 7; the transmission module 7 is used to provide the combined USB transactions to the base board The circuit's synchronous clock and EN signal combination is output to the backplane circuit through IO expansion port module 3. When the EN signal is high, one byte in the USB transaction will be output in each synchronous clock cycle.
一种基于USB数据侦听方法,所述方法包括:A USB data listening method, the method includes:
USB接口芯片模块2通过USB接口A11、USB接口B12的USB总线无侵入式截取主设备9和从设备10之间的信号并发送给FPGA模块1处理,FPGA模块1将处理完后的数据组合成一个USB事务从IO扩展口模块3输出给底板电路;底板电路根据事务的头文件筛选所需要的数据去使用。The USB interface chip module 2 non-intrusively intercepts the signals between the master device 9 and the slave device 10 through the USB bus of the USB interface A11 and the USB interface B12 and sends it to the FPGA module 1 for processing. The FPGA module 1 combines the processed data into A USB transaction is output from IO expansion port module 3 to the backplane circuit; the backplane circuit filters the required data for use based on the header file of the transaction.
作为本发明的进一步方案,每个USB事务输出时,前4个字节为事务信息头,4字节的事务信息头格式为:As a further solution of the present invention, when each USB transaction is output, the first 4 bytes are the transaction information header, and the 4-byte transaction information header format is:
第1个字节:tid[7:0],表示该事务的类型;The first byte: tid[7:0], indicating the type of transaction;
第2个字节:addr[6:0],表示该事务对应的设备地址;The second byte: addr[6:0], indicating the device address corresponding to the transaction;
第3个字节:低4位为ep[3:0],表示该事务对应的端点号,高4位为len[3:0];The third byte: the lower 4 bits are ep[3:0], indicating the endpoint number corresponding to the transaction, and the upper 4 bits are len[3:0];
第4个字节:len[11:4],len[11:0]表示该事务对应的数据长度;The fourth byte: len[11:4], len[11:0] indicates the data length corresponding to the transaction;
后面跟随0~1024字节的事务数据。Followed by 0 to 1024 bytes of transaction data.
具体的,FPGA模块1通过不同的I/O口连接USB接口芯片模块2和IO扩展口模块3。FPGA模块1与USB接口芯片模块2和IO扩展口模块3之间的数据传输由位宽为8位的数据线D0~D7来实现。DIR即Direction,用于控制数据总线的传输方向;当USB接口芯片模块2向FPGA模块1传输数据时候,驱动DIR为高;没有数据传输时,驱动为低并监视FPGA模块1端的控制信号;同时,USB接口芯片模块2会在不能接收数据时驱动DIR为高。NXT即Next,USB接口芯片模块2会在传输数据时控制该信号;当FPGA模块1发送数据到USB接口芯片模块2,USB接口芯片模块2接收到数据时会马上拉高NXT;随后FPGA模块1会在下一个时钟周期时将下一字节放到数据总线上;相应的,当USB接口芯片模块2正在发送数据给FPGA模块1,NXT代表此时有新字节数据要发送给FPGA模块1。STP即Stop,当FPGA模块1置STP有效时在一个时钟周期内,停止总线上当前的数据流;如果FPGA模块1正在传输数据到USB接口芯片模块2,STP会保持为每个数据包的最后一位的数据。Specifically, FPGA module 1 is connected to USB interface chip module 2 and IO expansion port module 3 through different I/O ports. The data transmission between FPGA module 1, USB interface chip module 2 and IO expansion port module 3 is realized by data lines D0~D7 with a bit width of 8 bits. DIR is Direction, which is used to control the transmission direction of the data bus; when the USB interface chip module 2 transmits data to the FPGA module 1, the driver DIR is high; when there is no data transmission, the driver is low and monitors the control signal of the FPGA module 1; at the same time , USB interface chip module 2 will drive DIR high when it cannot receive data. NXT is Next. USB interface chip module 2 will control this signal when transmitting data; when FPGA module 1 sends data to USB interface chip module 2, USB interface chip module 2 will immediately pull NXT high when receiving the data; then FPGA module 1 The next byte will be put on the data bus in the next clock cycle; correspondingly, when USB interface chip module 2 is sending data to FPGA module 1, NXT means that there is a new byte of data to be sent to FPGA module 1 at this time. STP means Stop. When FPGA module 1 sets STP valid, it stops the current data flow on the bus within one clock cycle; if FPGA module 1 is transmitting data to USB interface chip module 2, STP will remain as the last bit of each data packet. One bit of data.
如图1所示,USB接口A11为一个USB端口用于连接主设备9、USB接口B12为另一个USB端口用于连接从设备10,将两个接口的USB总线中间引线,从差分对上拉出两根线,使得信号可以直接流出,这样才能使其恢复原有的连接,在硬件层面上达到不干扰原传输线路的目的。As shown in Figure 1, USB interface A11 is a USB port used to connect the master device 9, USB interface B12 is another USB port used to connect the slave device 10, pull up the middle leads of the USB buses of the two interfaces from the differential pair Two wires are drawn out so that the signal can flow out directly, so that the original connection can be restored and the purpose of not interfering with the original transmission line can be achieved at the hardware level.
如图1所示,USB接口芯片模块2通过USB接口A11、USB接口B12的USB总线无侵入式截取主设备9和从设备10之间的信号并发送给FPGA模块1处理、FPGA模块1将处理完后的数据组合成一个USB事务从IO扩展口模块3发给底板电路。底板电路可根据事务的头文件筛选所需要的数据去使用。As shown in Figure 1, the USB interface chip module 2 non-invasively intercepts the signals between the master device 9 and the slave device 10 through the USB bus of the USB interface A11 and the USB interface B12 and sends it to the FPGA module 1 for processing. The FPGA module 1 will process The completed data is combined into a USB transaction and sent from IO expansion port module 3 to the backplane circuit. The backplane circuit can be used to filter the required data based on the transaction header file.
如图2所示的电路示意图解决了其中主要难度,实现了USB接口芯片模块2到FPGA模块1中DATA数据的双向导通。其中MUX是数据选择器,BUFT是三态输出缓冲器。当DIR为高位时三态输出缓冲器为高阻态;数据选择器将DATA和DATA_IN导通。实现了当USB接口芯片模块2向FPGA模块1传输数据时,驱动DIR为高,FPGA模块1开始接收USB接口芯片模块2传进来的数据。当DIR为低位时三态输出缓冲器将DATA_OUT数据传送到DATA。当没有数据传输时,USB接口芯片模块2驱动DIR为低并监视FPGA模块1的控制信号,这样FPGA模块1就能将命令写入USB接口芯片模块2的寄存器中。The circuit diagram shown in Figure 2 solves the main difficulty and realizes the two-way communication of DATA data from the USB interface chip module 2 to the FPGA module 1. Where MUX is the data selector and BUFT is the three-state output buffer. When DIR is high, the three-state output buffer is in a high-impedance state; the data selector turns on DATA and DATA_IN. It is realized that when the USB interface chip module 2 transmits data to the FPGA module 1, the DIR is driven high, and the FPGA module 1 starts to receive the data transmitted from the USB interface chip module 2. The tri-state output buffer transfers DATA_OUT data to DATA when DIR is low. When there is no data transmission, the USB interface chip module 2 drives DIR low and monitors the control signal of the FPGA module 1, so that the FPGA module 1 can write commands into the register of the USB interface chip module 2.
如图1所示,FPGA模块1包括:ULPI接口模块4、包分解模块5、事务组合模块6、传输模块7、时钟模块8;ULPI接口模块4为ULPI PHY接口模块,与USB接口芯片模块2建立协议层的联系,并把数据完整输出给包分解模块5;包分解模块5将USB数据包缓存到RAM,并把包信息存入FIFO中缓存;事务组合模块6用于USB事务处理,将几个相关联的令牌包、数据包、握手包组合成一个USB事务并提供EN信号;时钟模块8由USB接口芯片模块2输入,控制着ULPI接口模块4、包分解模块5、事务组合模块6、传输模块7的时钟;传输模块7用于将组合好的USB事务、提供给底板的同步时钟和EN信号组合通过IO扩展口模块3输出给底板,当EN信号为高时,每一个同步时钟周期就会输出USB事务中的一个字节。As shown in Figure 1, FPGA module 1 includes: ULPI interface module 4, packet decomposition module 5, transaction combination module 6, transmission module 7, clock module 8; ULPI interface module 4 is a ULPI PHY interface module, and USB interface chip module 2 Establish the connection at the protocol layer, and output the complete data to the packet decomposition module 5; the packet decomposition module 5 caches the USB data packets to RAM, and stores the packet information in the FIFO cache; the transaction combination module 6 is used for USB transaction processing, Several associated token packets, data packets, and handshake packets are combined into a USB transaction and provide the EN signal; the clock module 8 is input by the USB interface chip module 2 and controls the ULPI interface module 4, packet decomposition module 5, and transaction combination module 6. The clock of the transmission module 7; the transmission module 7 is used to output the combined USB transaction, the synchronization clock and the EN signal provided to the base plate to the base plate through the IO expansion port module 3. When the EN signal is high, each synchronization One clock cycle will output a byte in the USB transaction.
如图3所示,当ULPI接口模块4将包开始信号传到包分解模块5时,将8位并行数据存入8位宽的RAM中,当一个完整的包传输结束后,将PID、端点,设备地址信息、数据包长度和在RAM中的位置组成位宽为64的数据存入64位宽FIFO中缓存。当没有数据向底板传输时,处理FIFO中的数据。当一次事务传输完整时,将几个包的PID整合成一次事务的TID,把CRC舍弃掉,然后将几个包的信息整合成一个事务包信息头。As shown in Figure 3, when the ULPI interface module 4 transmits the packet start signal to the packet decomposition module 5, the 8-bit parallel data is stored in the 8-bit wide RAM. When a complete packet transmission is completed, the PID, endpoint , the device address information, data packet length and location in RAM form data with a bit width of 64 and are stored in the 64-bit wide FIFO cache. When no data is transmitted to the backplane, the data in the FIFO is processed. When a transaction transmission is complete, the PIDs of several packets are integrated into the TID of a transaction, the CRC is discarded, and then the information of several packets is integrated into a transaction packet information header.
如图1所示,USB接口芯片模块2需要将USB3300芯片中写入USB协议,以使其能够把差分信号还原成为电平信号,并翻译成符合ULPI协议的信号,再通过ULPI协议将数据转化为位宽为8位的数据传入FPGA处理。并将CLK信号传进FPGA内。As shown in Figure 1, the USB interface chip module 2 needs to write the USB protocol into the USB3300 chip so that it can restore the differential signal to a level signal and translate it into a signal that conforms to the ULPI protocol, and then convert the data through the ULPI protocol. The data with a bit width of 8 bits is transferred to the FPGA for processing. And transmit the CLK signal into the FPGA.
如图1所示,IO扩展口模块3连接着FPGA模块1的传输模块7;IO扩展口模块3将时钟信号输出给底板,使底板时钟同步;将事务有效信号EN和USB事务输出给底板。As shown in Figure 1, the IO expansion port module 3 is connected to the transmission module 7 of the FPGA module 1; the IO expansion port module 3 outputs the clock signal to the base board to synchronize the base board clock; it outputs the transaction valid signal EN and the USB transaction to the base board.
如图4所示,是本发明向底板传输的底板接收状态机。每个USB事务输出时,当EN有效时,依次将本次事务包输出,前4个字节为事务信息头,4字节的事务信息头格式为:As shown in Figure 4, it is the baseboard receiving state machine of the present invention that transmits to the baseboard. When each USB transaction is output, when EN is valid, the transaction package will be output in sequence. The first 4 bytes are the transaction information header, and the 4-byte transaction information header format is:
第1个字节:tid[7:0],表示该事务的类型;The first byte: tid[7:0], indicating the type of transaction;
第2个字节:addr[6:0],表示该事务对应的设备地址;The second byte: addr[6:0], indicating the device address corresponding to the transaction;
第3个字节:低4位为ep[3:0],表示该事务对应的端点号,高4位为len[3:0];The third byte: the lower 4 bits are ep[3:0], indicating the endpoint number corresponding to the transaction, and the upper 4 bits are len[3:0];
第4个字节:len[11:4],len[11:0]表示该事务对应的数据长度;The fourth byte: len[11:4], len[11:0] indicates the data length corresponding to the transaction;
后面跟随0~1024字节的事务数据。Followed by 0 to 1024 bytes of transaction data.
所述底板在上电后,进入初始状态(IDLE),当使能信号EN为1且前一个时钟EN为0时,也就是有USB事务由本系统传向底板时,接收第一个八位数据的信息头并进入HEADER_1状态。HEADER_1状态EN为1接收第二个八位数据的信息头并进入HEADER_2状态。HEADER_2状态EN为1接收第三个八位数据的信息头并进入HEADER_3状态。HEADER_3状态EN为1接收第四个八位数据的信息头并进入DATA状态。DATA状态只要EN为1就有数据持续传下来,直到EN为0,返回初始状态机(IDLE)。底板可根据此状态机加信息头约束去筛选所需数据。After the backplane is powered on, it enters the initial state (IDLE). When the enable signal EN is 1 and the previous clock EN is 0, that is, when a USB transaction is transmitted from the system to the backplane, the first eight-bit data is received. header and enter the HEADER_1 state. The HEADER_1 state EN is 1 to receive the second eight-bit data header and enter the HEADER_2 state. The HEADER_2 state EN is 1 to receive the third eight-bit data header and enter the HEADER_3 state. HEADER_3 state EN is 1 to receive the information header of the fourth eight-bit data and enter the DATA state. In the DATA state, as long as EN is 1, data will continue to be passed down until EN is 0, returning to the initial state machine (IDLE). The backplane can filter the required data based on this state machine and information header constraints.
上面结合附图对本发明的具体实施例作了详细说明,但是本发明并不限于上述实施例,在本领域普通技术人员所具备的知识范围内,还可以在不脱离本发明宗旨的前提下作出各种变化。The specific embodiments of the present invention have been described in detail above in conjunction with the accompanying drawings. However, the present invention is not limited to the above-mentioned embodiments. Within the scope of knowledge possessed by those of ordinary skill in the art, other modifications can be made without departing from the purport of the present invention. Various changes.
Claims (2)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011537834.8A CN112559429B (en) | 2020-12-23 | 2020-12-23 | System and method for monitoring data based on USB |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011537834.8A CN112559429B (en) | 2020-12-23 | 2020-12-23 | System and method for monitoring data based on USB |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112559429A CN112559429A (en) | 2021-03-26 |
CN112559429B true CN112559429B (en) | 2023-10-03 |
Family
ID=75030919
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011537834.8A Active CN112559429B (en) | 2020-12-23 | 2020-12-23 | System and method for monitoring data based on USB |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112559429B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN118535515B (en) * | 2024-06-03 | 2025-02-14 | 之江实验室 | USB communication method and device |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103999066A (en) * | 2011-12-16 | 2014-08-20 | 英特尔公司 | Automatic downstream to upstream mode switching at a universal serial bus physical layer |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9785595B2 (en) * | 2013-09-09 | 2017-10-10 | Lenovo Enterprise Solutions (Singapore) Pte. Ltd. | Multi-channel universal serial bus (USB) to subrate channel systems |
US11132441B2 (en) * | 2019-05-06 | 2021-09-28 | The Florida International University Board Of Trustees | Systems and methods for inhibiting threats to a computing environment |
-
2020
- 2020-12-23 CN CN202011537834.8A patent/CN112559429B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103999066A (en) * | 2011-12-16 | 2014-08-20 | 英特尔公司 | Automatic downstream to upstream mode switching at a universal serial bus physical layer |
Non-Patent Citations (2)
Title |
---|
Chenhao Duan等.FPGA-based USB 2.0 data monitoring and acquisition circuit function and simulation design.IOP Conference Series: Materials Science and Engineering.2019,第1-6页. * |
杨素英等.基于USB的数据采集系统的设计.计算机与现代化.2007,(第8期),第56-63页. * |
Also Published As
Publication number | Publication date |
---|---|
CN112559429A (en) | 2021-03-26 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN109828941B (en) | AXI2WB bus bridge implementation method, device, equipment and storage medium | |
CN103064805B (en) | SPI controller and communication means | |
CN103914424B (en) | LPC peripheral expansion method based on GPIO interface and device | |
CN101087235A (en) | A FPGA-based multi-functional communication interface conversion device and method | |
CN102253913B (en) | Device for carrying out state acquisition and output control on multi-board-card port | |
CN110213143A (en) | A kind of 1553B bus IP Core and monitoring system | |
CN101916237B (en) | DMA (Direct Memory Access) high-speed data transmission method of PCI (Programmable Communications Interface) bus | |
CN109165178B (en) | Rapid IO-based high-speed communication method between SoC (system on a chip) chips of system on missile | |
CN106933760A (en) | A kind of dma controller and data uploading method based on AXI protocol | |
CN204423250U (en) | A kind of X86 embedded type CPU mainboard with multipath high-speed intelligent CAN | |
CN104102160B (en) | Controller area network (CAN) bus signal transceiving analysis tool | |
CN109947019A (en) | Processing device and parallel work control method of train network input and output system | |
CN107908587A (en) | Real-time data acquisition transmitting device based on USB3.0 | |
CN112559429B (en) | System and method for monitoring data based on USB | |
CN102253916B (en) | Double-end double-channel first in first out (FIFO) for synchronous-to-asynchronous conversion | |
CN109359082B (en) | USB data real-time monitoring system and method based on FPGA | |
CN101140551B (en) | A device for realizing asynchronous serial communication of digital signal processor | |
CN112631976A (en) | Configurable hardware IP circuit structure | |
US6874047B1 (en) | System and method for implementing an SMBus/I2C interface on a network interface card | |
CN117251397A (en) | Communication method of processor and external SRIO device | |
CN113709010B (en) | A Modbus Communication Protocol System with Unlimited Frame Length | |
CN100462952C (en) | Universal Serial Bus controller with configurable interface | |
Zuquim et al. | An embedded converter from RS232 to Universal Serial Bus | |
CN101452439A (en) | CompactPCI communication card | |
CN115296741A (en) | Cross-platform optical fiber transmission system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |