Data packet sorting method based on random memory in FPGA chip

By sorting data packets using feature fields in the on-chip random access memory of the FPGA, the problem of high time complexity of existing sorting algorithms is solved, and faster data packet sorting and system response are achieved.

CN117591033BActive Publication Date: 2026-11-24UNIV OF SCI & TECH OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311706942.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-12
Publication Date
2026-11-24
Estimated Expiration
2043-12-12

AI Technical Summary

Technical Problem

Existing sorting algorithms have high time complexity, especially at the O(n²) and O(n×log₂n) level, resulting in slow system response speed.

Method used

By utilizing the on-chip random access memory of the FPGA, data packets are written to the address of the random access memory through a feature field, and the valid address status is marked by an index register to achieve data packet sorting.

Benefits of technology

It reduces the time complexity of packet sorting, improves the system's response speed, and dynamically modifies the state of the valid address in the index register of the random access memory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117591033B_ABST
    Figure CN117591033B_ABST
Patent Text Reader

Abstract

This disclosure provides a data packet sorting method based on on-chip random access memory (RAM) of an FPGA. The FPGA integrates RAM and the data packet sorting method includes: acquiring multiple data packets from an external source; writing the multiple data packets into multiple addresses of the RAM according to feature fields, where the feature fields are used as the sorting criteria for the data packets; using the addresses where the data packets are written as valid addresses and marking the state of each address of the RAM using the index register of the FPGA; and using the FPGA to read the data packets corresponding to the valid addresses and update the state of the read valid addresses in the index register to achieve sorting of the multiple data packets.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of memory technology, and more specifically, to a data packet sorting method based on FPGA on-chip random access memory. Background Technology

[0002] Sorting algorithms are one of the fundamental algorithms in electronic information technology. Time complexity is a key indicator for evaluating the efficiency of an algorithm and plays an important role in processing large-scale data.

[0003] Currently, sorting algorithms include, for example, bubble sort, insertion sort, and selection sort. The time complexity of these sorting algorithms is O(n^2). 2 For example, merge sort, quick sort, and heap sort are sorting algorithms with a time complexity of O(n×log₂n). Although they are diverse, their basic idea is to compare elements and perform serial loop recursion, thus resulting in a high time complexity, generally remaining at O(n×log₂n). 2 The time complexity is either O(n×log2n), so there is an urgent need to develop a data packet sorting method to reduce the time complexity and improve the system's response speed. Summary of the Invention

[0004] To address at least one of the technical problems in the prior art, this disclosure provides a data packet sorting method based on FPGA on-chip random access memory, which can reduce the time complexity of data packet sorting and dynamically modify the state of the valid address in the random access memory corresponding to the index register.

[0005] This disclosure provides a data packet sorting method based on on-chip random access memory (RAM) of an FPGA. The FPGA integrates RAM, and the data packet sorting method includes: acquiring multiple data packets from an external source; writing the multiple data packets into multiple addresses of the RAM according to feature fields of the multiple data packets, wherein the feature fields are used as sorting criteria for the data packets; using the addresses where the data packets are written as valid addresses, marking the state of each address of the RAM using an index register of the FPGA; reading the data packets corresponding to the valid addresses using the FPGA, and updating the state of the read valid addresses in the index register, thereby sorting the multiple data packets.

[0006] According to some embodiments of this disclosure, the data packet includes multiple fields, and any one of the multiple fields is selected as the feature field, while the fields other than the feature field are used as other fields.

[0007] According to some embodiments of this disclosure, writing multiple data packets to multiple addresses of the random access memory based on the feature fields of the multiple data packets includes: converting the multiple feature fields into addresses of the random access memory based on the conversion relationship between the feature fields and addresses in the random access memory; and storing the other fields of each of the multiple data packets at the addresses in the random access memory corresponding to the feature fields.

