Buffer division method and device, storage medium and electronic device

Dynamically partitioning of buffers solves the problem that traditional methods cannot adapt to different application scenarios, improves resource utilization and performance, and realizes efficient data buffer management in different scenarios.

CN119025445APending Publication Date: 2024-11-26SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411214876.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-30
Publication Date
2024-11-26

AI Technical Summary

Technical Problem

The traditional buffer partitioning and management method fixed methods cannot adapt to different application scenarios of the chip, resulting in waste of resources or performance decline.

Method used

By determining the starting addresses of the first buffer and the second buffer based on the total buffer, dynamically divide the small buffers, partitioning and managing the buffers according to the data storage needs, and improving the utilization rate of the buffers.

Benefits of technology

It realizes dynamic adjustment of buffer size and quantity in different application scenarios, improves resource utilization and performance, and solves the problems of resource waste and performance decline caused by traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119025445A_ABST
    Figure CN119025445A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a partition method and device of a buffer area, a storage medium and an electronic device.The partition method of the buffer area comprises the steps that a first initial address of a first buffer area and a second initial address of a second buffer area are determined according to a total buffer area, the first buffer area comprises a plurality of first small buffer areas, and the second buffer area comprises a plurality of second small buffer areas; the first small buffer area is used for storing data, the second buffer area comprises a plurality of second small buffer areas, and the second small buffer areas are used for storing buffer area numbers of the first small buffer areas; receiving a first data storage request under the condition of determining that the total buffer area is in the buffer area division state; and dividing a new first small buffer area in the total buffer area according to the first end address of the first buffer area at the current moment, storing the first data in the new first small buffer area, and dividing a new second small buffer area in the total buffer area according to the second end address of the second buffer area at the current moment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the computer field, and more specifically, to a buffer zone partitioning method and device, a storage medium, and an electronic device. Background Art

[0002] With the rapid development of integrated circuits, more and more interfaces are integrated on the chip. The interface protocols and upper layer protocols of each interface are different. Therefore, it is necessary to realize the sorting, splicing and exchange of data between different interfaces inside the chip. In the process of conversion and exchange, data buffer must be used. The data input by the interface needs to be temporarily stored, and then the data is sorted, split, spliced ​​and packaged according to the protocol of the target interface. In particular, the upper layer protocols above some interfaces often define some long messages that are much longer than what the interface can accommodate. Therefore, in the conversion process, the data needs to be further judged and sorted. An indispensable function in this process is data buffering and buffer management.

[0003] The traditional buffer management method is to define the buffer at the beginning of the design, including the buffer address, total buffer size, and the number of small buffers, which are fixed, and then the entire buffer is managed by calculation according to fixed scenarios and methods. However, there is a disadvantage to this, that is, the interface performance and packet size requirements of the chip are not fixed in different scenarios or working conditions. If it is managed and controlled according to a predetermined scenario, it will inevitably cause resource waste or performance degradation in other scenarios.

[0004] Regarding the related technologies, the traditional buffer division and management methods are carried out in a fixed manner and cannot adapt to different application scenarios of the chip, resulting in technical problems such as resource waste or performance degradation, and no effective solution has been proposed yet. Summary of the invention

[0005] The embodiments of the present application provide a buffer partitioning method and device, a storage medium and an electronic device, so as to at least solve the problem in the related art that the traditional buffer partitioning and management method is performed in a fixed manner and cannot adapt to different application scenarios of the chip, resulting in resource waste or performance degradation.

[0006] According to an embodiment of the present application, a buffer partitioning method is provided, comprising: determining a first starting address of a first buffer and a second starting address of a second buffer according to a total buffer, wherein the total buffer comprises the first buffer and the second buffer, the first buffer comprises a plurality of first small buffers, the plurality of first small buffers are used to store data, the plurality of first small buffers have the same size and are all p1, the second buffer comprises a plurality of second small buffers, the plurality of second small buffers are used to store buffer numbers of the plurality of first small buffers, the plurality of second small buffers have the same size and are all p2; in the case of determining that the total buffer is in a buffer partitioning state, receiving a first data storage request, wherein the first data storage request is used to store first data; partitioning a new first small buffer in the total buffer according to the first end address of the first buffer at the current moment, storing the first data in the new first small buffer, and partitioning a new second small buffer in the total buffer according to the second end address of the second buffer at the current moment.

[0007] In an exemplary embodiment, determining the first starting address of the first buffer and the second starting address of the second buffer according to the total buffer includes: determining the minimum address of the total buffer as the first starting address; storing the first starting address as the initial end address of the first buffer in a current address register, wherein the current address register is used to store the first end address; obtaining a first value from a total buffer size register, determining the maximum address according to the first starting address and the first value, and determining the maximum address as the second starting address, wherein the first value is used to indicate the size of the total buffer; storing the second starting address in a starting address register, and storing A as the initial end address of the second buffer in an end address register, wherein the end address register is used to store the second end address, A=B-1, and B is the second starting address.

[0008] In an exemplary embodiment, after dividing a new first small buffer zone in the total buffer zone according to the first end address of the first buffer zone at the current moment, storing the first data in the first small buffer zone, and dividing a new second small buffer zone in the total buffer zone according to the second end address, the method further includes: updating the current address register according to p1, and updating the end address register according to p2; determining the size of C and D, wherein C=E+p1+1, E is the value in the current address register, and D is the value in the end address register; when C is less than D, determining that the total buffer zone is in the buffer zone division state; when C is greater than or equal to D, determining that the total buffer zone is in the division completion state.

