FPGA-based pointer updating method and device
By using the dynamic update mechanism of pointer pool and dynamic pointer chain in FPGA design, the problem of pointer loss and failure to be recycled is solved, the usage of RAM is improved, and the system is prevented from being stuck.
Patent Information
- Application Number
- CN202411131060.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-08-16
AI Technical Summary
In FPGA design, the problem of pointer loss and failure to recycle effectively leads to reduced RAM usage and may even lead to system jamming.
Using the FPGA-based pointer update method, by setting the pointer pool and dynamic pointer chain, the tail pointer in the dynamic pointer chain moves within the preset time interval to update, responding to pointer requests and recycling instructions, ensuring that the pointer in the pointer pool can be effectively updated. and replace.
It effectively solves the problem that pointer cannot be recycled after it is lost, improves the resource utilization rate of memory, and prevents the system from getting stuck.
Smart Images

Figure CN119045736A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a pointer updating method, device, network equipment and computer-readable storage medium based on FPGA. Background Art
[0002] Field-Programmable Gate Array (FPGA) chip is a commonly used digital communication baseband chip. In the FPGA design process, pointers are usually used to improve the utilization rate of FPGA's resource RAM (Random-Access Memory).
[0003] In the related technical solution, a pointer pool is set, and the initial number of pointers in the pointer pool is m. When the FPGA writes data to the RAM, a pointer value is taken out from the pointer pool, and the write address of the RAM is obtained based on the pointer value to complete the write data operation of the RAM. When the FPGA completes reading data from the RAM, the pointer recovery operation is performed, and the corresponding read address is pushed back into the pointer pool. In the actual use process, the pointer is lost and the pointer is not effectively recovered. For example, when a certain service is deleted, the data in the RAM address corresponding to the service has not been needed to be used, that is, the data will not be read out later, resulting in the RAM address being occupied all the time, so that the pointer cannot be recovered, or when the FPGA executes the read RAM command, the read command is lost due to some bugs, resulting in the inability to read the corresponding data, resulting in the pointer cannot be recovered, or the RAM data is read, but the pointer is not pushed back into the pointer pool due to some program bugs, resulting in the loss of the pointer. In the above situation, the pointer is lost, so that the pointer cannot be effectively recovered, thereby reducing the utilization rate of the RAM, and may even cause all the pointers in the pointer pool to be lost, resulting in the entire system design being stuck. Summary of the invention
[0004] The purpose of this application is to provide a pointer updating method based on FPGA, which can effectively recycle pointers and improve the utilization rate of memory.
[0005] Based on the above purpose, the present application provides a pointer updating method based on FPGA, the method comprising:
[0006] Set a pointer pool, the pointers in the pointer pool point to the addresses of the memory;
[0007] A dynamic pointer chain is set, the dynamic pointer chain includes a head pointer and a tail pointer, the head pointer and the tail pointer are continuous pointers, the tail pointer is a moving pointer, the tail pointer is moved based on a preset time interval to update the dynamic pointer chain, and the pointers in the dynamic pointer chain point to the addresses of the memory;
[0008] In response to a new pointer request instruction, determine whether there is an idle pointer in the pointer pool, if yes, output an idle pointer as a new pointer; if no, use the head pointer in the dynamic pointer chain as the new pointer, and increase the head pointer by 1;
[0009] In response to a pointer recycling instruction, it is determined whether the recycled pointer is in the dynamic pointer chain. If so, the recycled pointer is discarded, otherwise the recycled pointer is pushed into the pointer pool.
[0010] Furthermore, the number of addresses in the memory is m, the initial value of the number of pointers in the dynamic pointer chain is n, the number of pointers in the pointer pool is mn, the pointers in the pointer pool are 0 to mn-1, where n is less than or equal to m, the head pointer of the dynamic pointer chain is mn, and the tail pointer of the dynamic pointer chain is m-1.
[0011] Further, when n is less than m, after the system is powered on, the dynamic pointer chain is dynamically adjusted, and the steps of the dynamic adjustment include:
[0012] In the first clock cycle, the tail pointer is incremented by 1 and becomes 0;
[0013] Every x clock cycles, the tail pointer is incremented from 0 to 1 until the tail pointer is mn-1.
[0014] Further, in response to a new pointer request instruction, the method includes:
[0015] In response to a write data instruction of the memory, output a new pointer request instruction;
[0016] After obtaining the new pointer, the memory write operation is performed using the new pointer.
[0017] Further, in response to a pointer recovery instruction, the method includes:
[0018] In response to a data read instruction of the memory, performing a read operation on the memory;
[0019] When the read operation is completed, a pointer recovery instruction is output, and the pointer recovery instruction includes the read address of the read operation.
[0020] Furthermore, the method also includes:
[0021] At each preset first clock cycle, it is determined whether the tail pointer in the dynamic pointer chain is incremented by 1. The determination steps are as follows:
[0022] If the tail pointer is less than the head pointer, the tail pointer is increased by 1, otherwise the tail pointer remains unchanged.
[0023] Furthermore, the method also includes:
[0024] A new pointer request instruction is output every second preset clock cycle, and the first clock cycle is greater than the second clock cycle.
[0025] Based on the above purpose, the present application provides a pointer updating device based on FPGA, which includes:
[0026] The storage module is used to set a pointer pool, wherein the pointers in the pointer pool point to the addresses of the storage;
[0027] A dynamic pointer module is used to set a dynamic pointer chain, the dynamic pointer chain includes a head pointer and a tail pointer, the head pointer and the tail pointer are continuous pointers, the tail pointer is a moving pointer, the tail pointer is moved based on a preset time interval to update the dynamic pointer chain, and the pointers in the dynamic pointer chain point to the addresses of the memory;
[0028] The update module is used to respond to a new pointer request instruction, determine whether there is an idle pointer in the pointer pool, if yes, output an idle pointer as a new pointer; if no, use the head pointer in the dynamic pointer chain as the new pointer, and increase the head pointer by 1;
[0029] The recycling module is used to respond to a pointer recycling instruction, determine whether the recycled pointer is in the dynamic pointer chain, if so, discard the recycled pointer, otherwise push the recycled pointer into the pointer pool.
[0030] Based on the above purpose, the present application provides a network device, including the FPGA-based pointer updating device as described above.
[0031] Based on the above purpose, the present application provides a computer-readable storage medium having a computer program stored thereon, and the computer program implements the steps of the above method when executed by a processor.
[0032] The present application sets a pointer pool and a dynamic pointer chain, and dynamically updates the dynamic pointer chain. When all pointers in the pointer pool are occupied or a pointer is lost, a new pointer is taken from the dynamic pointer chain. The dynamic pointer chain can replenish the pointer. When the pointer is recycled, the pointer is pushed back into the pointer pool. This cycle allows the pointers in the pointer pool to be updated and replaced at a certain speed. Even if the pointer is lost, it can be replenished, thereby solving the technical problem that the pointer cannot be recycled after being lost, and improving the resource utilization of the memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 It is a first flow chart of a pointer updating method based on FPGA provided in an embodiment of the present application;
[0034] Figure 2 is a second flow chart of a pointer updating method based on FPGA provided in an embodiment of the present application;
[0035] Figure 3 is a third flow chart of a pointer updating method based on FPGA provided in an embodiment of the present application;
[0036] Figure 4 is a system block diagram of a pointer updating device based on FPGA provided according to an embodiment of the present application;
[0037] Figure 5 It is a system block diagram of a network device provided according to an embodiment of the present application. DETAILED DESCRIPTION
[0038] The present application will be described in detail below in conjunction with the specific implementation modes shown in the accompanying drawings, but these implementation modes do not limit the present application. Structural, methodological, or functional changes made by ordinary technicians in the field based on these implementation modes are included in the protection scope of the present application.
[0039] Please refer to Figure 1 The present application embodiment provides a pointer updating method based on FPGA, the method comprising the steps of:
[0040] Step S101: set a pointer pool, where the pointers in the pointer pool point to addresses of memory.
[0041] Exemplarily, the pointer pool may be a FIFO, the memory may be a RAM, and the pointers in the pointer pool point to addresses of the memory, that is, the pointer values in the pointer pool correspond to the respective storage addresses of the memory.
[0042] Step S102, set a dynamic pointer chain, the dynamic pointer chain includes a head pointer and a tail pointer, the head pointer and the tail pointer are continuous pointers, the tail pointer is a moving pointer, the tail pointer is moved based on a preset time interval to update the dynamic pointer chain, and the pointers in the dynamic pointer chain point to the address of the memory.
[0043] A dynamic pointer chain is constructed, the dynamic pointer chain includes a head pointer and a tail pointer, the pointers in the dynamic pointer chain point to the address of the memory, the head pointer and the tail pointer are continuous pointers, the tail pointer is a movable pointer, and the tail pointer is dynamically adjusted, so that the pointers in the dynamic pointer chain are dynamically adjusted. The system adjusts the tail pointer based on a preset time interval to dynamically update the dynamic pointer chain.
[0044] Exemplarily, an initial dynamic pointer chain is set, and the head pointer of the initial dynamic pointer chain points to the address of the memory, and the address can be set according to actual needs. Based on the initial head pointer, and based on the number of pointers in the dynamic pointer chain, the tail pointer is set, and the system updates the tail pointer at a certain time interval. Because the pointers in the dynamic pointer chain are continuous, the tail pointer is increased by 1, so that the number of pointers in the dynamic pointer chain increases, so that the pointers of the dynamic pointer chain are dynamically updated, so that all the pointers in the dynamic pointer chain point to the address of the memory.
[0045] Exemplarily, the dynamic pointer chain can be designed in a register manner, because the pointer values in the dynamic pointer chain are continuous, so only the register of the head pointer and the register of the tail pointer are designed, that is, the first register stores the head pointer, and the second register stores the tail pointer. For the pointers between the head pointer and the tail pointer, the corresponding pointers can be confirmed in sequence based on the head pointer. For example, the first pointer after the head pointer is the head pointer plus 1, the second pointer is the head pointer plus 2, and so on. Based on this implementation, the register method is adopted instead of the FIFO method, which saves storage space in the FPGA design process.
[0046] Step S103, in response to a new pointer request instruction, determine whether there is an idle pointer in the pointer pool, if so, output an idle pointer as a new pointer; if not, use the head pointer in the dynamic pointer chain as the new pointer, and increase the head pointer by 1.
[0047] After receiving the new pointer request instruction, determine whether there is an idle pointer in the pointer pool. If there is an idle pointer in the pointer pool, pop up an idle pointer from the pointer pool, and the idle pointer is used as a new pointer, and the new pointer is used as the address of the memory. It can be understood that when there are multiple idle pointers in the pointer pool, an idle pointer can be arbitrarily popped out from the pointer pool and used as a new pointer. If there is no idle pointer in the pointer pool, that is, the pointers in the pointer pool are all occupied, it is necessary to obtain a new pointer from the dynamic pointer chain. As can be seen from the above, the pointer in the dynamic pointer chain also points to the address of the memory, that is, the pointer in the dynamic pointer chain can be used as the address of the memory, and the pointer in the dynamic pointer chain is frequently dynamically updated. After that, all its pointers point to the address of the memory, so a new pointer value can be obtained from the dynamic pointer chain. Therefore, if there is no idle pointer in the pointer pool, the head pointer in the dynamic pointer chain is used as a new pointer. After the head pointer is taken out, the head pointer is used, so it is necessary to update the head pointer in the dynamic pointer chain, that is, add 1 to the head pointer.
[0048] Step S104, in response to a pointer recycling instruction, determine whether the recycled pointer is in the dynamic pointer chain, if so, discard the recycled pointer, otherwise push the recycled pointer into the pointer pool.
[0049] Upon receiving a pointer recycling instruction, the pointer to be recycled is determined based on the pointer recycling instruction, and it is determined whether the recycled pointer is in the dynamic pointer chain. If it is in the dynamic pointer chain, the recycled pointer is discarded; if it is not in the dynamic pointer chain, the recycled pointer is pushed back into the pointer pool, and the corresponding pointer is released back into the pointer pool.
[0050] In this implementation, by setting up a pointer pool and a dynamic pointer chain, and by dynamically updating the dynamic pointer chain, when all pointers in the pointer pool are occupied or a pointer is lost, because the pointer also exists in the dynamic pointer chain, a new pointer is taken from the dynamic pointer chain, and the dynamic pointer chain can replenish the pointer. When the pointer is recycled, the pointer is pushed back into the pointer pool. This cycle allows the pointers in the pointer pool to be updated and replaced at a certain speed, and even if the pointer is lost, it can be replenished, thereby solving the technical problem that the pointer cannot be recycled after being lost, and improving the resource utilization of RAM.
[0051] As an optional implementation, the number of addresses of the memory is m, the initial value of the number of pointers of the dynamic pointer chain is n, the number of pointers in the pointer pool is mn, the pointers of the pointer pool are 0 to mn-1, where n is less than or equal to m, the head pointer of the dynamic pointer chain is mn, and the tail pointer of the dynamic pointer chain is m-1. In the design of the dynamic pointer chain, the number of pointers of the dynamic pointer chain can be set to be consistent with the number of pointers in the pointer pool, that is, consistent with the number of addresses of the memory, and the pointers in the dynamic pointer chain also all point to the addresses of the memory. For example, the number of addresses of the memory is 1024, the number of pointers in the pointer pool is 1024, the number of pointers in the dynamic pointer chain is 1024, the pointers in the pointer pool point to the addresses of the memory, and the pointers in the dynamic pointer chain point to the addresses of the memory.
[0052] As an optional implementation, in the design of the dynamic pointer chain, the number of pointers in the dynamic pointer chain can be set to be inconsistent with the number of pointers in the pointer pool, that is, the initial value n of the number of pointers in the dynamic pointer chain is less than m. After the system is powered on, it is necessary to perform dynamic adjustment on the dynamic pointer chain, and after adjustment, the pointers in the dynamic pointer chain point to the address of the memory. The dynamic adjustment step includes: in the first clock cycle, the tail pointer is increased by 1, and the tail pointer becomes 0. Every x clock cycles, the tail pointer is increased by 1 from 0 until the tail pointer is mn-1. For example, the system is initially set as follows: the number of addresses of the memory is 1024, assuming that the address is set to 0-1023, the number of pointers in the pointer pool is 1008, and the corresponding pointers are 0-1007. The initial value of the number of pointers in the dynamic pointer chain is 16, and the pointers of the dynamic pointer chain are 1008-1023, that is, the head pointer is 1008 and the tail pointer is 1023. After the system is powered on, the dynamic pointer chain is dynamically adjusted. The adjustment process is: in the first clock cycle, the tail pointer is incremented by 1 and updated to 0. In the second clock cycle, the tail pointer is incremented by 1 and updated to 1. After multiple clock cycles, the tail pointer is updated to 1007, that is, the pointers in the dynamic pointer chain change from 1008 to 1023 to 0 to 1007. The pointers between 1008 and 1023 are continuous pointers, and the pointers between 0 and 1007 are continuous pointers. It can be seen that after dynamic adjustment, the pointers in the dynamic pointer chain can all execute the addresses of the memory. It can be understood that the dynamic adjustment process is relatively short when the FPGA system clock is used as the clock in the dynamic adjustment process.
[0053] As an optional implementation, Figure 2 As shown, in response to a new pointer request instruction, it is determined whether there is an idle pointer in the pointer pool. If yes, an idle pointer is output as a new pointer; if no, the head pointer in the dynamic pointer chain is used as the new pointer, and the head pointer is increased by 1, including:
[0054] Step S201, in response to a write data instruction of the memory, output a new pointer request instruction;
[0055] Step S202: After obtaining the new pointer, perform a write operation on the memory using the new pointer.
[0056] When data needs to be written to the memory, the FPGA executes the operation of writing to the memory, that is, outputting the write data instruction of the memory. To write data to the memory, a pointer needs to be obtained, so a new pointer request instruction is output based on the write instruction. According to the new pointer request instruction, it is determined whether there is an idle pointer in the pointer pool. If so, an idle pointer is output as a new pointer; if not, the head pointer in the dynamic pointer chain is used as the new pointer, and the head pointer is increased by 1. After obtaining the new pointer, the memory write operation is performed with the new pointer to complete the memory write data function.
[0057] As an optional implementation, Figure 3 As shown, in response to a pointer recovery instruction, the method includes:
[0058] Step S301, in response to a data read instruction of the memory, performing a read operation on the memory;
[0059] Step S302: After the read operation is completed, a pointer recovery instruction is output, where the pointer recovery instruction includes a read address of the read operation.
[0060] When data needs to be read from the memory, the FPGA executes the memory read operation, that is, outputs the memory read data instruction, and reads the data from the memory. When the read operation is completed, the pointer recovery instruction is output, and the pointer recovery instruction includes the read address of the read operation. According to the read address of the pointer recovery instruction, the pointer to be recovered is determined, and it is determined whether the recovered pointer is in the dynamic pointer chain. If so, the recovered pointer is discarded, otherwise the recovered pointer is pushed into the pointer pool.
[0061] As an optional implementation, if not, the head pointer in the dynamic pointer chain is used as the new pointer, and the head pointer is increased by 1, including: every preset first clock cycle, judging whether the tail pointer in the dynamic pointer chain is increased by 1, and the judging step is: if the tail pointer is less than the head pointer, the tail pointer is increased by 1, otherwise the tail pointer remains unchanged. Output a new pointer request instruction every preset second clock cycle, and the first clock cycle is greater than the second clock cycle. After the head pointer in the dynamic pointer chain is updated, it is necessary to judge whether the tail pointer of the dynamic pointer chain is updated, and every first clock cycle, the update of the tail pointer is judged, if the tail pointer is less than the head pointer, the tail pointer is increased by 1, otherwise the tail pointer remains unchanged. Exemplarily, if the second clock cycle is set to 2 system clock cycles, the second clock cycle is set to 4 system clock cycles. The rate of taking a new pointer is also set, and a new pointer request instruction is output every preset second clock cycle, and the first clock cycle is greater than the second clock cycle. Under this implementation, the update rate of the dynamic pointer chain is less than the rate of taking a new pointer, so that the flow speed of the pointer is greater than the replacement speed of the pointer, so that the pointer in the pointer pool is replaced at a certain speed.
[0062] like Figure 4 As shown, the present application provides a pointer updating device based on FPGA, the device comprising:
[0063] The storage module 401 is used to set a pointer pool, where the pointers in the pointer pool point to the addresses of the storage;
[0064] A dynamic pointer module 402 is used to set a dynamic pointer chain, the dynamic pointer chain includes a head pointer and a tail pointer, the head pointer and the tail pointer are continuous pointers, the tail pointer is a moving pointer, the tail pointer is moved based on a preset time interval to update the dynamic pointer chain, and the pointers in the dynamic pointer chain point to the addresses of the memory;
[0065] The pointer request module 403 is used to respond to a new pointer request instruction, determine whether there is an idle pointer in the pointer pool, if yes, output an idle pointer as a new pointer; if no, use the head pointer in the dynamic pointer chain as the new pointer, and increase the head pointer by 1;
[0066] The pointer recycling module 404 is used to respond to a pointer recycling instruction and determine whether the recycled pointer is in the dynamic pointer chain. If so, the recycled pointer is discarded; otherwise, the recycled pointer is pushed into the pointer pool.
[0067] Optionally, the number of addresses of the memory is m, the initial value of the number of pointers of the dynamic pointer chain is n, the number of pointers in the pointer pool is mn, the pointers of the pointer pool are 0 to mn-1, where n is less than or equal to m, the head pointer of the dynamic pointer chain is mn, and the tail pointer of the dynamic pointer chain is m-1. When n is less than m, after the system is powered on, the dynamic pointer module 402 performs dynamic adjustment on the dynamic pointer chain, including: in the first clock cycle, the tail pointer is increased by 1, and the tail pointer becomes 0; every x clock cycles, the tail pointer is increased by 1 from 0 until the tail pointer is mn-1.
[0068] Optionally, the pointer request module 403 is specifically used for:
[0069] In response to a write data instruction of the memory, output a new pointer request instruction;
[0070] After obtaining the new pointer, the memory write operation is performed using the new pointer.
[0071] Optionally, the pointer recovery module 404 is specifically used for:
[0072] In response to a data read instruction of the memory, performing a read operation on the memory;
[0073] When the read operation is completed, a pointer recovery instruction is output, and the pointer recovery instruction includes the read address of the read operation.
[0074] Optionally, the pointer recovery module 404 is specifically used for:
[0075] At each preset first clock cycle, it is determined whether the tail pointer in the dynamic pointer chain is incremented by 1, and the determination step is: if the tail pointer is smaller than the head pointer, the tail pointer is incremented by 1, otherwise the tail pointer remains unchanged.
[0076] Optionally, the pointer request module 403 is specifically used for:
[0077] A new pointer request instruction is output every second preset clock cycle, and the first clock cycle is greater than the second clock cycle.
[0078] The embodiment of the present application further provides a network device, which includes the above-mentioned FPGA-based pointer updating device, for example, the network device includes Figure 4 The FPGA-based pointer update device shown. The network device can be any network device used for service forwarding in a communication network. For example, according to the device type, the network device can be a switch, a router, etc. According to the device deployment location, the network device can be an edge network device, a core network device, or a network device in a data center.
[0079] As an example, see Figure 5 , which shows a schematic diagram of the structure of a network device provided by an embodiment of the present application. The network device includes an FPGA-based pointer update device 501, a communication interface 502, a processor 503, a memory 504, and a bus 505. The processor 503, the memory 504, the communication interface 502, and the FPGA-based pointer update device 501 are connected to each other through the bus 505. Among them, Figure 5 The connection method between the processor 503, memory 504, communication interface 502 and FPGA-based pointer update device 501 shown is merely exemplary. During implementation, the processor 503, memory 504, communication interface 502 and FPGA-based pointer update device 501 may also be connected to each other in communication with each other using other connection methods besides the bus 505.
[0080] The memory 504 can be used to store computer programs, which may include instructions and data. In an embodiment of the present application, the memory 504 may be various types of storage media, such as random access memory (RAM), read only memory (ROM), non-volatile RAM (NVRAM), programmable ROM (PROM), erasable PROM (EPROM), electrically erasable PROM (EEPROM), flash memory, optical storage, and registers. The memory 504 may include a hard disk and / or a memory.
[0081] The processor 503 may be a general-purpose processor, which may be a processor that performs specific steps and / or operations by reading and executing a computer program stored in a memory (e.g., memory 504), and the general-purpose processor may use data stored in the memory (e.g., memory 504) in the process of performing the steps and / or operations. The general-purpose processor may be, for example, but not limited to, a central processing unit (CPU). In addition, the processor 503 may also be a dedicated processor, which may be a processor specially designed to perform specific steps and / or operations, and the dedicated processor may be, for example, but not limited to, an ASIC and an FPGA, etc. In addition, the processor 503 may also be a combination of multiple processors, such as a multi-core processor.
[0082] The communication interface 502 may include an input / output (I / O) interface, a physical interface, and a logical interface, etc., which are used to interconnect devices within the network device, and an interface for interconnecting the network device with other devices (such as network devices). The physical interface may be a Gigabit Ethernet interface (GE), which may be used to interconnect the network device with other devices, and the logical interface is an interface within the network device, which may be used to interconnect devices within the network device. It is easy to understand that the communication interface 502 may be used for the network device to communicate with other devices, for example, the communication interface 802 is used to send and receive messages between the network device and other devices.
[0083] The bus 505 may be any type of communication bus for interconnecting the processor 503 , the memory 504 , the communication interface 502 , and the FPGA-based pointer updating device 501 , such as a system bus.
[0084] The pointer updating device 501 based on FPGA can be any possible chip such as ASIC chip, FPGA chip, etc. The structure of the pointer updating device 501 based on FPGA can refer to Figure 1 The illustrated embodiments are not described here in detail. The interconnection between any device among the processor 503, the memory 504 and the communication interface 502 and the FPGA-based pointer update device 501 may specifically refer to the interconnection between any device and the device in the FPGA-based pointer update device 501. In some embodiments, the above-mentioned processor 503, the memory 504 and the communication interface 502 may all be integrated on the FPGA-based pointer update device 501, or the above-mentioned processor 503, the memory 504 and the communication interface 502 may be respectively arranged on chips independent of each other, or may be at least partially or completely arranged on the same chip. Whether each device is independently arranged on different chips or integrated on one or more chips often depends on the needs of product design. This application does not limit the specific implementation form of the above-mentioned devices.
[0085] Figure 5 The network device shown is merely exemplary. During implementation, the network device may further include other components, which are not listed one by one in this article.
[0086] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part in the form of a computer program product, and the computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a computer network or other programmable device. The computer instruction can be stored in a computer's readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instruction can be transmitted from a website site, a computer, a server or a data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, a data center, etc. that contains one or more available media integrated. Available media can be magnetic media (e.g., floppy disk, hard disk, tape), optical media, or semiconductor media (e.g., solid-state hard disk), etc.
[0087] The embodiments disclosed in the present application also provide a computer-readable storage medium, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the FPGA-based pointer updating method described in any one of the above embodiments.
[0088] Although the preferred embodiments of the present application have been disclosed for illustrative purposes, those skilled in the art will appreciate that various modifications, additions and substitutions are possible, without departing from the scope and spirit of the application as disclosed in the accompanying claims.
Claims
1. A pointer updating method based on FPGA, characterized in that: The method comprises: Setting a pointer pool, wherein the pointers in the pointer pool point to addresses of the memory; A dynamic pointer chain is set, the dynamic pointer chain includes a head pointer and a tail pointer, the head pointer and the tail pointer are continuous pointers, the tail pointer is a moving pointer, the tail pointer is moved based on a preset time interval to update the dynamic pointer chain, and the pointers in the dynamic pointer chain point to the address of the memory; In response to a new pointer request instruction, determine whether there is an idle pointer in the pointer pool, if yes, output an idle pointer as a new pointer; if no, use the head pointer in the dynamic pointer chain as the new pointer, and increase the head pointer by 1; In response to a pointer recycling instruction, it is determined whether the recycled pointer is in the dynamic pointer chain. If so, the recycled pointer is discarded; otherwise, the recycled pointer is pushed into the pointer pool.
2. The pointer updating method based on FPGA as claimed in claim 1, characterized in that: The number of addresses of the memory is m, the initial value of the number of pointers of the dynamic pointer chain is n, the number of pointers in the pointer pool is mn, the pointers of the pointer pool are 0 to mn-1, where n is less than or equal to m, the head pointer of the dynamic pointer chain is mn, and the tail pointer of the dynamic pointer chain is m-1.
3. The pointer updating method based on FPGA as claimed in claim 2, characterized in that: When n is less than m, after the system is powered on, the dynamic pointer chain is dynamically adjusted, and the steps of the dynamic adjustment include: In the first clock cycle, the tail pointer is incremented by 1, and the tail pointer becomes 0; Every x clock cycles, the tail pointer is incremented from 0 to 1 until the tail pointer is mn-1.
4. The pointer updating method based on FPGA as claimed in claim 1, characterized in that: The step of responding to a new pointer request instruction comprises: In response to a write data instruction of the memory, output the new pointer request instruction; After acquiring the new pointer, a write operation of the memory is performed using the new pointer.
5. The pointer updating method based on FPGA as claimed in claim 4, characterized in that: The step of responding to a pointer recovery instruction comprises: In response to a data read instruction of the memory, performing a read operation on the memory; When the read operation is completed, a pointer recovery instruction is output, and the pointer recovery instruction includes a read address of the read operation.
6. The pointer updating method based on FPGA as claimed in claim 1, characterized in that: The method further comprises: At each preset first clock cycle, it is determined whether the tail pointer in the dynamic pointer chain is incremented by 1, and the determination step is as follows: If the tail pointer is smaller than the head pointer, the tail pointer is incremented by 1, otherwise the tail pointer remains unchanged.
7. The pointer updating method based on FPGA as claimed in claim 6, characterized in that: The method further comprises: The new pointer request instruction is output every preset second clock cycle, and the first clock cycle is greater than the second clock cycle.
8. A pointer updating device based on FPGA, characterized in that: The device comprises: A storage module, used for setting a pointer pool, wherein the pointers in the pointer pool point to the addresses of the storage; A dynamic pointer module, used to set a dynamic pointer chain, the dynamic pointer chain includes a head pointer and a tail pointer, the head pointer and the tail pointer are continuous pointers, the tail pointer is a moving pointer, the tail pointer is moved based on a preset time interval to update the dynamic pointer chain, and the pointers in the dynamic pointer chain point to the address of the memory; An update module, for responding to a new pointer request instruction, determining whether there is an idle pointer in the pointer pool, and if so, outputting an idle pointer as a new pointer; if not, using a head pointer in the dynamic pointer chain as a new pointer, and increasing the head pointer by 1; The recycling module is used to respond to a pointer recycling instruction, determine whether the recycled pointer is in the dynamic pointer chain, if so, discard the recycled pointer, otherwise push the recycled pointer into the pointer pool.
9. A network device, characterized in that: It comprises the pointer updating device based on FPGA as claimed in claim 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Initializing method and circuit of head and tail pointer chain table storage
CN104598194A
Queue manager and method based on large-granularity storage unit
CN109783035A
Memory space management method and device, electronic equipment and storage medium
CN115168243A
Dynamic chain type control method for queue messages based on FPGA (Field Programmable Gate Array)
CN116700916A
Handling Pointers in Program Code in a System that Supports Multiple Address Spaces
US20140047419A1