[0008] According to some embodiments of this disclosure, the above-described conversion of feature fields of multiple data packets to addresses of the random access memory based on the conversion relationship between the feature fields and addresses in the random access memory includes: mapping the smallest feature field among the feature fields of the multiple data packets to the first address of the random access memory; and mapping the largest feature field among the feature fields of the multiple data packets to the last address of the random access memory.

[0009] According to some embodiments of this disclosure, the index register includes i bits, each bit corresponding to an address of the random access memory.

[0010] According to some embodiments of this disclosure, the above-mentioned use of the address to write the data packet as a valid address and the use of the index register of the FPGA to mark the state of each address of the random access memory includes: when the address of the random access memory is a valid address, the bit corresponding to the valid address in the index register is marked as 1; when the address not written to the data packet is a invalid address, when the address of the random access memory is an invalid address, the bit corresponding to the invalid address in the index register is marked as 0.

[0011] According to some embodiments of this disclosure, the above-mentioned method of using the FPGA to read the data packet corresponding to the valid address and updating the state of the read valid address in the index register to sort multiple data packets includes: when the i-th bit is determined to be 1, using the FPGA to read the data packet corresponding to the address of the i-th bit in the random access memory; and when the i-th bit has been read, setting the i-th bit to zero in the index register.

[0012] According to some embodiments of this disclosure, after the i-th bit has been read, setting the i-th bit to zero in the index register includes: using the FPGA to read the data packet at the address corresponding to the next bit in the index register when the next bit is 1 in the random access memory.

[0013] According to some embodiments of this disclosure, the above-mentioned method of using the FPGA to read the data packets corresponding to the valid addresses and updating the state of the read valid addresses in the index register to sort the multiple data packets further includes: using the FPGA to read the data packets corresponding to all valid addresses on the random access memory and updating the state of each read valid address in the index register.

[0014] According to an embodiment of this disclosure, a data packet sorting method based on FPGA on-chip random access memory (RAM) first obtains multiple data packets from an external source. Based on the characteristic fields of the multiple data packets, the multiple data packets are written to multiple addresses in the RAM. The characteristic fields serve as the sorting criteria for the data packets, and the addresses where the data packets are written are designated as valid addresses. The state of each address in the RAM is marked using the index register of the FPGA. The data packets corresponding to the valid addresses are read using the FPGA, and the state of the read valid addresses in the index register is updated to achieve sorting of multiple data packets. This method can reduce the time complexity of data packet sorting, improve the system response speed, and dynamically modify the state of the valid addresses in the RAM corresponding to the index register. Attached Figure Description

[0015] Figure 1 This is a flowchart illustrating an illustrative embodiment of a data packet sorting method based on FPGA on-chip random access memory;

[0016] Figure 2 This is a schematic diagram illustrating the conversion of multiple feature fields into addresses of random access memory according to an illustrative embodiment of the present disclosure;

[0017] Figure 3 This is a schematic diagram illustrating the use of an index register of an FPGA to mark the state of each address of a random access memory according to an illustrative embodiment of this disclosure; and

[0018] Figure 4 This is a signal simulation diagram of a data packet sorting method based on FPGA on-chip random access memory according to an illustrative embodiment of the present disclosure. Detailed Implementation

[0019] The embodiments of the present disclosure will now be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the disclosure. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the present disclosure for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concepts of the present disclosure.

[0020] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit this disclosure. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0021] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.

[0022] When using expressions such as "at least one of A, B, and C," the expression should generally be interpreted in accordance with the meaning commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, and C" should include, but is not limited to, systems having A alone, having B alone, having C alone, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.). Similarly, when using expressions such as "at least one of A, B, or C," the expression should generally be interpreted in accordance with the meaning commonly understood by a person skilled in the art (e.g., "a system having at least one of A, B, or C" should include, but is not limited to, systems having A alone, having B alone, having C alone, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.).