[0009] In an exemplary embodiment, updating the current address register according to p1 and updating the end address register according to p2 includes: updating the current address register according to the sum of the first end address stored in the current address register at the current moment and p1, and updating the end address register according to the difference between the second end address stored in the end address register at the current moment and p2.

[0010] In an exemplary embodiment, the method further includes: when it is determined that a third small buffer among the multiple first small buffers releases the stored data, storing the first buffer number of the third small buffer in a fourth small buffer among the multiple second small buffers, wherein the fourth small buffer is the second small buffer pointed to by the first write address; and updating the first write address to a second write address according to p2, wherein the second write address points to the next second small buffer of the fourth small buffer.

[0011] In an exemplary embodiment, after storing the first buffer number of the third small buffer in the fourth small buffer among the multiple second small buffers, the method further includes: receiving a second data storage request when it is determined that the total buffer is in a division completion state, wherein the second data storage request is used to store the second data; determining whether there is a target signal, wherein the target signal is used to indicate that the multiple second small buffers are all empty; when it is determined that the target signal does not exist, determining a fifth small buffer among the multiple second small buffers according to the first read address, and reading the second buffer number of the sixth small buffer from the fifth small buffer, wherein the multiple first small buffers include the sixth small buffer; storing the second data in the sixth small buffer according to the second buffer number; determining a second read address according to the first read address and p2; when the second read address is less than the second end address, determining the second start address as the third read address; when the second read address is greater than the second end address, determining the second read address as the third read address; updating the first read address to the third read address, wherein the third read address points to the next second small buffer of the fifth small buffer.

[0012] In an exemplary embodiment, after determining whether the target signal exists, the method further includes: if it is determined that the target signal exists, prohibiting access to the second buffer according to the first read address.

[0013] According to another embodiment of the present application, a buffer partitioning device is provided, comprising: a determination module, used to determine a first starting address of a first buffer and a second starting address of a second buffer according to a total buffer, wherein the total buffer includes the first buffer and the second buffer, the first buffer includes a plurality of first small buffers, the plurality of first small buffers are used to store data, the plurality of first small buffers have the same size and are all p1, the second buffer includes a plurality of second small buffers, the plurality of second small buffers are used to store buffer numbers of the plurality of first small buffers, the plurality of second small buffers have the same size and are all p2; a receiving module, used to receive a first data storage request when determining that the total buffer is in a buffer partitioning state, wherein the first data storage request is used to store first data; a partitioning module, used to partition a new first small buffer in the total buffer according to the first end address of the first buffer at the current moment, store the first data in the new first small buffer, and partition a new second small buffer in the total buffer according to the second end address of the second buffer at the current moment.

[0014] According to another embodiment of the present application, a computer-readable storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when run.

[0015] According to another embodiment of the present application, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0016] According to another embodiment of the present application, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of the method described in each embodiment of the present application are implemented.

[0017] Through the present application, the first starting address of the first buffer and the second starting address of the second buffer are first determined according to the total buffer, wherein the total buffer includes the first buffer and the second buffer, the first buffer includes multiple first small buffers, the first small buffer is used to store data, the sizes of the multiple first small buffers are the same and are all p1, the second buffer includes multiple second small buffers, the second small buffer is used to store the buffer number of the first small buffer, the sizes of the multiple second small buffers are the same and are all p2; if the total buffer is in a buffer division state, then after receiving a first data storage request, a new first small buffer is divided in the total buffer according to the first end address of the first buffer, and the first data is stored in the newly generated first small buffer, and a new second small buffer is divided according to the second end address of the second buffer at the current moment; adopting the above scheme, when a new data storage request is received, the buffer is dynamically divided according to the data storage demand, thereby improving the utilization rate of the data buffer; thereby solving the problem in the related art that the traditional buffer division and management method is carried out in a fixed manner and cannot adapt to different application scenarios of the chip, resulting in resource waste or performance degradation. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] Figure 1 It is a hardware structure block diagram of a computer terminal according to a buffer partitioning method of an embodiment of the present application;

[0019] Figure 2 is a flowchart of a buffer zone division method according to an embodiment of the present application;

[0020] Figure 3 is a schematic diagram of an optional buffer zone partition structure according to an embodiment of the present application;

[0021] Figure 4is a schematic diagram of an optional buffer control logic circuit structure according to an embodiment of the present application;

[0022] Figure 5 It is a flowchart of an optional buffer zone partitioning and management method that can be dynamically and adaptively implemented according to an embodiment of the present application;

[0023] Figure 6 It is a structural block diagram of a buffer zone partitioning device according to an embodiment of the present application. DETAILED DESCRIPTION

[0024] The embodiments of the present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0025] It should be noted that the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0026] The method embodiments provided in the embodiments of the present application can be executed in a computer terminal or a similar computing device. Taking running on a computer terminal as an example, Figure 1 1 is a hardware structure block diagram of a computer terminal of a buffer partitioning method according to an embodiment of the present application. Figure 1 As shown, the computer terminal may include one or more ( Figure 1 Only one is shown in the figure) processor 102 (processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the computer terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0027] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the method for dividing the buffer in the embodiment of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0028] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of a computer terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0029] The following is an explanation of the professional terms that appear in this application:

