A data exchange method and device based on FPGA memory dynamic allocation
Through the dynamic allocation strategy of RAM within FPGA, the message caching problem of traditional network switching chips in the power system is solved, the hardware cost and complexity are reduced, the real-time and reliability of data transmission are improved, and the personalization of the power system is satisfied. need.
Patent Information
- Application Number
- CN202111093096.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-17
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-09-17
AI Technical Summary
Traditional network switching chips cannot change their own structure when the network topology changes, and the use of external SRAM memory results in high hardware cost and implementation complexity, which cannot meet the diverse and personalized network communication needs in the power system.
Adopting a dynamic memory allocation strategy based on FPGA, the first-level and second-level cache units are implemented through the FPGA internal RAM, and cache resources are dynamically allocated to handle burst transmission of messages, avoiding the use of external SDRAM.
It reduces hardware cost and implementation complexity, improves the real-time and reliability of data transmission, meets the personalized needs of power protection devices, and achieves flexible network port configuration and efficient message forwarding.
Smart Images

Figure CN113836048B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of communication and power system automation, and in particular to a data exchange method and device based on FPGA memory dynamic allocation. Background Art
[0002] With the continuous development of digitalization and intelligence of substations, the demand for diversified and personalized network communications is increasing, and the limitations of traditional network switching chips are becoming more and more obvious. Busbar protection devices suitable for various voltage levels of 1000kV and below include a main box and a sub-box. The main box must complete SV sampling and GOOSE tripping functions through the network. The sub-unit is an extension of the main box and must also complete SV and GOOSE data reception and communication with the host. The network topology of the busbar protection device is as follows: Figure 1 As shown, the slave communicates with the host externally through switch port 5, and the slave switch ports 1 to 4 communicate with the external network. Ports 1 to 4 are point-to-point communications and the message traffic is controllable. Port 5 is the aggregation port of ports 1 to 4. The instantaneous traffic may be very large, and the switch needs to handle the message burst transmission of port 5.
[0003] An Ethernet switch is a network device used for signal forwarding, which can provide an exclusive signal path for any two network nodes connected to the switch. A switch working at the second layer of the OSI reference model, the data link layer, is also called a layer 2 switch. It has no IP routing function and only handles the switching business of the data link layer. There are currently two strategies for implementing network switching. One is to use off-the-shelf network chips; the other is to use field programmable devices (FPGAs) to implement network switching functions. When the network topology changes, the network switching chip cannot change its own structure, and its use will be limited. Currently, network switching implemented using FPGAs will use external SRAM memory to temporarily store forwarded network packets, which has high hardware cost and implementation complexity. Summary of the invention
[0004] Based on the above situation of the prior art, the purpose of the present invention is to provide a data exchange method and device based on FPGA memory dynamic allocation, which adopts a memory dynamic allocation strategy to solve the message cache problem of the cascade port, wherein the cache is only implemented using the internal RAM of the FPGA, reducing the hardware cost and implementation complexity.
[0005] To achieve the above object, according to one aspect of the present invention, a data exchange method based on dynamic allocation of FPGA memory is provided, comprising the steps of:
[0006] S1, receiving Ethernet messages, parsing the forwarding destination port and encapsulating it into the forwarding message;
[0007] S2, storing the forwarded message in a first-level cache unit;
[0008] S3. Determine the occupancy of the secondary cache unit, and process the forwarded message according to the determination result.
[0009] Furthermore, the first-level cache unit and the second-level cache unit are both provided by FPGA memory.
[0010] Furthermore, the secondary cache unit may be allocated dynamically.
[0011] Further, the determining of the occupancy of the secondary cache unit and processing the forwarded message according to the determination result includes:
[0012] S31, query whether the destination port occupies the secondary cache unit, if so, jump to step S36; if not, execute step S34;
[0013] S34, determining whether the sending buffer of the destination port is full, if so, executing step S35; if not, jumping to step S38;
[0014] S35, determine whether the secondary cache unit is idle, if so, execute step S36; if not, the message data overflows;
[0015] S36, storing the forwarded message in a secondary cache unit;
[0016] S37, when the secondary cache unit is not empty, wait until there is space in the send cache of the destination port;
[0017] S38: Write the message data into the sending buffer of the destination port and send it.
[0018] Furthermore, it also includes:
[0019] If the secondary cache unit is not empty, the space of the secondary cache unit is released.
[0020] According to another aspect of the present invention, a data exchange device based on dynamic allocation of FPGA memory is provided, comprising a message receiving module, a message storage module, and a message processing module; wherein:
[0021] The message receiving module is used to receive Ethernet messages, parse out the forwarding destination port and encapsulate it into the forwarding message;
[0022] The message storage module is used to store the forwarded message in a first-level cache unit;
[0023] The message processing module is used to determine the occupancy of the secondary cache unit and process the forwarded message according to the determination result.
[0024] Furthermore, the first-level cache unit and the second-level cache unit are both provided by FPGA memory.
[0025] Furthermore, the secondary cache unit may be allocated dynamically.
[0026] Further, the message processing module determines the occupancy of the secondary cache unit, and processes the forwarded message according to the determination result, including:
[0027] S31, query whether the destination port occupies the secondary cache unit, if so, jump to step S36; if not, execute step S34;
[0028] S34, determining whether the sending buffer of the destination port is full, if so, executing step S35; if not, jumping to step S38;
[0029] S35, determine whether the secondary cache unit is idle, if so, execute step S36; if not, the message data overflows;
[0030] S36, storing the forwarded message in a secondary cache unit;
[0031] S37, when the secondary cache unit is not empty, wait until there is space in the send cache of the destination port;
[0032] S38, write the message data into the sending buffer of the destination port and send
[0033] Furthermore, the message processing module is also used to release the space of the secondary cache unit if the secondary cache unit is not empty.
[0034] In summary, the present invention provides a data exchange method and device based on FPGA memory dynamic allocation, using field programmable FPGA devices to implement Ethernet layer 2 switching processing services, and using a memory dynamic allocation strategy, that is, using FPGA internal RAM to implement a first-level cache unit and a second-level cache unit as a forwarding message cache, the first-level cache unit caches the Ethernet message after the second-level switching process, and the second-level cache unit is dynamically allocated to a port with message burst transmission. Generally, only the first-level cache unit is used as a forwarding message cache. When the instantaneous flow of a port is too large, the second-level cache unit is applied to occupy the second-level cache unit. After the message is sent, the second-level cache unit is released. The second-level cache unit is dynamically allocated to the port with large instantaneous flow, and the internal cache of the FPGA is used reasonably and efficiently, eliminating the SDRAM that needs to be mounted for the conventional message cache strategy. The present invention solves the message cache problem of the cascade port by adopting a memory dynamic allocation strategy, wherein the cache is only implemented using the internal RAM of the FPGA, reducing the hardware cost and implementation complexity.
[0035] Compared with the prior art, the present invention has the following beneficial technical effects:
[0036] (1) The MAC layer module of the present invention is implemented by the internal logic of FPGA, and the number of network ports can be flexibly configured as needed, with good portability and versatility;
[0037] (2) Implementing Layer 2 Ethernet switching service processing through field programmable logic FPGA devices to solve the shortcomings of traditional Ethernet switching chips, such as complex functions, hardening and difficult upgrades, and difficulty in meeting personalized needs. FPGA software customization can be used to implement Ethernet switching processing functions that meet the needs of power protection devices;
[0038] (3) The memory dynamic allocation strategy proposed by the present invention uses the FPGA internal resource RAM to implement message forwarding storage, eliminating the need for conventional message storage external SDRAM, thus reducing hardware cost and design complexity;
[0039] (4) The MAC address table and message forwarding storage of the present invention are implemented inside the FPGA, which is convenient for data storage and reading, the network data transmission path is short, the message forwarding delay is small, the real-time performance of data transmission is enhanced, and the reliability of the protection device is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] Figure 1 It is a network topology diagram of a busbar protection device in the prior art;
[0041] Figure 2 It is a flow chart of the data exchange method based on FPGA memory dynamic allocation of the present invention;
[0042] Figure 3 It is a schematic diagram of Layer 2 network switching service processing. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention is further described in detail below in conjunction with specific embodiments and with reference to the accompanying drawings. It should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present invention. In addition, in the following description, the description of well-known structures and technologies is omitted to avoid unnecessary confusion of the concept of the present invention.
[0044] In view of the characteristics of power system network communication, most network ports are point-to-point communication, and only one network port is used as a cascade port to communicate with the host with message burst transmission. In the embodiment of the present invention, a memory dynamic allocation strategy is proposed to solve the message cache problem of the cascade port. The cache is only implemented using the internal RAM of the FPGA, which reduces the hardware cost and implementation complexity.
[0045] The technical solution of the present invention will be described in detail below in conjunction with the accompanying drawings. According to one embodiment of the present invention, a data exchange method based on dynamic allocation of FPGA memory is provided. The hardware structure based on the method provided in this embodiment mainly includes a network port physical circuit, an FPGA chip and an external FLASH. The network port physical circuit is responsible for the network port physical layer data processing, and is interconnected with the FPGA via an RMII interface, and the external FLASH stores the FPGA program. The field programmable logic FPGA chip completes the reception and transmission of 100M MAC layer messages, the second-layer forwarding processing of network messages, and the use of the internal RAM of the FPGA to temporarily store the forwarded network packets. The network topology structure of Ethernet data interaction includes a MAC layer module and a second-layer network exchange service processing, and the MAC layer module and the second-layer network exchange service processing are both implemented using FPGA. Each MAC layer module consists of a MAC sending module and a MAC receiving module. The network exchange service processing consists of a receiving service control, a data processing unit, a MAC address table module, a first-level cache unit, a second-level cache unit and a sending processing control, wherein the number of MAC modules is flexibly configured according to needs.
[0046] The MAC layer module communicates with the network physical layer chip via the RMII interface. The MAC receiving module caches the external input network data message into the receiving cache. The receiving service control polls and reads the message received in each MAC port receiving cache, and encapsulates the received port number as the source port number into the receiving message and passes it to the data processing unit. The data processing unit is the core module of network switching. It parses the destination MAC address, source MAC address and source port number of the message and passes them to the MAC address table module. The MAC address table module completes MAC address table learning, aging and search. The MAC address table module outputs the destination port to forward the message to realize the second-layer network switching service. The data processing unit encapsulates the destination port into the message and passes it to the first-level cache unit. The first-level cache unit stores the messages that have been exchanged and passes the forwarded messages to the first-level cache unit according to the traffic status of each network port. The sending process control or cache is to the secondary cache unit; the secondary cache unit has two states, namely, idle state and working state. When the network traffic is normal, the secondary cache unit is in the idle state. When a port has a burst transmission, the port applies to use the secondary cache unit, and stores the forwarding message that is not transmitted in time in the secondary cache unit. At this time, the secondary cache unit is in the working state, and other ports are not allowed to apply for use. After the forwarding message of the port is sent, the secondary cache unit is released, and the secondary cache unit returns to the idle state; the sending process control needs to read the forwarding message of the primary cache unit and the secondary cache unit, parse the destination port number of the message, write the forwarding message into the sending cache of the corresponding port, and query the status of the sending cache in real time, and feed back the status of the sending cache to the primary cache unit; the MAC sending module reads the message in the sending cache, sends it out frame by frame, and completes the message forwarding. That is to say, the Ethernet switching function and message storage involved in this embodiment are all realized by FPGA, and FPGA devices are used to realize Ethernet switching service processing, replace the traditional Ethernet switching dedicated chip, and propose a memory dynamic allocation strategy, which saves the conventional external SRAM storage in the forwarding message storage, and only uses the RAM of FPGA to realize message caching. The dynamic memory allocation strategy is implemented by using two levels of cache, both of which are implemented using FPGA internal RAM resources. Figure 2 As shown, the following steps are included:
[0047] S1, receiving Ethernet messages, parsing the forwarding destination port and encapsulating it into the forwarding message;
[0048] S2, storing the forwarded message in a first-level cache unit;
[0049] S3, judging the occupancy of the secondary cache unit, and processing the forwarded message according to the judgment result. This step can be further implemented by the following steps:
[0050] S31, query whether the destination port occupies the secondary cache unit, if so, jump to step S36; if not, execute step S34;
[0051] S34, determining whether the sending buffer of the destination port is full, if so, executing step S35; if not, jumping to step S38;
[0052] S35, determine whether the secondary cache unit is idle, if so, execute step S36; if not, the message data overflows;
[0053] S36, storing the forwarded message in a secondary cache unit;
[0054] S37, when the secondary cache unit is not empty, wait until there is space in the send cache of the destination port;
[0055] S38: Write the message data into the sending buffer of the destination port and send it.
[0056] The method further includes: if the secondary cache unit is not empty, releasing the space of the secondary cache unit.
[0057] Wherein, the first-level cache unit and the second-level cache unit are both provided by FPGA memory, and the second-level cache unit can be dynamically allocated.
[0058] First, after the received Ethernet message is processed by the data processing unit, the destination port A to be forwarded is encapsulated into the message, and then the forwarded message is placed in the first-level cache unit. The first-level cache unit queries whether port A has occupied the second-level cache. If port A has not occupied the second-level cache, it determines whether the send cache of port A is full. If the send cache of port A is not full, it is directly written; if the send cache of port A is full, it applies to use the second-level cache. If the current second-level cache is idle, the application is successful and the second-level cache enters the working state. If the application is unsuccessful, the current message overflows; if port A has occupied the second-level cache, the forwarded messages of port A are stored in the second-level cache. When there is space in the send cache of port A, the forwarded message is read from the second-level cache to the send cache of port A until the messages in the second-level cache are sent. Port A releases the second-level cache and the second-level cache enters the idle state. The second-level cache is to alleviate the problem of overflow of the send cache of a certain port in burst transmission. The second-level cache can be dynamically allocated. When the second-level cache is in the idle state, the port with a full send cache can apply to use the second-level cache. When the second-level cache is in the working state, it does not accept applications from other ports.
[0059] As a specific implementation method, the hardware for implementing the memory dynamic allocation Ethernet switching service in the sub-unit device of the intelligent station bus protection device can be selected from the Unigroup FPGA chip PGL22G, the 100M Ethernet PHY chip YT8512H and the FPGA program storage FLASH chip SGC25N016D, all of which are domestic chips. In this embodiment, the FPGA chip PGL22G is connected to the Ethernet PHY chip through the RMII interface, where the number of MACs can be configured as needed. This article sets 5 MACs as an example. The FPGA implements the 100M Ethernet MAC layer module, the Layer 2 network switching service, and the cache of the forwarded message.
[0060] Figure 3The schematic diagram of the layer 2 network switching service processing is shown in the figure. Its overall design consists of the layer 2 network switching service and the dynamic memory storage of the forwarding message, which are all implemented by FPGA software. The internal function implementation of FPGA can be divided into multiple independent modules, mainly including MAC layer module and layer 2 network switching service. Each MAC module consists of MAC sending module and MAC receiving module. The layer 2 network switching service consists of receiving service control, data processing unit, MAC address table module, first-level cache unit and second-level cache unit and sending processing control. The MAC layer module consists of MAC receiving module and MAC sending module. The external interface of the MAC layer module is a standard RMII interface. The main function is to realize the data interaction between FPGA and the physical layer chip of the external network port, and complete the reception and transmission of network messages. The receiving module of the MAC layer receives network data packets, filters out the messages with CRC errors, and stores the valid data packets in the receiving cache, waiting for the receiving service control to read. The MAC sending module detects whether there is data in the sending cache in real time, and sends the forwarding message in the sending cache. The receiving service control queries the receiving cache of the MAC layer, reads a complete frame of the receiving cache at a time, and records which port the message comes from, and encapsulates it into the receiving message as the source port number for MAC address table learning. The receiving service control needs to schedule the 5 receiving caches of 5 MACs, read the receiving network data packets of each queue in turn, and process one frame of receiving message before processing and transferring to the next cache. The data processing unit is the core module of network switching. It needs to parse the message, parse out the destination MAC address, source MAC address and source port number of the message, and pass it to the MAC address learning module. The source MAC address and source port number are given to the MAC address table module for MAC address learning. The destination MAC address is used to look up the MAC address table to output the destination port number to be forwarded by the message, and the destination port number is encapsulated into the message and passed to the first-level cache unit. The MAC address table module has two main functions: storing the MAC address table and processing Ethernet Layer 2 switching. The MAC address table is provided by the internal RAM of the FPGA. Storage and reading are completed inside the FPGA. The information of each MAC is stored in the MAC address table in the format of a MAC address table entry. The content of the MAC address table entry includes the valid bit of the table entry, the aging counter, the MAC physical address and the port number. The MAC address table module receives the source MAC address and source port number transmitted by the data processing unit, and uses the hash value of the source MAC address as an index to store it in the storage MAC address table for maintaining the MAC address table update; at the same time, based on the hash value of the destination MAC address transmitted by the data processing unit as an index, it searches for the destination port number to be forwarded and output, thereby realizing Ethernet Layer 2 switching services.
[0061] The first-level cache unit caches the messages that have completed the exchange search output by the data processing unit. The first-level cache configuration size of 8KB is provided by the internal RAM of FPGA. The output of the first-level cache unit has two paths, namely the second-level cache unit and the MAC send cache. The first-level cache unit must first determine whether the sending port of the current message has occupied the second-level cache unit. If the current port has occupied the second-level cache unit, the message is directly written to the second-level cache unit, otherwise it is directly written to the send cache area. The second-level cache unit can be dynamically allocated to a certain port to solve the problem of burst message buffering. When multiple network ports forward messages to the same network port in the same time period, the send cache area of the current network port may be full. At this time, the current network port can apply to use the second-level cache unit. The second-level cache configuration size of 32K is provided by the internal RAM of FPGA. The second-level cache can only be used by one network port at the same time. Only after the current network port cache message is sent and released can it be applied for by the next port. The sending service control receives data from the first-level cache unit and the second-level cache unit, and writes the message to the corresponding port send cache according to the destination port number. The sending service control monitors the send cache status of each port in real time and feeds it back to the first-level cache unit. When the L2 cache is in the idle state, the sending service control will read the message from the L1 cache unit and write it into the corresponding port sending buffer area; when the L2 cache is in the working state, in addition to reading the L1 cache, when the sending buffer of the port occupying the L2 cache is not full, the sending service control will read the forwarding message from the L2 cache unit.
[0062] According to another embodiment of the present invention, a data exchange device based on dynamic allocation of FPGA memory is provided, comprising a message receiving module, a message storage module, and a message processing module; wherein,
[0063] The message receiving module is used to receive Ethernet messages, parse out the forwarding destination port and encapsulate it into the forwarding message;
[0064] The message storage module is used to store the forwarded message in a first-level cache unit;
[0065] The message processing module is used to determine the occupancy of the secondary cache unit and process the forwarded message according to the determination result.
[0066] The specific manner in which the device implements various functions is the same as that of the first embodiment of the present invention, and will not be described in detail here.
[0067] In summary, the present invention relates to a data exchange method and device based on FPGA memory dynamic allocation, which uses field programmable FPGA devices to implement Ethernet layer 2 switching processing services and adopts a memory dynamic allocation strategy, that is, using FPGA internal RAM to implement a first-level cache unit and a second-level cache unit as a forwarding message cache, the first-level cache unit caches the Ethernet message after the second-level switching process, and the second-level cache unit is dynamically allocated to a port with message burst transmission. Generally, only the first-level cache unit is used as a forwarding message cache. When the instantaneous flow of a certain port is too large, the second-level cache unit is applied to occupy the second-level cache unit. After the message is sent, the second-level cache unit is released. The second-level cache unit is dynamically allocated to the port with large instantaneous flow, and the internal cache of the FPGA is used reasonably and efficiently, eliminating the SDRAM that needs to be mounted in the conventional message cache strategy. The present invention solves the message cache problem of the cascade port by adopting a memory dynamic allocation strategy, wherein the cache is only implemented using the internal RAM of the FPGA, reducing the hardware cost and implementation complexity.
[0068] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0069] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0070] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0071] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0072] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit its protection scope. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the field should understand that after reading the present invention, those skilled in the art can still make various changes, modifications or equivalent substitutions to the specific implementation methods of the invention, but these changes, modifications or equivalent substitutions are all within the protection scope of the pending claims of the invention.
Claims
1. A data exchange method based on dynamic allocation of FPGA memory, characterized in that: Includes steps: S1, receiving Ethernet messages, parsing the forwarding destination port and encapsulating it into the forwarding message; S2, storing the forwarded message in a first-level cache unit; S3, judging the occupancy of the secondary cache unit, and processing the forwarded message according to the judgment result, including: S31, query whether the destination port occupies the secondary cache unit, if so, jump to step S36; If not, execute step S34; S34, determining whether the sending buffer of the destination port is full, if so, executing step S35; if not, jumping to step S38; S35, determine whether the secondary cache unit is idle, if so, execute step S36; if not, the message data overflows; S36, storing the forwarded message in a secondary cache unit; S37, when the secondary cache unit is not empty, wait until there is space in the send cache of the destination port; S38: Write the message data into the sending buffer of the destination port and send it.
2. The method according to claim 1, characterized in that The first-level cache unit and the second-level cache unit are both provided by FPGA memory.
3. The method according to claim 2, characterized in that The secondary cache unit may be allocated dynamically.
4. The method according to claim 3, characterized in that: Also includes: If the secondary cache unit is not empty, the space of the secondary cache unit is released.
5. A data exchange device based on FPGA memory dynamic allocation, characterized in that: It includes a message receiving module, a message storage module, and a message processing module; wherein, The message receiving module is used to receive Ethernet messages, parse out the forwarding destination port and encapsulate it into the forwarding message; The message storage module is used to store the forwarded message in a first-level cache unit; The message processing module is used to determine the occupancy of the secondary cache unit and process the forwarded message according to the determination result, including: S31, query whether the destination port occupies the secondary cache unit, if so, jump to step S36; if not, execute step S34; S34, determining whether the sending buffer of the destination port is full, if so, executing step S35; if not, jumping to step S38; S35, determine whether the secondary cache unit is idle, if so, execute step S36; if not, the message data overflows; S36, storing the forwarded message in a secondary cache unit; S37, when the secondary cache unit is not empty, wait until there is space in the send cache of the destination port; S38: Write the message data into the sending buffer of the destination port and send it.
6. The device according to claim 5, characterized in that The first-level cache unit and the second-level cache unit are both provided by FPGA memory.
7. The device according to claim 6, characterized in that The secondary cache unit may be allocated dynamically.
8. The device according to claim 7, characterized in that The message processing module is further configured to release the space of the secondary cache unit if the secondary cache unit is not empty.