[0023] Sorting algorithms include, for example, bubble sort, insertion sort, and selection sort. The time complexity of these sorting algorithms is O(n^2). 2 Taking the bubble sort algorithm as an example, bubble sort is a basic sorting algorithm. Its core idea is to repeatedly traverse the sequence to be sorted, compare adjacent elements, and gradually swap larger elements to their correct positions. In each round of traversal, by comparing two adjacent elements in turn, the larger element is moved towards the end of the sequence until the entire sequence is sorted. The disadvantage of the bubble sort algorithm is its high time complexity, which is O(n^2). 2For example, merge sort, quick sort, and heap sort have a time complexity of O(n×log₂n). Taking quick sort as an example, quick sort is a representative of advanced sorting algorithms. Its core idea is to select a pivot element and divide the sequence into two subsequences: the left subsequence contains elements smaller than the pivot, and the right subsequence contains elements larger than the pivot. This process is recursively repeated on the subsequences until the entire sequence is sorted. The key to this algorithm is to quickly determine the final position of each element through a rapid partitioning process, thus achieving the effect of quick sorting. Its average time complexity is O(n×log₂n). Although there are various types of sorting algorithms, the basic idea is to compare elements and use serial recursion, resulting in a relatively high time complexity, generally around O(n×log₂n). 2 Or O(n×log2n).

[0024] To address the issue of reducing the time complexity of data packet sorting, according to one aspect of the present disclosure, multiple data packets are first acquired from an external source. Based on the characteristic fields of these data packets, they are written to multiple addresses in a random access memory (RAM). The characteristic fields serve as the sorting criteria for the data packets, and the addresses where the data packets are written are designated as valid addresses. The state of each address in the RAM is marked using an index register of an FPGA. The FPGA then reads the data packets corresponding to the valid addresses and updates the state of the read valid addresses in the index register, thereby achieving the sorting of multiple data packets. This reduces the time complexity of data packet sorting, improves the system's response speed, and dynamically modifies the state of the valid addresses in the RAM corresponding to the index register.

[0025] Figure 1 This is a flowchart of a data packet sorting method based on FPGA on-chip random access memory according to an illustrative embodiment of the present disclosure.

[0026] According to embodiments of this disclosure, such as Figure 1 As shown, a data packet sorting method based on FPGA on-chip random access memory includes the following steps S1-S4.

[0027] Step S1: Obtain multiple data packets from external sources.

[0028] According to embodiments of this disclosure, the source of data packets varies under different conditions. Taking a physical experiment as an example, the data packets are generated by a data acquisition system.

[0029] According to embodiments of this disclosure, field-programmable gate arrays (FPGAs) have advantages such as good real-time performance and hardware reconfigurability.

[0030] According to embodiments of this disclosure, FPGA on-chip random access memory (RAM) is a low-level hardware resource of the FPGA, and it has the following two characteristics: First, the addresses of FPGA on-chip RAM are both discrete and ordered, similar to an ordered queue of discrete data. Second, unlike off-chip DDR memory and external non-volatile memory, on-chip RAM is integrated inside the FPGA, thus supporting direct random read / write operations by the FPGA without complex timing overhead. Therefore, FPGA on-chip RAM offers superior real-time performance, and its read / write process does not obstruct data flow.

[0031] Step S2: Write multiple data packets to multiple addresses in random access memory based on their characteristic fields. The characteristic fields are used as the sorting criteria for the data packets.

[0032] According to embodiments of this disclosure, an ordered queue is naturally formed during the process of writing multiple data packets to multiple addresses of a random access memory.

[0033] Step S3: Use the address of the data packet to be written as the valid address, and use the FPGA's index register to mark the state of each address in the random access memory.

[0034] Step S4: Use the FPGA to read the data packets corresponding to the valid addresses and update the status of the read valid addresses in the index register to sort multiple data packets.

[0035] According to embodiments of this disclosure, the on-chip random access memory of the FPGA is used as the medium for sorting data packets. The complete sorting of data packets includes not only the process of writing data packets into the random access memory to form an ordered queue, but also the process of reading the corresponding data packets from the valid address in the random access memory.