[0030] SRAM: static random access memory;

[0031] FIFO (First Input First Output): First-in, first-out memory;

[0032] DDR: Double data rate synchronous memory.

[0033] When the receiving end receives the data, the first thing to do is to find an empty buffer to cache the received data, which involves the issue of buffer management. In order to achieve effective management of the buffer, the buffer must first be divided into independent small buffers, and then the corresponding control logic must be designed to manage the status of each buffer, and then an available buffer entry can be provided to the upper-level logic so that the upper-level logic can directly cache the received data. The first issue involved is the size selection of the small buffer. Generally, the requirement for the divided small buffer is to store a packet of data on the interface. Therefore, if you want the product to adapt to multiple scenarios, you need to consider whether the capacity of the divided small buffer in each scenario can carry the maximum packet length in each scenario. This means that in order to meet the application of individual extreme scenarios, the designer may set a small buffer size that will cause huge waste in other scenarios, which will consistently affect the performance of the system.

[0034] In order to maximize the efficiency of resources in different scenarios, a buffer partitioning method is provided in this embodiment, which is applied to a computer terminal. Figure 2 is a flowchart of a method for dividing a buffer zone according to an embodiment of the present application, such as Figure 2 As shown, the process includes the following steps:

[0035] Step S202, determining a first starting address of a first buffer and a second starting address of a second buffer according to a total buffer, wherein the total buffer includes the first buffer and the second buffer, the first buffer includes a plurality of first small buffers, the plurality of first small buffers are used to store data, the plurality of first small buffers have the same size and are all p1, the second buffer includes a plurality of second small buffers, the plurality of second small buffers are used to store buffer numbers of the plurality of first small buffers, the plurality of second small buffers have the same size and are all p2;

[0036] Step S204, receiving a first data storage request when it is determined that the total buffer is in a buffer partition state, wherein the first data storage request is used to store first data;

[0037] Step S206, divide a new first small buffer in the total buffer according to the first end address of the first buffer at the current moment, store the first data in the new first small buffer, and divide a new second small buffer in the total buffer according to the second end address of the second buffer at the current moment.

[0038] Through the above steps, the first starting address of the first buffer and the second starting address of the second buffer are first determined according to the total buffer, wherein the total buffer includes the first buffer and the second buffer, the first buffer includes multiple first small buffers, the first small buffer is used to store data, the sizes of the multiple first small buffers are the same and are all p1, and the second buffer includes multiple second small buffers, the second small buffer is used to store the buffer number of the first small buffer, the sizes of the multiple second small buffers are the same and are all p2; if the total buffer is in a buffer division state, then after receiving a first data storage request, a new first small buffer is divided in the total buffer according to the first end address of the first buffer, and the first data is stored in the newly generated first small buffer, and a new second small buffer is divided according to the second end address of the second buffer at the current moment; adopting the above scheme, when a new data storage request is received, the buffer is dynamically divided according to the data storage demand, thereby improving the utilization rate of the data buffer; thereby solving the problem in the related art that the traditional buffer division and management method is carried out in a fixed manner and cannot adapt to different application scenarios of the chip, resulting in resource waste or performance degradation.

[0039] The execution subject of the above steps may be a computer terminal, etc., but is not limited thereto.

[0040] The execution order of step S202 and step S204 is interchangeable, that is, step S204 may be executed first, and then step S202.

[0041] In an exemplary embodiment, determining the first starting address of the first buffer and the second starting address of the second buffer according to the total buffer includes: determining the minimum address of the total buffer as the first starting address; storing the first starting address as the initial end address of the first buffer in a current address register, wherein the current address register is used to store the first end address; obtaining a first value from a total buffer size register, determining the maximum address according to the first starting address and the first value, and determining the maximum address as the second starting address, wherein the first value is used to indicate the size of the total buffer; storing the second starting address in a starting address register, and storing A as the initial end address of the second buffer in an end address register, wherein the end address register is used to store the second end address, A=B-1, and B is the second starting address.

[0042] In the embodiment of the present application, the following registers are configured in the buffer: a base address register, a total buffer size register and a small buffer size register. The base address register is used to inform the design buffer (i.e., the first buffer) of the starting address (i.e., the first starting address). The buffer starting address is not required to start from all 0s, as long as it is aligned to any starting address of the data bit width. The second is the total buffer size register, which is used to inform the design buffer of the total size space. The buffer size is not limited, as long as the address bit width can be covered and it is a continuous memory space starting from the base address. There is no restriction on the buffer type. It can be an on-chip SRAM or an off-chip memory, such as DDR, etc. The user can decide which memory space to allocate for buffering according to the scenario. It can be a whole memory or a part of it. Then the small buffer size register is used to store the size of each small buffer (i.e., p1). This user can define it according to the needs of the scenario. Here, the relationship between the total buffer size and the small buffer size does not require integer multiples. In this embodiment, the small buffer is allocated according to the maximum utilization rate according to the configuration adaptive calculation division.

