A high-speed data acquisition system and method based on FPGA
By using DDR cache modules and ring buffers in the FPGA system, combined with AXI and PCIE protocols, efficient transmission of high-speed network data is achieved, solving the problem of excessive CPU resource usage, and achieving 100% line-speed transmission and high throughput. .
Patent Information
- Application Number
- CN201911059477.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-11-01
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2039-11-01
AI Technical Summary
When the existing data acquisition system processes high-speed network data, the CPU resources are too large, resulting in low transmission efficiency, unable to achieve 100% line speed, and prone to packet loss.
Design a high-speed data transmission acquisition system based on FPGA. Through the DDR cache module and ring buffer, the AXI bus and PCIE protocol are used to realize high-speed data transmission. DMA operation is used to transmit the data from the DDR cache to the host computer system memory to ensure that the data Packet integrity and high throughput.
It achieves 100% line-speed transmission of 10Gbps network data, reduces CPU intervention, improves data transmission efficiency, and is suitable for higher-rate network data collection.
Smart Images

Figure CN112765054B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network information collection, and in particular to a high-speed data transmission and collection system and method based on FPGA. Background Art
[0002] The rapid development of modern digital processing technology and network technology has made it possible for complex systems to process massive amounts of collected data in real time. With the emergence of applications such as 5G networks, the Internet of Things, and cloud computing, the increasing amount of data and the increasing data transmission speed have also put forward higher requirements for today's data acquisition and processing systems. High-speed data transmission and acquisition systems are widely used in communications, networks and other fields, and the requirements for higher speed, high precision, and real-time performance of the system are becoming more urgent. Faced with increasingly heavy signal acquisition and processing tasks, the rate and capacity of data storage have become important factors restricting system performance.
[0003] With the gradual increase of network bandwidth, high-speed port interconnection and data transmission has become a research hotspot in the industry. In areas such as network security and digital algorithm processing that require a large amount of data transmission, the requirements for the efficiency, security, and integrity of high-speed network port transmission are becoming increasingly higher. With the continuous development of high-speed serialization of data transmission, serial bus standards such as PCIE bus and high-speed Ethernet have been proposed one after another, which also enables high-speed data transmission. The PCIE DMA transmission method reduces CPU intervention, has extremely fast transmission rate, and low latency; compared with other serial buses, high-speed Ethernet also has the advantages of larger bandwidth, faster transmission rate, and longer transmission distance.
[0004] After decades of rapid development, FPGA has gradually become one of the mainstream platforms for high-speed data processing systems. Due to its outstanding advantages of parallelism and high throughput, it is widely used in various fields of network communication. For high-speed data processing systems, FPGA is usually used to transmit the data to be processed to the host server for subsequent precision and complex calculation processing. This involves the problem of large-scale data transmission between FPGA and the host computer. Therefore, building a high-speed data transmission and acquisition system and method between the server and FPGA has become the current research focus of the industry.
[0005] At present, DDR SDRAM (Double Data Rate SDRAM, DDR) is often used to expand the system's storage space and improve the ability to store and process data in real time. The memory controller is used to complete operations such as reading, writing, and refreshing the memory. DDR SDRAM is widely used in FPGA board design. Through the configuration of the internal memory controller, various functions that require high-speed cache design can be implemented. Xilinx, Altera, Synopsys and other companies have developed and released universal DDR series controller IP cores. Based on the important role of DDR SDRAM in FPGA, designing a high-speed, low-latency data transmission and acquisition system, as well as a method for efficiently processing the collected data, has a wide range of application scenarios and has great research significance for future networks and big data processing.
[0006] At present, the data received by traditional servers from the network port needs to be processed by the CPU, which will take up a lot of CPU resources. The CPU's processing capacity for small packets is far from enough. Using pure software methods to receive packets from the 10G network card and put them into the server memory, for 10Gbps such as Ethernet packets with a length of 64 bytes, the general line speed can only reach 60% or even lower, and cannot reach 100% line speed, which will cause packet loss. Summary of the invention
[0007] The purpose of the present invention is to overcome the above technical defects, and provide a cache processing system and method for network data acquisition and transmission scenarios based on FPGA, through which high-throughput data packet sending and receiving tasks can be achieved. The server and the FPGA board adopt high-speed network port protocol and PCIE protocol for communication, the network port receives the data transmitted by the server and transmits it to DDR through AXI bus as a large-capacity cache, and then transmits the data cached in DDR to the host computer system memory at high speed through DMA operation and performs corresponding subsequent processing. When extracting data from the DDR cache to the host computer system memory, a circular cache method is adopted, and the read and write pointers are set respectively to record the data information of the DDR cache. When the amount of data between the read and write pointers reaches the set value (such as 2MB), a DMA operation is performed to transfer the data to the host computer system memory. For a 10Gbps high-speed network port, the method of the present invention can reach 14.88Mpps (64-byte packet), achieve 100% line speed, and can synchronously import data into the server memory.
[0008] To achieve the above object, the present invention proposes a high-speed data transmission and acquisition system based on FPGA, the system comprising a data receiving module, a DDR cache module and a data uploading module; the DDR cache module comprises a ring buffer, a write pointer and a read pointer; the ring buffer stores data, the write pointer points to the position after the ring buffer writes data, and the read pointer points to the position after the ring buffer reads data;
[0009] The data receiving module is used to receive network data packets, parse the data packets and write them into the ring buffer, and synchronously modify the position of the write pointer; when the difference between the write pointer and the read pointer reaches a preset data amount, a data read instruction is sent to the data uploading module;
[0010] The data upload module is used to read the data between the read pointer and the write pointer of the ring buffer when receiving an instruction to read data, upload the data to the host computer, and synchronously modify the position of the read pointer.
[0011] As an improvement of the above system, the data receiving module includes an XGMII core interface, a FIFO, an AXI bus, a MIG core and a counter;
[0012] The XGMII core interface is used to receive network data packets, parse the layer 2 network protocol through FPGA to obtain the leading code indication signal and the current packet end signal, and write the valid data of each data packet into the FIFO;
[0013] The FIFO is used to output the data processed across clock domains to the AXI bus; the AXI bus forwards the FIFO data to the MIG core through burst setting;
[0014] The MIG core is used to write data into a ring buffer;
[0015] The counter is used to count the number of AXI bus bursts and synchronously modify the position of the write pointer.
[0016] As an improvement of the above system, in the initial state, the read pointer and the write pointer are both at the starting position of the ring buffer storage area; during modification, the read pointer and the write pointer rotate in the same direction of the ring buffer.
[0017] As an improvement of the above system, the preset data volume is 256K, 512K or 2M.
[0018] As an improvement of the above system, the data upload module includes a PCIE core and a DMA controller; the DMA controller is used to read the data between the read pointer and the write pointer of the ring buffer through the PCIE core when receiving an instruction to read data, and upload it to the host computer.
[0019] As an improvement of the above system, the system also includes: a timer, which is used to monitor in real time whether there is new data input to the XGMII core interface, and is cleared when there is new data input; when the timing value exceeds the preset time, a data read instruction is sent to the data upload module; the DMA controller reads the remaining data in the ring buffer through the PCIE core and uploads it to the host computer.
[0020] The present invention also proposes a high-speed data transmission and acquisition method based on FPGA, which is implemented based on the above system. The method includes:
[0021] The data receiving module receives network data packets, parses the data packets and writes them into the ring buffer, the counter counts the number of AXI bus bursts, and synchronously modifies the position of the write pointer;
[0022] When the difference between the write pointer and the read pointer reaches a preset data amount, a data read instruction is sent to the data upload module;
[0023] When the data upload module receives a data read instruction, the data between the read pointer and the write pointer of the ring buffer is read through the PCIE core, uploaded to the host computer, and the position of the read pointer is modified synchronously.
[0024] As an improvement of the above method, the method further comprises:
[0025] Initialize each module of the system;
[0026] Set AXI bus burst mode;
[0027] The read pointer and the write pointer are both set at the starting position of the ring buffer storage area.
[0028] As an improvement of the above method, the data receiving module receives a network data packet, parses the data packet and writes it into a ring buffer, specifically including:
[0029] When the XGMII core interface receives a data packet and its transmission output enable is 1, the FIFO write enable is set to 1 and data starts to be transmitted to the FIFO. The number of FIFO input bits is based on the network port data unit. When the burst number set by the AXI bus is reached, the read enable is set to 1, and the AXI bus starts to read the data in the FIFO and transmits it to the ring buffer through the MIG core.
[0030] As an improvement of the above method, the method further includes: when the timing value of the timer exceeds a preset time, sending an instruction to read data; the DMA controller reads the remaining data in the ring buffer through the PCIE core and uploads it to the host computer.
[0031] Compared with the prior art, the advantages of the present invention are:
[0032] 1. The high-speed data transmission and acquisition system of the present invention realizes the capture of high-speed network data packets based on FPGA, as well as PCIE high-speed transmission, and has a very high throughput rate; for a 10Gbps high-speed network port, this method can reach 14.88Mpps (64-byte packets), achieving 100% line speed, and can synchronously import data into server memory;
[0033] 2. The DDR ring cache writing and reading method of the FPGA board proposed in the present invention has good practicality. In network data transmission applications, it can not only ensure the integrity of data packet transmission, but also cooperate with DMA transmission to reduce CPU intervention consumption, thereby improving transmission efficiency and having wide applicability.
[0034] 3. The system and method provided by the present invention have good universality, and are also applicable to single-channel 25G optical ports, as well as parallel data collection of multiple optical ports, and are applicable to high-speed network data collection such as 20G / 25G / 40G / 100G;
[0035] 4. The system and method of the present invention can realize high-throughput network data collection at a rate of 10Gbps and above. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a framework design diagram of the system of high-speed data transmission and collection based on FPGA of the present invention;
[0037] Figure 2 It is a schematic diagram of the DDR cache ring read pointer setting of the present invention;
[0038] Figure 3 It is a flow chart of the method for high-speed data transmission and acquisition based on FPGA of the present invention. DETAILED DESCRIPTION
[0039] The technical solution of the present invention is further described below in conjunction with the accompanying drawings. These embodiments are used to illustrate the present invention but are not intended to limit the scope of the present invention.
[0040] The present invention proposes a high-speed data transmission and collection system based on FPGA, which is used for completely transmitting data packets collected from the network to a host computer for processing. The system includes an FPGA for receiving data packets through a high-speed network port (10Gbps or higher rate). The FPGA parses the received data packets through a data link layer protocol and stores them in a DDR cache through a FIFO and an AXI bus. The data cached in a large-capacity DDR is transmitted to the host computer at a high speed through a PCIE core interface through a DMA operation, and the user performs the next step of processing.
[0041] Based on the state machine, the FPGA writes to the DDR ring buffer through the AXI bus, and the write pointer is modified synchronously after each data is written; the large block of data is read from the DDR ring buffer through the DMA driver, and the read pointer is modified synchronously after each read. The read and write pointers rotate in the same direction (such as clockwise) of the DDR ring buffer. When the difference between the write pointer and the read pointer reaches a certain large block value (such as 2MB), the upper-level application calls the DMA driver to perform a DMA read operation. When the write pointer does not change for more than a certain time interval (such as 50ms) (indicating that there is no new data in the network in the recent period of time), the DMA reads the remaining data in the DDR ring buffer at one time.
[0042] Example 1
[0043] like Figure 1 As shown, Embodiment 1 of the present invention proposes a high-speed data transmission and acquisition system based on FPGA, including a data receiving module, a DDR buffer module and a data uploading module;
[0044] The DDR cache module includes: a ring buffer, a write pointer and a read pointer; the ring buffer allows concurrent reading and writing, and data reading and writing in the buffer can be achieved by moving the read pointer and the write pointer.
[0045] Data receiving module: used to receive network data packets sent by a server through the XGMII core interface of FPGA, and store them into the DDR cache module through the AXI bus through the set asynchronous FIFO after parsing;
[0046] The data receiving module mainly implements the data reception of FPGA, ensuring that the data transmitted by the network port can be stably and completely cached in the DDR cache module.
[0047] This module mainly includes XGMII core interface, one or more asynchronous FIFOs, AXI bus, several MIG cores and counters. The XGMII core interface receives network data packets sent by a server. Since the network port transmission clock is 156MHz and the AXI bus read and write clock is 250MHz, a FIFO needs to be added between the AXI bus and the network port to complete the cross-clock domain conversion and data structure conversion. By setting FIFO and controlling the corresponding read and write enable, it is possible to avoid the problems of timing disorder and data instability caused by the introduction of complex timing to establish the data conversion module due to data requirements. FIFO can ensure that the read and write enable, data and read and write clocks are of the same source, avoiding the problem of unstable transmission caused by cross-clock domain. The enable signal is used as the write enable of the asynchronous FIFO, and the data output by the network port is connected to the write data interface of the data FIFO. The data processed across the clock domain is output from the FIFO to the AXI bus, and is transmitted to the ring buffer through the MIG core through the burst setting of the AXI bus.
[0048] The counter counts the burst times of the AXI bus and modifies the position of the write pointer synchronously.
[0049] The write pointer points to the writable buffer in the ring buffer, that is, the end position of the valid data. The write pointer is modified synchronously after each data is written. The read pointer points to the readable buffer in the ring buffer, that is, the start position of the valid data; the read pointer is modified synchronously after each data is read, and the read pointer points to the next data address position;
[0050] like Figure 2 As shown, in the initial state, the read pointer and the write pointer overlap at the starting position, and the read and write pointers rotate in the same direction (e.g., clockwise) of the DDR ring buffer. When the MIG core is called to continuously buffer data to the DDR, the write pointer moves accordingly. When the amount of data between the read pointer and the write pointer reaches a preset amount of data, the read state is turned on, the amount of data between the read pointer and the write pointer is read out, and the read pointer points to a new position.
[0051] The data volume between the read and write pointers can be set to 256K, 512K or 2M according to actual needs, and the data volume is the data block size for one DMA transmission with the host computer. This embodiment adopts 2M.
[0052] The data upload module is used to transfer the data in the ring buffer to the host computer via PCIE DMA for the user to process in the next step;
[0053] The data upload module mainly realizes the data upload between FPGA and host computer, ensuring that the data packets cached in DDR can be stably transmitted to the host computer memory through the FPGA board for the next operation. This module mainly includes PCIE core and DMA controller.
[0054] A hardware timer is designed in FPGA to monitor whether there is new data input to the network port in real time. When there is new data input, the counter is cleared. When the timing exceeds the initial set time (such as 50ms), it is considered that there has been no new data input to the network port during this period, and the remaining data (less than 2MB) in the DDR ring buffer is transmitted to the host computer in DMA mode.
[0055] When the data packet received by the network is uploaded to the host computer memory by DDR for the last time, since the data volume between the read and write pointers is set to 2MB, the data volume in the last uploaded data packet is less than 2MB. At this time, a judgment flag needs to be set to judge that the DDR cache has completed the write operation. Here, a 50ms write pointer retention time is set as the judgment standard. The standard can be set according to the actual situation. Here is the commonly used judgment time. If the retention time exceeds 50ms, it means that the write operation has been completed, and the remaining data volume needs to be uploaded to the server.
[0056] The design steps of the FPGA-based high-speed data transmission and acquisition system of the present invention are as follows:
[0057] S01: Analyze each interface protocol and determine the IP core design of each interface, including PCIE core, xgmii core, DMA core, FIFO IP core, AXI bus IP core and MIG core.
[0058] S02: Complete the high-speed network port input logic design, including receiving logic design, xgmii interface design, AXI bus design, and realize high-speed network port data transmission;
[0059] S03: Complete the DDR storage interface design, including one or more asynchronous FIFO designs and MIG designs, to implement DDR read and write operations;
[0060] S04: Complete the design of the DDR ring buffer reading method, including the read-write pointer design, the timing module design, and the logic design of the counting module, to realize the reading of DDR data to the host computer memory with a constant data volume;
[0061] S05: Complete the PCIE core transmission logic design, including receiving / sending logic design and DMA control logic design, and realize the high-speed DMA read and write design of FPGA board and server;
[0062] S06: Complete the functional verification of the entire high-speed data transmission and acquisition system to ensure the correctness and efficiency of data transmission from the FPGA end to the server end;
[0063] S07: Port the entire platform to the hardware FPGA, including various hardware IPs, and write drivers for various hardware devices based on the official software drivers;
[0064] S08: Call each hardware IP core at the user layer to form the entire high-speed data transmission and acquisition system.
[0065] Example 2
[0066] like Figure 3 As shown, based on the above system, embodiment 2 of the present invention proposes a high-speed data transmission and acquisition method based on FPGA, including:
[0067] After the FPGA board is powered on and reset, each FPGA module is initialized, and the bus burst mode and DDR starting read and write address are set.
[0068] After the network port transmission output enable is 1, the FIFO write enable is set to 1, and data starts to be transmitted to the FIFO. The number of FIFO input bits is based on the network port data unit. When the burst number set by the AXI bus is reached, the read enable is set to 1, and the AXI bus starts to read the data in the FIFO and transmits it to the ring buffer on the FPGA board through the MIG core;
[0069] The counter counts the number of AXI bus bursts; the position of the write pointer is modified synchronously;
[0070] When the amount of data between the write pointer and the read pointer reaches the preset amount, a DMA operation is initiated to read the ring buffer data to the host computer.
[0071] If the amount of data between the read and write pointers does not reach 2MB, and the write pointer position does not change for more than 50ms, the remaining amount of data between the read and write pointers will be sent to the host computer memory via DMA. At this point, the entire data packet received by the network port has been uploaded to the host computer.
[0072] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention is described in detail with reference to the embodiments, it should be understood by those skilled in the art that any modification or equivalent replacement of the technical solutions of the present invention does not depart from the spirit and scope of the technical solutions of the present invention and should be included in the scope of the claims of the present invention.
Claims
1. A high-speed data transmission and acquisition system based on FPGA, It is characterized in that The system includes a data receiving module, a DDR buffer module and a data uploading module; the DDR buffer module includes a ring buffer, a write pointer and a read pointer; the ring buffer stores data, the write pointer points to the position after the ring buffer writes data, and the read pointer points to the position after the ring buffer reads data; The data receiving module is used to receive network data packets, parse the data packets and write them into the ring buffer, and synchronously modify the position of the write pointer; when the difference between the write pointer and the read pointer reaches a preset data amount, a data read instruction is sent to the data uploading module; The data upload module is used to read the data between the read pointer and the write pointer of the ring buffer when receiving the instruction to read data, upload it to the host computer, and synchronously modify the position of the read pointer; The data receiving module includes an XGMII core interface, a FIFO, an AXI bus, a MIG core and a counter; The XGMII core interface is used to receive network data packets, parse the layer 2 network protocol through FPGA to obtain the leading code indication signal and the current packet end signal, and write the valid data of each data packet into the FIFO; The FIFO is used to output the data processed across clock domains to the AXI bus; the AXI bus forwards the FIFO data to the MIG core through burst setting; The MIG core is used to write data into a ring buffer; The counter is used to count the number of AXI bus bursts and synchronously modify the position of the write pointer.
2. The system according to claim 1, It is characterized in that In the initial state, the read pointer and the write pointer are both at the starting position of the ring buffer storage area; during modification, the read pointer and the write pointer rotate in the same direction of the ring buffer.
3. The system according to claim 2, It is characterized in that The preset data volume is 256K, 512K or 2M.
4. The system according to claim 2, It is characterized in that The data upload module includes a PCIE core and a DMA controller; the DMA controller is used to read the data between the read pointer and the write pointer of the ring buffer through the PCIE core when receiving a data read instruction, and upload the data to the host computer.
5. The system according to claim 4, It is characterized in that The system also includes: a timer, which is used to monitor in real time whether there is new data input to the XGMII core interface, and is cleared when there is new data input; when the timing value exceeds the preset time, a data read instruction is sent to the data upload module; the DMA controller reads the remaining data in the ring buffer through the PCIE core and uploads it to the host computer.
6. A high-speed data transmission and acquisition method based on FPGA, implemented based on the system of one of claims 1-5, the method include: The data receiving module receives network data packets, parses the data packets and writes them into the ring buffer, the counter counts the number of AXI bus bursts, and synchronously modifies the position of the write pointer; When the difference between the write pointer and the read pointer reaches a preset data amount, a data read instruction is sent to the data upload module; When the data upload module receives a data read instruction, it reads the data between the read pointer and the write pointer of the ring buffer, uploads the data to the host computer, and synchronously modifies the position of the read pointer.
7. The method according to claim 6, It is characterized in that The method further comprises: Initialize each module of the system; Set AXI bus burst mode; The read pointer and the write pointer are both set at the starting position of the ring buffer storage area.
8. The method according to claim 7, It is characterized in that The data receiving module receives network data packets, parses the data packets and writes them into the ring buffer, specifically including: When the XGMII core interface receives a data packet and its transmission output enable is 1, the FIFO write enable is set to 1 and data starts to be transmitted to the FIFO. The number of FIFO input bits is based on the network port data unit. When the burst number set by the AXI bus is reached, the read enable is set to 1, and the AXI bus starts to read the data in the FIFO and transmits it to the ring buffer through the MIG core.
9. The method according to claim 8, It is characterized in that The method further comprises: when the timing value of the timer exceeds the preset time, sending a data reading instruction; the DMA controller reads the remaining data in the ring buffer through the PCIE core and uploads the data to the host computer.
Citation Information
Patent Citations
Method, device and digital-television receiving terminal for realizing ring buffer
CN101800867A
System and method for realizing multipath burst data business caching based on FPGA (Field Programmable Gate Array)
CN102096648A
Method and device for using annular data buffer to read and write batch data
CN102591815A
Memory control device, mobile terminal, memory control program, and computer-readable recording medium
CN104603867A
Caching method for NANDFlash to FPGA (field programmable gate array) internal block RAM (random-access memory)
CN107729269A