[0036] According to embodiments of this disclosure, the data packet sorting method based on FPGA on-chip random access memory is suitable for sorting data streams that are generally ordered but locally disordered. In this scenario, the data stream is generally ordered, and therefore not very dispersed, allowing it to be processed in stages. Furthermore, the amount of data processed each time is small, and all of it can be stored in the random access memory. For example, in nuclear and particle physics experiments, the data stream is formed according to the order of physical time occurrence, further compounded by factors such as transmission delays in each channel, thus exhibiting a generally ordered but locally disordered characteristic in time.

[0037] According to embodiments of this disclosure, multiple data packets are first acquired from an external source. Based on the characteristic fields of the multiple data packets, the multiple data packets are written to multiple addresses in a random access memory (RAM). The characteristic fields serve as the sorting criteria for the data packets, and the addresses where the data packets are written are taken as valid addresses. The state of each address in the RAM is marked using the index register of the FPGA. The data packets corresponding to the valid addresses are read using the FPGA, and the state of the read valid addresses in the index register is updated to achieve sorting of multiple data packets. This reduces the time complexity of data packet sorting, improves the system's response speed, and dynamically modifies the state of the valid addresses in the RAM corresponding to the index register.

[0038] According to embodiments of this disclosure, the data packet includes multiple fields, including timestamp, amplitude information, and channel number information. Any one of the multiple fields is selected as a feature field, and the fields other than the feature field are used as other fields.

[0039] According to embodiments of this disclosure, data packets typically consist of several fields, where the field used as the sorting criterion is a feature field, and the fields other than the feature field are designated as other fields. For example, in physics experiments, data packets recorded by a data acquisition system consist of fields such as channel number information, amplitude information, and timestamp. In scenarios such as real-time particle track reconstruction, data packets need to be sorted according to timestamps, where the timestamp is the feature field, and the channel number information, amplitude information, etc., are designated as other fields.

[0040] According to embodiments of this disclosure, writing multiple data packets to multiple addresses in random access memory based on their characteristic fields includes: converting the multiple characteristic fields into addresses in random access memory based on the conversion relationship between the characteristic fields and addresses in random access memory; and storing other fields of each of the multiple data packets in random access memory at the addresses corresponding to the characteristic fields.

[0041] Figure 2 This is a schematic diagram illustrating the conversion of multiple feature fields into addresses of random access memory according to an illustrative embodiment of the present disclosure.

[0042] According to embodiments of this disclosure, such as Figure 2 As shown, with Figure 2Taking the data packet samples as an example, the feature field sizes of data packets 1, 2, and 3 are 0x07, 0x05, and 0x10, respectively. The conversion relationship between feature fields and random access memory (RAM) addresses can be defined by the user. In one illustrative embodiment, the feature fields of the data packets can be directly mapped to RAM addresses. In another illustrative embodiment, the high-order bits of the feature fields can be mapped to RAM addresses. In yet another illustrative embodiment, the logarithm of the feature fields can be taken and then mapped to RAM addresses. The other fields of each of the multiple data packets are stored in RAM at the addresses corresponding to the feature fields.

[0043] According to embodiments of this disclosure, multiple data packets are written to multiple addresses of random access memory based on their characteristic fields. During the process of writing to multiple addresses of random access memory, the data packets can be sorted naturally. For each data packet, the data packet sorting method based on FPGA on-chip random access memory can complete the sorting in just one clock cycle, with a time complexity of O(n).

[0044] According to embodiments of this disclosure, converting the feature fields of multiple data packets into addresses in random access memory (RAM) based on the conversion relationship between feature fields and addresses in RAM includes: mapping the smallest feature field among the feature fields of the multiple data packets to the starting address of RAM; and mapping the largest feature field among the feature fields of the multiple data packets to the ending address of RAM.