[0043] Because the total buffer size and the small buffer size are configurable in the present application, any number of small buffers may appear, which brings a problem of how to manage these indefinite small buffers, because the number is indefinite and therefore fixed logic cannot be used to retrieve and manage the occupied state of the small buffer. Therefore, in order to achieve adaptive management of different numbers of small buffers, a dynamic adaptive Fifo is integrated in the present embodiment to achieve adaptive management of the empty and full state of the buffer. There is no fixed requirement for the bit width of the Fifo, which is determined by the maximum number of supported buffers, and can also be adjusted according to the data bit width of the buffer. For example, a 2B bit width Fifo supports a maximum depth of 64K, that is, it supports up to 64K small buffers. Within this range, the Fifo depth is a setting of the hardware circuit according to the adaptive size of the buffer. Adaptively, in the present embodiment, a Fifo start address register (i.e., the above-mentioned start address register) and a Fifo end address register (i.e., the above-mentioned end address register) are set for the Fifo. The Fifo start address register is used to record the start address of the Fifo buffer (i.e., the above-mentioned second buffer), and what is recorded is the maximum address of the calculated buffer; the Fifo end address register is used to record the end address of the Fifo buffer.

[0044] There is no fixed requirement for the bit width of Fifo. It is determined by the maximum number of supported buffers and can also be adjusted according to the data bit width of the buffer. For example, a 2B bit width Fifo supports a maximum depth of 64K, that is, it supports up to 64K small buffers. Within this range, the Fifo depth is set by the hardware circuit according to the buffer size. The main function of the Fifo is to access the current empty small buffer number. When the receiving end receives a packet of data, it only needs to determine whether the Fifo is empty to know whether there is an empty small buffer at present. If it is not empty, reading the Fifo can obtain an empty small buffer number, and then write the received data into the buffer where the buffer number is located. At the same time, when the data is read out of the small buffer, the buffer number is immediately written into the Fifo, which is equivalent to notifying the release of the small buffer space, and the space can continue to be used as a buffer for subsequent received data. In this way, the empty and full state management of the buffer is realized in a cycle, and the available small buffer number can be retrieved immediately.

[0045] There are several problems in the implementation of dynamic adaptive Fifo in design. The first is the implementation of Fifo's buffer, because Fifo also needs a storage area to store data, and the size of the buffer space used by Fifo, that is, the depth, is calculated adaptively by the number of small buffers according to the configuration parameters, and the supported Fifo depth adaptation range is large, from 2 to 64K. If a fixed maximum range of storage space is reserved, it will cause a large waste of resources. Therefore, how to implement a storage area with an adjustable storage space size to achieve Fifo depth adaptive adjustment is the first problem to be solved. In order to achieve Fifo depth adaptation, this embodiment also places the Fifo buffer in the buffer of the receiving end, so that different storage ranges can be divided as needed for Fifo data buffering, and adaptive management of the Fifo buffer is achieved.

[0046] Secondly, it is the division problem of Fifo buffer, because the storage area of ​​the receiving end is a whole, which is mainly used to store data packets. The hardware circuit needs to automatically calculate the required Fifo depth according to the value in the current configuration register and then divide it from the receiving end storage area for Fifo data storage, and at the same time, it is necessary to ensure that the storage space of Fifo and the storage space of data storage are isolated from each other and will not conflict. In addition, because the hardware circuit divides the receiving end memory into small buffers, it is necessary to comprehensively consider the storage space that Fifo needs to occupy, and the storage space occupied by Fifo is automatically adapted according to the number of small buffers. Therefore, the superposition of the two requires the use of more complex calculation and judgment logic. In order to solve this problem, the application completely isolates the starting addresses of the two, and allows 2 buffers (i.e., the first buffer and the second buffer) to divide the buffer from the minimum address and the maximum address of the storage area respectively, avoiding the problem of calculating the number of buffers and the Fifo depth from the beginning and dividing the Fifo buffer and the small buffer at the same time. Then, a Fifo structure with decreasing address, which is different from the traditional Fifo address increasing management method, is defined. The starting address of the Fifo buffer is set to the maximum address of the buffer. Every time one data is written, the Fifo write address is reduced by 1. Similarly, when reading data, the address is also decreased. Every time one data is read, the read address is reduced by 1. The entire address management logic is controlled in a decreasing manner. When the address decreases to the minimum value, it returns to the maximum address and starts to decrease again. The judgment of the empty and full signals is also judged according to the decreasing rules. This method of dividing the buffer from both ends of the buffer at the receiving end can better isolate the buffer used to store data and the Fifo buffer in the buffer, and both the data buffer and the Fifo buffer can obtain continuous address space. The final division of the data buffer and the Fifo buffer is as follows. Figure 3 shown.

[0047] Through the above embodiment, the detailed parameter information of each buffer is accurately recorded by setting the register, so as to prepare for the accurate completion of the buffer scheduling work; at the same time, the buffer is divided from both ends of the total buffer, which provides the basic conditions for dynamically dividing the buffer and determining the Fifo depth.

[0048] Furthermore, after dividing a new first small buffer zone in the total buffer zone according to the first end address of the first buffer zone at the current moment, storing the first data in the first small buffer zone, and dividing a new second small buffer zone in the total buffer zone according to the second end address, the method further includes: updating the current address register according to p1, and updating the end address register according to p2; determining the size of C and D, wherein C=E+p1+1, E is the value in the current address register, and D is the value in the end address register; when C is less than D, determining that the total buffer zone is in the buffer zone division state; and when C is greater than or equal to D, determining that the total buffer zone is in the division completion state.

[0049] After completing a buffer division, it is necessary to update the value stored in the register, and then determine whether the buffer division process of the total buffer is completed based on the updated register value. The judgment method can be: use the value in the current address register + the size value of the first small buffer + 1 to determine whether it is greater than the value in the end address register of the Fifo. If it is less than, it means that the remaining buffer space is greater than the space size of 1 first small buffer, so it can continue to be divided. Therefore, it is determined that the total cache area is in the buffer division state.

[0050] When it is determined that the total buffer is in the buffer division state, if messages continue to be received (i.e., the first data storage request mentioned above), the buffer division will continue, and the data will be stored in the newly divided first buffer. Then, the value of the Fifo end address register will be immediately reduced by 1 (unit depth), which is equivalent to expanding the Fifo depth by 1, and then the value of the current address register will be updated, and the value of the current address register + the value of the small buffer space register (i.e., p1) will be written back to the current address register, and then the size of C and D will be compared again, and so on, until C is greater than or equal to D, which means that the remaining buffer space is less than the size of 1 first small buffer, and the buffer division has been completed. The division completion flag position is set to "1", which means that the total buffer is determined to be in the division completion state.

[0051] Through this embodiment, a state judgment of the total buffer is performed after each buffer division, the state of the total buffer is accurately controlled, and the data storage request is correctly processed according to the state of the total buffer.

[0052] Further, updating the current address register according to p1 and updating the end address register according to p2 includes: updating the current address register according to the sum of the first end address stored in the current address register at the current moment and p1, and updating the end address register according to the difference between the second end address stored in the end address register at the current moment and p2.

[0053] The specific method for updating the register value is: after a buffer division, the address of the first buffer is incremented positively, while the address of the second buffer is decremented. Therefore, the sum of the first end address and p1 is stored back into the current address register to update the first end address, and the difference between the second end address and p2 is stored back into the end address register to update the second end address.

[0054] Optionally, the method also includes: when it is determined that there is a third small buffer among the multiple first small buffers that releases the stored data, storing the first buffer number of the third small buffer in a fourth small buffer among the multiple second small buffers, wherein the fourth small buffer is the second small buffer pointed to by the first write address; and updating the first write address to a second write address according to p2, wherein the second write address points to the next second small buffer of the fourth small buffer.

[0055] During the entire processing process, once data is released in the third small buffer among multiple first small buffers, it indicates that the third small buffer is in an idle state, and the multiple second small buffers are used to store the buffer numbers of the first small buffers in the idle state. Therefore, the first buffer number of the third small buffer is stored in the fourth small buffer indicated by the first write address. The first write address plays a role similar to a pointer, pointing to the second small buffer currently to be used. After the first buffer number is stored, the first write address is updated to the difference between the first write address and p2, so that the updated first write address points to the next second small buffer to be used.

[0056] Through this embodiment, when the third small buffer resource is released, its number is immediately stored in the second buffer to facilitate subsequent calls and management.

[0057] Based on the above steps, after storing the first buffer number of the third small buffer in the fourth small buffer among the multiple second small buffers, the method further includes: receiving a second data storage request when it is determined that the total buffer is in a division completion state, wherein the second data storage request is used to store the second data; determining whether there is a target signal, wherein the target signal is used to indicate that the multiple second small buffers are all empty; when it is determined that the target signal does not exist, determining a fifth small buffer among the multiple second small buffers according to the first read address, and reading the second buffer number of the sixth small buffer from the fifth small buffer, wherein the multiple first small buffers include the sixth small buffer; storing the second data in the sixth small buffer according to the second buffer number; determining a second read address according to the first read address and p2; when the second read address is less than the second end address, determining the second start address as the third read address; when the second read address is greater than the second end address, determining the second read address as the third read address; updating the first read address to the third read address, wherein the third read address points to the next second small buffer of the fifth small buffer.

[0058] Optionally, after determining whether the target signal exists, the method further includes: if it is determined that the target signal exists, prohibiting access to the second buffer according to the first read address.

[0059] When the buffer is divided, the depth of the Fifo is determined. However, during the division process, since the Fifo depth is constantly iterating, how to update the data in the Fifo used to indicate whether the buffer is available and how to judge the buffer status also need to be discussed in categories:

[0060] 1, buffer division stage, in this stage, because buffer is not divided and completed, Fifo is not established and completed, the available buffer quantity of the storage area of ​​the whole receiving end is also unknown, so the value in Fifo is not used in this stage, that is, Fifo will not be read. Because buffer is being divided at this time, therefore just can know whether small buffer (i.e. first small buffer) is available according to current division situation, and all undivided buffers are empty at this time, so buffer data is buffered according to the numbering sequence of buffer division. When data is forwarded from small buffer as described in the above embodiment, then need to write the vacated buffer number (i.e. above-mentioned first buffer number) into Fifo, this operation needs to be carried out normally. At this moment, Ffio is not established and completed, but in the process of dividing buffer, every time a small buffer is divided, Fifo depth is added by 1, therefore, the small buffer number that is forwarded is written into Fifo and will not overflow and other problems. The small buffer that is forwarded and completed in this stage will be reused later, so also need to record it into Fifo, just can be used normally in normal receiving stage (i.e. total buffer is in division and completed state).