[0045] According to embodiments of this disclosure, the smallest feature field (such as...) among the feature fields of multiple data packets is... Figure 2 The feature field 0x05 shown is mapped to the starting address of random access memory, and the largest feature field (e.g., ...) among the feature fields of multiple data packets is mapped to the starting address of random access memory. Figure 2 The feature field 0xMN shown is mapped to the tail address of random access memory, which enables full utilization of the address depth of random access memory.

[0046] According to embodiments of this disclosure, the difference between the maximum and minimum feature fields is no greater than the depth of the random access memory address.

[0047] According to embodiments of this disclosure, the maximum depth of the FPGA's on-chip random access memory is 10. 6 The data dispersion of the random access memory is no greater than the maximum depth of the random access memory, that is, the difference between the largest and smallest feature fields is no greater than the depth of the address of the random access memory, which can make full use of the depth of the address of the random access memory.

[0048] According to embodiments of this disclosure, the index register includes i bits, each bit corresponding to an address of a random access memory.

[0049] According to embodiments of this disclosure, the index register includes i bits, that is, the index register is composed of register units within the FPGA, and its length is equal to the depth of the random access memory. Each bit of the index register corresponds to each address of the random access memory.

[0050] According to embodiments of this disclosure, the address where a data packet is written is used as a valid address, and the state of each address in the random access memory (RAM) is marked using the FPGA's index register: when the RAM address is a valid address, the bit corresponding to the valid address in the index register is marked as 1. Addresses where no data packet is written are used as invalid addresses, and when the RAM address is an invalid address, the bit corresponding to the invalid address in the index register is marked as 0.

[0051] According to embodiments of this disclosure, the feature fields of the data packets may not be contiguous, while the addresses of the FPGA's on-chip random access memory (RAM) are contiguous. After the conversion between the feature fields and the RAM addresses, some addresses in the FPGA's on-chip RAM will inevitably be unwritten into the data packets, i.e., invalid addresses.

[0052] Figure 3 This is a schematic diagram illustrating the use of an index register of an FPGA to mark the state of each address of a random access memory according to an illustrative embodiment of the present disclosure.

[0053] According to embodiments of this disclosure, such as Figure 3 As shown, the address written to the data packet is taken as the valid address, and the corresponding bit in the index register is marked as 1. The address not written to the data packet is taken as the invalid address, and the corresponding bit in the index register is marked as 0. This enables real-time marking of each address in the random access memory.

[0054] According to embodiments of this disclosure, such as Figure 3 As shown, the sorting of multiple data packets is achieved by using an FPGA to read the data packets corresponding to valid addresses and updating the state of the read valid addresses in the index register. This includes: when the i-th bit is determined to be 1, using the FPGA to read the data packet corresponding to the address of the i-th bit in the random access memory. If the i-th bit has already been read, the i-th bit is set to zero in the index register.

[0055] According to embodiments of this disclosure, the location of a bit set to 1 can be determined using a priority-based multi-branch selection (casex) statement. Only one clock cycle is needed to locate the first non-zero bit in the index register, which points to the first valid address in the random access memory. The data packet at the first valid address is then read using the FPGA. Figure 3The valid data packets in the random access memory are used for subsequent processing. Simultaneously, setting the bits in the index register corresponding to the first valid address to zero allows for dynamic modification of the state of the valid address in the index register within the random access memory.

[0056] According to embodiments of this disclosure, by using an FPGA to read data packets at the corresponding address in the random access memory when the bit is 1, and skipping invalid addresses, the efficiency of data processing can be improved.

[0057] According to an embodiment of this disclosure, after the i-th bit has been read, setting the i-th bit to zero in the index register includes: using the FPGA to read the data packet at the address corresponding to the next bit in the index register when the next bit is 1 in the random access memory.