[0061] 2. Normal receiving stage. In this stage, the total buffer has been divided and Fifo has been established. At this time, the data in Fifo can be used to obtain the first available small buffer according to the normal process. As long as the buffer full signal is 0 (that is, there is no target signal), it means that there is an available small buffer and the small buffer number can be read; if the buffer full signal is 1 (that is, there is a target signal), do not read it. Therefore, the buffer is already full at this time. After forced reading, the value obtained must be invalid. If data is written according to the invalid value, it will cause data confusion. In addition, by querying the available depth count and used depth count of Fifo, the number and usage of small buffers can be obtained in real time, and the functions such as buffer usage efficiency statistics can be realized.

[0062] The distinction between these two stages can be identified by the division completion flag register. When the division completion flag register is 0, it means that the division is still in progress. At this time, Fifo is only written but not read. The number in Fifo and the empty and full signals will not be read. Data is directly received by dividing a new small buffer. Until the buffer division completion register is 1, indicating that the buffer division is completed, the available small buffer number is obtained by reading Fifo.

[0063] In addition, this embodiment can support the configuration parameters of the buffer during the operation of the product. It only needs to be valid when the buffer empty signal is valid, that is, the data in the buffer has been forwarded. In this case, set the division completion flag register to 0, and then set the setting completion flag register to 0, and then reconfigure the desired buffer address base address, size and small buffer size. Of course, during the configuration process, it is necessary to ensure that the upper-level logic will not apply for the buffer during this period by adding status control signals or handshakes, because the logic does not work before the setting completion flag register is set to 1. The entire circuit structure is as follows Figure 4 As shown, the configuration parameters related to the buffer partitioning work are stored in the configurable registers, and the buffer partitioning control module completes the buffer partitioning work. The buffer management logic reads the available buffer number and other information, and outputs statistical parameters such as the buffer full and the buffer used number.

[0064] According to the above-mentioned embodiments and Figure 4 The circuit structure shown can realize dynamically configurable adaptive buffer division and management logic. The user only needs to configure the information of the divided buffer for buffering into the corresponding logic register, and the hardware logic can automatically complete the division and management of the buffer according to the parameters and feedback the status of the small buffer. It also allows the user to modify the configuration midway and re-divide the buffer.

[0065] Optionally, the embodiment of the present application provides a buffer partitioning and management method that can be dynamically and adaptively implemented, such as Figure 5 As shown, the following steps are included:

[0066] 1. Software configures registers and triggers configuration completion;

[0067] After the hardware is powered on, it waits for the software to configure the base address register, total buffer size register and small buffer size register, and then sets the completion flag register to "1".

[0068] 2. Update the current address register;

[0069] After the logic query finds that the setting completion flag register is set to "1", the value in the base address register is first filled into the current address register. The value of this register is used to calculate the address to which the current small buffer (ie, the first small buffer) has been divided, that is, the first end address mentioned above.

[0070] 3. Calculate the maximum address of the buffer using the base address + memory space;

[0071] After the value in the storage area base address register is added to the value in the total buffer size register to obtain the maximum address of the buffer, the hardware logic automatically configures the registers of the internal adaptive Fifo.

[0072] 4. Fill in the Fifo start address and Fifo end address;

[0073] The adaptive Fifo mainly consists of 2 configuration registers:

[0074] Fifo start address register, used to record the start address of the Fifo buffer, that is, the maximum address of the buffer, that is, the second start address mentioned above;

[0075] The Fifo end address register is used to record the end address of the Fifo buffer (ie, the second end address mentioned above).

[0076] 5. Determine whether the current address + small buffer is greater than the Fifo end address (i.e., the second end address). If not, execute step 6. If yes, execute step 9.

[0077] Fill the maximum address of the buffer into the Fifo start address register; fill the value after the maximum address is reduced by 1 into the Fifo end address register. This is because the address management logic of the Fifo is managed and controlled in a decreasing manner. When writing data, the address is controlled and managed in a decreasing manner. Use the value in the current address register + the value of the small buffer space + 1 to determine whether it is greater than the value in the Fifo end address register. If it is less than the value in the Fifo end address register, it means that the remaining buffer space is greater than the size of 1 small buffer space, so it can still be divided.

[0078] 6. Wait for new data to be received. If not, wait in a loop until new data is received and execute step 7. If yes, execute step 7.

[0079] 7. Write the data to the address range specified by the current address register;

[0080] 8. Update the values ​​of the current address register and the Ffio end address register, and return to step 5;

[0081] 9. End buffer division and Fifo depth adjustment;

[0082] If it is greater than the value in the Fifo end address register, it means that the remaining buffer space is less than the size of one small buffer and the buffer division has been completed.

[0083] 10. The division completion mark position is "1".

[0084] The embodiment of the present application proposes a method for dynamically dividing and adaptively managing buffers, and divides the buffers while buffering data, so as to achieve a simple structure, so that users can customize the location and size of the buffers according to the usage scenarios of the product, and be compatible with more usage scenarios. For example, in the data buffering and reorganization functions in the on-chip network bus, the adaptability of the bus can be improved through this solution; or in the protocol conversion chip, the utilization rate of the data buffer can be improved by configuring the buffer size and number in different scenarios, and the protocol conversion efficiency can be improved at the same time; or when performing data buffering and reorganization functions in the network chip, the overall performance of the chip can be improved by allocating buffer resources of different nodes, so as to maximize the utilization rate of resources.