[0058] According to the embodiments of this disclosure, after the i-th bit has been read, the i-th bit is set to zero in the index register, and the data packet corresponding to the address in the random access memory when the next bit in the index register is 1 is read by the FPGA. This enables tracking the next valid address in the current random access memory within one clock cycle and skipping invalid addresses. This eliminates the problem of invalid addresses caused by the conversion relationship between feature fields and addresses in the random access memory, and improves the efficiency of FPGA reading random access memory.

[0059] According to embodiments of this disclosure, the sorting of multiple data packets by using an FPGA to read data packets corresponding to valid addresses and updating the state of each read valid address in the index register further includes: using an FPGA to read data packets corresponding to all valid addresses in the random access memory and updating the state of each read valid address in the index register.

[0060] According to embodiments of this disclosure, an FPGA is used to read data packets corresponding to all valid addresses in a random access memory, while simultaneously traversing the entire index register and updating the state of each read valid address in the index register until all bits in the index register are dynamically set to zero.

[0061] Figure 4 This is a signal simulation diagram of a data packet sorting method based on FPGA on-chip random access memory according to an illustrative embodiment of the present disclosure.

[0062] According to embodiments of this disclosure, such as Figure 4 As shown, 1214, 1049, 1552, and 1456 represent multiple extracted feature fields, and 73, 123, 94, and 88 represent other fields in the data packet corresponding to these feature fields. If the timestamp is used as the sorting criterion for the data packets, then... Figure 4The key feature field in the data packet is the timestamp, while other fields include amplitude information, channel number information, etc. The data packet's key feature field is directly mapped to a random access memory (RAM) address. Based on this mapping, the FPGA writes the input streaming data into the RAM. Although the data packets themselves are unordered according to clock sequence, such as... Figure 4 The unordered data packets in the memory are 1214, 1049, 1552, and 1456. When writing to random access memory (RAM), the data packet corresponding to 1214 is written to RAM first, then the data packet corresponding to 1049, then the data packet corresponding to 1552, and finally the data packet corresponding to 1456, following clock order. After writing to RAM, an ordered queue is automatically formed. When data packets are read from RAM, they are read one by one according to their addresses (i.e., feature fields), that is, the data packet content corresponding to these addresses is read one by one, i.e., 1049, 1214, 1456, and 1552. Therefore, the read data packets become ordered. During the process of writing data packets to RAM, the index register is automatically maintained; that is, the bit of the index register corresponding to the address of each data packet written to RAM is set to 1. During the process of reading data packets from RAM, the index register can skip invalid addresses of RAM that are empty. Figure 4 Simulation results show that this disclosure uses the on-chip random access memory of the FPGA as a medium to transform complex sorting operations into simple read and write operations of the random access memory. Each data packet only requires one clock cycle to complete the sorting, thus the time complexity is only O(n).

[0063] According to embodiments of this disclosure, the packet sorting method based on FPGA on-chip random access memory can be widely applied in the fields of data acquisition, data communication, and other technical fields.

[0064] It should also be noted that the directional terms mentioned in the embodiments, such as "up," "down," "front," "back," "left," and "right," are only for reference to the directions in the accompanying drawings and are not intended to limit the scope of protection of this disclosure. Throughout the drawings, the same elements are represented by the same or similar reference numerals. Conventional structures or constructions will be omitted where they may cause confusion in understanding this disclosure, and the shapes and dimensions of the components in the drawings do not reflect actual size and proportion, but are only schematic representations of the embodiments of this disclosure.

[0065] Unless otherwise stated, the numerical parameters in this specification and the appended claims are approximate values ​​and can be varied according to desired characteristics derived from the content of this disclosure. Specifically, all figures used in the specification and claims to indicate composition, reaction conditions, etc., should be understood to be modified by the term "about" in all cases. Generally, this means that a specific amount varies by ±10% in some embodiments, ±5% in some embodiments, ±1% in some embodiments, and ±0.5% in some embodiments.