[0085] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0086] In this embodiment, a buffer partitioning device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0087] Figure 6 is a structural block diagram of a buffer zone partitioning device according to an embodiment of the present application, such as Figure 6 As shown, the device comprises:

[0088] a determination module 62, configured to determine a first starting address of a first buffer and a second starting address of a second buffer according to a total buffer, wherein the total buffer includes the first buffer and the second buffer, the first buffer includes a plurality of first small buffers, the plurality of first small buffers are used to store data, the plurality of first small buffers have the same size and are all p1, the second buffer includes a plurality of second small buffers, the plurality of second small buffers are used to store buffer numbers of the plurality of first small buffers, the plurality of second small buffers have the same size and are all p2;

[0089] A receiving module 64 is configured to receive a first data storage request when it is determined that the total buffer is in a buffer partition state, wherein the first data storage request is used to store first data;

[0090] The partitioning module 66 is used to partition a new first small buffer in the total buffer according to the first end address of the first buffer at the current moment, store the first data in the new first small buffer, and partition a new second small buffer in the total buffer according to the second end address of the second buffer at the current moment.

[0091] Through the above device, the first starting address of the first buffer and the second starting address of the second buffer are first determined according to the total buffer, wherein the total buffer includes the first buffer and the second buffer, the first buffer includes multiple first small buffers, the first small buffer is used to store data, the sizes of the multiple first small buffers are the same and are all p1, and the second buffer includes multiple second small buffers, the second small buffer is used to store the buffer number of the first small buffer, the sizes of the multiple second small buffers are the same and are all p2; if the total buffer is in a buffer division state, then after receiving a first data storage request, a new first small buffer is divided in the total buffer according to the first end address of the first buffer, and the first data is stored in the newly generated first small buffer, and a new second small buffer is divided according to the second end address of the second buffer at the current moment; adopting the above scheme, when a new data storage request is received, the buffer is dynamically divided according to the data storage demand, thereby improving the utilization rate of the data buffer; thereby solving the problem in the related art that the traditional buffer division and management method is carried out in a fixed manner and cannot adapt to different application scenarios of the chip, resulting in resource waste or performance degradation.

[0092] Optionally, the above-mentioned determination module 62 is also used to determine the minimum address of the total buffer as the first starting address; store the first starting address as the initial end address of the first buffer in the current address register, wherein the current address register is used to store the first end address; obtain a first value from the total buffer size register, determine the maximum address according to the first starting address and the first value, and determine the maximum address as the second starting address, wherein the first value is used to indicate the size of the total buffer; store the second starting address in the starting address register, and store A as the initial end address of the second buffer in the end address register, wherein the end address register is used to store the second end address, A=B-1, B is the second starting address.

[0093] Optionally, the above-mentioned division module 66 is also used to update the current address register according to p1, and to update the end address register according to p2; determine the size of C and D, wherein C=E+p1+1, E is the value in the current address register, and D is the value in the end address register; when C is less than D, determine that the total buffer is in the buffer division state; when C is greater than or equal to D, determine that the total buffer is in the division completion state.

[0094] Optionally, the above-mentioned division module 66 is also used to update the current address register according to the sum of the first end address stored in the current address register at the current moment and p1, and to update the end address register according to the difference between the second end address stored in the end address register at the current moment and p2.

[0095] Optionally, the above-mentioned device is also used to store the first buffer number of the third small buffer in a fourth small buffer among the multiple second small buffers when it is determined that there is a third small buffer among the multiple first small buffers that releases the stored data, wherein the fourth small buffer is the second small buffer pointed to by the first write address; and update the first write address to the second write address according to p2, wherein the second write address points to the next second small buffer of the fourth small buffer.

[0096] Optionally, the above-mentioned device is also used to receive a second data storage request when it is determined that the total buffer is in a division completion state, wherein the second data storage request is used to store the second data; determine whether there is a target signal, wherein the target signal is used to indicate that the multiple second small buffers are all empty; when it is determined that the target signal does not exist, determine the fifth small buffer in the multiple second small buffers according to the first read address, and read the second buffer number of the sixth small buffer from the fifth small buffer, wherein the multiple first small buffers include the sixth small buffer; store the second data in the sixth small buffer according to the second buffer number; determine the second read address according to the first read address and p2; when the second read address is less than the second end address, determine the second start address as the third read address; when the second read address is greater than the second end address, determine the second read address as the third read address; update the first read address to the third read address, wherein the third read address points to the next second small buffer of the fifth small buffer.

[0097] Optionally, the determination module 62 is further configured to prohibit access to the second buffer according to the first read address when it is determined that the target signal exists.

[0098] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0099] An embodiment of the present application further provides a computer-readable storage medium, in which a computer program is stored, wherein the computer program is configured to execute the steps of any of the above method embodiments when running.

[0100] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media that can store computer programs, such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk.

[0101] An embodiment of the present application further provides an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0102] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0103] An embodiment of the present application further provides a computer program product, comprising a non-volatile computer-readable storage medium, wherein the non-volatile computer-readable storage medium stores a computer program product, and when the computer program is executed by a processor, the steps of the method described in each embodiment of the present application are implemented.

[0104] For specific examples in this embodiment, reference may be made to the examples described in the above embodiments and exemplary implementation modes, and this embodiment will not be described in detail herein.