[0066] The use of ordinal numbers such as "first," "second," "third," etc., in the specification and claims to modify the corresponding elements does not imply that the element has any ordinal number, nor does it represent the order of one element with another element, or the order of manufacturing methods. The use of these ordinal numbers is only to enable a named element to be clearly distinguished from another element with the same name.

[0067] Furthermore, unless specifically described or required to occur in a specific order, the order of the above steps is not limited to those listed above and can be varied or rearranged according to the desired design. Moreover, the above embodiments can be used in combination with each other or with other embodiments based on design and reliability considerations; that is, technical features from different embodiments can be freely combined to form more embodiments.

[0068] The embodiments of this disclosure have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of this disclosure. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. The scope of this disclosure is defined by the appended claims and their equivalents. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of this disclosure, and all such substitutions and modifications should fall within the scope of this disclosure.

Claims

1. A data packet sorting method based on FPGA on-chip random access memory, wherein, The FPGA integrates a random access memory, and the data packet sorting method includes: Retrieve multiple data packets from external sources; Based on the characteristic fields of the multiple data packets, the multiple data packets are written to multiple addresses of the random access memory, and the characteristic fields are used as the sorting criteria for the data packets; The address written to the data packet is used as the valid address, and the state of each address in the random access memory is marked using the index register of the FPGA; The FPGA is used to read the data packets corresponding to the valid addresses, and the status of the read valid addresses in the index register is updated to sort the multiple data packets. The data packet includes multiple fields. Any one of the multiple fields is selected as the feature field, and the fields other than the feature field are used as other fields. The step of writing multiple data packets to multiple addresses of the random access memory based on the feature fields of the multiple data packets includes: Based on the conversion relationship between the characteristic fields and the addresses in the random access memory, multiple characteristic fields are converted into addresses in the random access memory; The other fields of each of the multiple data packets are stored in the random access memory at the address corresponding to the feature field; The step of converting the feature fields of multiple data packets into addresses of the random access memory based on the conversion relationship between the feature fields and addresses in the random access memory includes: Map the smallest feature field among the feature fields of the multiple data packets to the starting address of the random access memory; The largest feature field among the feature fields of the multiple data packets is mapped to the tail address of the random access memory.

2. The data packet sorting method based on FPGA on-chip random access memory according to claim 1, wherein, The index register includes i bits, each bit corresponding to an address of the random access memory.

3. The data packet sorting method based on FPGA on-chip random access memory according to claim 2, wherein, The step of using the address written to the data packet as a valid address and marking the state of each address in the random access memory using the index register of the FPGA includes: When the address of the random access memory is the valid address, the bit corresponding to the valid address in the index register is marked as 1; The address that is not written to the data packet is treated as an invalid address. If the address in the random access memory is the invalid address, the bit corresponding to the invalid address in the index register is marked as 0.

4. The data packet sorting method based on FPGA on-chip random access memory according to claim 3, wherein, The step of using the FPGA to read the data packet corresponding to the valid address and updating the state of the read valid address in the index register to sort the multiple data packets includes: If the i-th bit is determined to be 1, the FPGA is used to read the data packet corresponding to the address of the i-th bit in the random access memory; If the i-th bit has been read, set the i-th bit to zero in the index register.

5. The data packet sorting method based on FPGA on-chip random access memory according to claim 4, wherein, The step of setting the i-th bit to zero in the index register after the i-th bit has been read includes: The FPGA is used to read the data packet at the address corresponding to the next bit in the index register when the next bit is 1.

6. The data packet sorting method based on FPGA on-chip random access memory according to claim 5, wherein, The step of using the FPGA to read the data packet corresponding to the valid address and updating the state of the read valid address in the index register to sort the multiple data packets further includes: The FPGA is used to read the data packets corresponding to all valid addresses in the random access memory, and the status of each read valid address in the index register is updated.

Citation Information

Patent Citations

  • DRAM fragment management method and device

    CN109828931A

  • Network data processing method and system

    CN114449046A