[0105] Obviously, those skilled in the art should understand that the above modules or steps of the present application can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order from that herein, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present application is not limited to any specific combination of hardware and software.

[0106] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the principles of the present application shall be included in the protection scope of the present application.

Claims

1. A method for dividing a buffer zone, characterized in that: include: Determine a first starting address of a first buffer and a second starting address of a second buffer according to a total buffer, wherein the total buffer includes the first buffer and the second buffer, the first buffer includes a plurality of first small buffers, the plurality of first small buffers are used to store data, the plurality of first small buffers have the same size and are all p1, the second buffer includes a plurality of second small buffers, the plurality of second small buffers are used to store buffer numbers of the plurality of first small buffers, the plurality of second small buffers have the same size and are all p2; In a case where it is determined that the total buffer is in a buffer partition state, receiving a first data storage request, wherein the first data storage request is used to store first data; A new first small buffer zone is divided out of the total buffer zone according to the first end address of the first buffer zone at the current moment, the first data is stored in the new first small buffer zone, and a new second small buffer zone is divided out of the total buffer zone according to the second end address of the second buffer zone at the current moment.

2. The method according to claim 1, characterized in that The step of determining a first starting address of the first buffer and a second starting address of the second buffer according to the total buffer comprises: Determine the minimum address of the total buffer as the first starting address; storing the first starting address as the initial ending address of the first buffer in a current address register, wherein the current address register is used to store the first ending address; Obtaining a first value from a total buffer size register, determining a maximum address of the total buffer according to the first starting address and the first value, and determining the maximum address as the second starting address, wherein the first value is used to indicate the size of the total buffer; The second starting address is stored in a starting address register, and A is stored as an initial ending address of the second buffer in an ending address register, wherein the ending address register is used to store the second ending address, A=B-1, and B is the second starting address.

3. The method according to claim 2, characterized in that After dividing a new first small buffer zone in the total buffer zone according to the first end address of the first buffer zone at the current moment, storing the first data in the first small buffer zone, and dividing a new second small buffer zone in the total buffer zone according to the second end address, the method further includes: updating the current address register according to p1, and updating the end address register according to p2; Determine the size of C and D, where C=E+p1+1, E is the value in the current address register, and D is the value in the end address register; In the case where C is less than D, determining that the total buffer is in the buffer division state; When C is greater than or equal to D, it is determined that the total buffer is in a division completion state.

4. The method according to claim 3, characterized in that The updating of the current address register according to p1 and the updating of the end address register according to p2 include: The current address register is updated according to the sum of the first end address and p1 stored in the current address register at the current moment, and the end address register is updated according to the difference between the second end address and p2 stored in the end address register at the current moment.

5. The method according to claim 1, characterized in that The method further comprises: When it is determined that a third small buffer in the plurality of first small buffers releases stored data, the first buffer number of the third small buffer is stored in a fourth small buffer in the plurality of second small buffers, wherein the fourth small buffer is the second small buffer pointed to by the first write address; The first write address is updated to a second write address according to p2, wherein the second write address points to a second small buffer next to the fourth small buffer.

6. The method according to claim 5, characterized in that After storing the first buffer zone number of the third small buffer zone in a fourth small buffer zone among the plurality of second small buffer zones, the method further comprises: In the case where it is determined that the total buffer is in a division completion state, receiving a second data storage request, wherein the second data storage request is used to store second data; Determining whether a target signal exists, wherein the target signal is used to indicate that the plurality of second small buffers are all empty; In the case where it is determined that the target signal does not exist, determining a fifth small buffer in the plurality of second small buffers according to the first read address, and reading the second buffer number of a sixth small buffer from the fifth small buffer, wherein the plurality of first small buffers includes the sixth small buffer; storing the second data in the sixth small buffer according to the second buffer number; Determine a second read address according to the first read address and p2; When the second read address is smaller than the second end address, determining the second start address as a third read address; When the second read address is greater than the second end address, determining the second read address as a third read address; The first read address is updated to the third read address, wherein the third read address points to the next second small buffer zone of the fifth small buffer zone.

7. The method according to claim 6, characterized in that After determining whether there is a target signal, the method further includes: In a case where it is determined that the target signal exists, access to the second buffer according to the first read address is prohibited.

8. A buffer zone division device, characterized in that: include: a determining module, configured to determine a first starting address of a first buffer and a second starting address of a second buffer according to a total buffer, wherein the total buffer includes the first buffer and the second buffer, the first buffer includes a plurality of first small buffers, the plurality of first small buffers are used to store data, the plurality of first small buffers have the same size and are all p1, and the second buffer includes a plurality of second small buffers, the plurality of second small buffers are used to store buffer numbers of the plurality of first small buffers, the plurality of second small buffers have the same size and are all p2; a receiving module, configured to receive a first data storage request when determining that the total buffer is in a buffer division state, wherein the first data storage request is used to store first data; A partitioning module is used to partition a new first small buffer in the total buffer according to a first end address of the first buffer at a current moment, store the first data in the new first small buffer, and partition a new second small buffer in the total buffer according to a second end address of the second buffer at a current moment.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 7 when executed by a processor.

10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 7 are implemented.

Citation Information

Cited By

  • Real-time data read-write method of on-chip logic analyzer and related device

    CN119849393A