A method and device for locating the oldest item in a pointer-type queue subset
By constructing a mask vector and fixed priority arbitration, the problem in the existing technology of being unable to efficiently locate the oldest item in any subset of a pointer-type queue is solved, the effect of efficiently finding the oldest item in any subset is achieved, and the application scope of the pointer-type queue is expanded.
Patent Information
- Application Number
- CN202310563460.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-18
- Publication Date
- 2025-09-16
- Estimated Expiration
- 2043-05-18
AI Technical Summary
The existing technology cannot efficiently locate the oldest item in any subset of a pointer-type queue, which limits its application scope.
By constructing a mask vector MASK, the items of the pointer-type queue are divided into parts with indexes lower than and not lower than the head pointer. The subset flag vector and the mask vector are then ANDed together, and the vector of the oldest item is generated in combination with fixed-priority arbitration to achieve the search for the oldest item in the specified subset.
This method realizes efficient search for the oldest item in any subset of a pointer queue, expands the application scope of pointer queues, and enables them to be used in scenarios where the oldest item in any subset needs to be located.
Smart Images

Figure CN116662613B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of integrated circuit chip design, and in particular to a method and device for locating the oldest item in a pointer-type queue subset. Background Art
[0002] Queues are a crucial functional unit in chip design, and different queue implementations have distinct characteristics. For example, a pointer queue can store data in a register array or random access memory (RAM). It maintains a head pointer and a tail pointer: the head pointer points to the location stored at the head of the queue, and the tail pointer points to the tail of the queue. Pointer queues can only insert new items from the tail of the queue, and existing items can only be deleted from the head of the queue. Therefore, the queue item pointed to by the head pointer is the "oldest" item in the entire queue, while the item just inserted at the location pointed to by the tail pointer is the "newest" item in the queue. Pointer queues typically only provide the location of the oldest item in the entire queue (that is, the location pointed to by the head pointer), and cannot provide the location of the oldest item in any subset of the queue. This limits the scope of application of pointer queues. Summary of the Invention
[0003] The technical problem to be solved by the present invention is: in response to the above-mentioned problems of the existing technical problems, a method and device for locating the oldest item in a subset of a pointer-type queue is provided. The present invention can efficiently realize the search for the oldest item in a subset of a pointer queue specified by a bit vector, greatly expanding the application scope of the pointer-type queue, so that it can be used in scenarios where the oldest item in any subset needs to be located.
[0004] In order to solve the above technical problems, the technical solution adopted by the present invention is:
[0005] A method for locating the oldest item in a pointer-type queue subset, comprising:
[0006] S101, constructing a mask vector MASK according to a head pointer Head of a pointer-type queue, so as to divide N items of the pointer-type queue into a part with an index lower than the head pointer Head and a part with an index not lower than the head pointer Head;
[0007] S102: Perform an AND operation on the input subset flag vector Sub and the mask vector MASK to obtain the result Sub&MASK, and the inverse value ~MASK of the mask vector MASK to obtain the result Sub&~MASK. The width of the subset flag vector Sub is consistent with the depth of the data body of the pointer-type queue. Each item in the data body corresponds to a bit in the subset flag vector Sub, and 1 and 0 are used to distinguish whether it belongs to the specified subset.
[0008] S103, performing fixed-priority arbitration on the result Sub&MASK to generate a vector Oldest_h. If the vector Oldest_h is not all zero, then the vector Oldest_h is output as the oldest item Oldest of the required subset. Otherwise, performing fixed-priority arbitration on the result Sub&~MASK to generate a vector Oldest_l, and then outputting it as the oldest item Oldest of the required subset.
[0009] Optionally, after step S101 and before step S102, the process further includes determining whether the input subset flag vector Sub is all zero. If it is all zero, outputting 0 as the oldest item Oldest of the required subset; otherwise, skipping to step S102.
[0010] Optionally, constructing the mask vector MASK according to the head pointer Head of the pointer-type queue in step S101 includes: initializing an N-bit mask vector MASK, where N is the depth of the pointer-type queue; traversing the N items of the pointer-type queue, and for the I-th item obtained by the traversal, the value range of I is 0-N-1, if I is less than the head pointer Head, then setting the I-th bit MASK[I] of the mask vector MASK to 1; otherwise, setting the I-th bit MASK[I] of the mask vector MASK to 0, and finally obtaining the N-bit mask vector MASK.
[0011] Optionally, in step S103, performing fixed-priority arbitration on the result Sub&MASK to generate the vector Oldest_h includes: scanning the value of the result Sub&MASK from the 0th bit to the N-1th bit, and when the first bit set to 1 is i, setting the i-th bit of the vector Oldest_h to 1, ending and exiting, so that the final vector Oldest_h has only one bit set to 1.
[0012] Optionally, in step S101, performing fixed-priority arbitration on the result Sub&~MASK to generate Oldest_l includes: scanning the value of the result Sub&~MASK from the 0th bit to the N-1th bit, and when the first bit set to 1 is i, setting the i-th bit of the vector Oldest_l to 1, ending and exiting, so that the final vector Oldest_l has only one bit set to 1.
[0013] In addition, the present invention also provides a device for locating the oldest item in a pointer-type queue subset, comprising:
[0014] a mask calculation module, configured to construct a mask vector MASK according to a head pointer Head of the pointer-type queue, so as to divide the N items of the pointer-type queue into a part with an index lower than the head pointer Head and a part with an index not lower than the head pointer Head;
[0015] The first AND operation module is used to perform an AND operation on the input subset flag vector Sub and the mask vector MASK to obtain the result Sub&MASK, where the width of the subset flag vector Sub is consistent with the data body depth of the pointer-type queue. Each item in the data body corresponds to a bit in the subset flag vector Sub, and 1 and 0 are used to distinguish whether it belongs to the specified subset;
[0016] The negation module is used to negate the mask vector MASK to obtain the inverse value ~MASK of the mask vector MASK;
[0017] The second AND operation module is used to perform an AND operation on the input subset flag vector Sub and the inverse value ~MASK of the mask vector MASK to obtain the result Sub&~MASK;
[0018] A first fixed-priority arbiter is used to perform fixed-priority arbitration on the result Sub&MASK to generate a vector Oldest_h;
[0019] The second fixed-priority arbiter is used to perform fixed-priority arbitration on the result Sub&~MASK to generate a vector Oldest_l;
[0020] A judgment module is used to judge whether the vector Oldest_h is not all zeros;
[0021] A selector, configured to select, according to the judgment module, to output the vector Oldest_h or the vector Oldest_l as the oldest item Oldest of the required subset; if the vector Oldest_h is not all zero, then the vector Oldest_h is output as the oldest item Oldest of the required subset; otherwise, the vector Oldest_l is output as the oldest item Oldest of the required subset;
[0022] The output end of the mask calculation module is respectively connected to an input end of the first AND operation module and to an input end of the second AND operation module through the negation module. The other input end of the first AND operation module and the second AND operation module are connected to the external input subset flag vector Sub. The output end of the first AND operation module is connected to an input end of the selector through a first fixed priority arbitrator, and the output end of the second AND operation module is connected to the other input end of the selector through a second fixed priority arbitrator. The control end of the selector is connected to the output end of the judgment module.
[0023] Optionally, a subset flag vector Sub detection module is further included, which is used to determine whether the input subset flag vector Sub is all zero. If it is all zero, 0 is output as the oldest item Oldest of the required subset.
[0024] Optionally, the mask calculation module constructs the mask vector MASK according to the head pointer Head of the pointer type queue, including: initializing the N-bit mask vector MASK, where N is the depth of the pointer type queue; traversing the N items of the pointer type queue, and for the I-th item obtained through the traversal, the value range of I is 0- N-1, if I is less than the head pointer Head, then the I-th bit MASK[I] of the mask vector MASK is set to 1; otherwise, the I-th bit MASK[I] of the mask vector MASK is set to 0, and finally an N-bit mask vector MASK is obtained; the first fixed-priority arbiter performs fixed-priority arbitration on the result Sub&MASK to generate the vector Oldest_h, including: scanning the value of the result Sub&MASK from the 0th bit to the N-1th bit, when the scan finds that the first bit set to 1 is i, then setting the i-th bit of the vector Oldest_h to 1, ending and exiting, so that the finally obtained vector Oldest_h has only one bit set to 1; the second fixed-priority arbiter performs fixed-priority arbitration on the result Sub&~MASK to generate Oldest_l, including: scanning the value of the result Sub&~MASK from the 0th bit to the N-1th bit, when the scan finds that the first bit set to 1 is i, then setting the i-th bit of the vector Oldest_l to 1, ending and exiting, so that the finally obtained vector Oldest_l has only one bit set to 1.
[0025] In addition, the present invention also provides a device for locating the oldest item in a pointer-type queue subset, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the method for locating the oldest item in the pointer-type queue subset.
[0026] In addition, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and the computer program is used to be programmed or configured by a microprocessor to execute the method for locating the oldest item in the pointer-type queue subset.
[0027] Compared with the existing technology, the present invention has the following major advantages: the method includes constructing a mask vector MASK based on the head pointer Head of a pointer-type queue; performing an AND operation on the input subset flag bit vector Sub with the mask vector MASK and its inverse ~MASK, respectively; performing fixed-priority arbitration on the AND operation result Sub&MASK to generate Oldest_h; if Oldest_h is not all zero, it is output as the oldest item in the required subset; otherwise, performing fixed-priority arbitration on the AND operation result Sub&~MASK to generate Oldest_l, which is also output as the oldest item in the required subset. The present invention can efficiently search for the oldest item in a subset of a pointer queue specified by a bit vector, significantly expanding the application scope of pointer-type queues, enabling their application in scenarios where the oldest item in any subset needs to be located. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 Schematic diagram of the process of the embodiment of the present invention.
[0029] Figure 2 Schematic diagram of the structure of the device according to the embodiment of the present invention. DETAILED DESCRIPTION
[0030] The technical problem to be solved by the present invention is how to efficiently find the oldest item in a subset of a pointer queue. That is, for a pointer queue with a memory bank depth of N items, the input of this problem is an N-bit subset flag bit vector Sub, each bit corresponds to an item in the memory bank, and a bit with a value of 1 indicates that the corresponding item belongs to the subset. The output of this problem is an N-bit vector Oldest, in which only one bit is 1, and the data item corresponding to this bit is the oldest item in the data item subset represented by the input vector. Figure 1 As shown, the method for locating the oldest item in the pointer-type queue subset in this embodiment includes:
[0031] S101, construct a mask vector MASK according to the head pointer Head of the pointer-type queue, so as to divide the N items of the pointer-type queue into a part with an index lower than the head pointer Head and a part with an index not lower than the head pointer Head, so that the input vector can be divided into two parts according to the positions of the head and tail pointers to find the oldest item respectively; for example, for a pointer-type queue with a depth of 4, if the head pointer Head=2 and the tail pointer Tail=1, then the mask vector MASK=4'b1100, if the head pointer Head=1 and the tail pointer Tail=2, then the mask vector MASK=4'b1100.
[0032] S102, perform an AND operation on the input subset flag vector Sub and the mask vector MASK to obtain the result Sub&MASK, and the inverse value ~MASK of the mask vector MASK to obtain the result Sub&~MASK. The subset of the pointer-type queue can be determined using the subset flag vector Sub. The width of the subset flag vector Sub is consistent with the depth of the data body of the pointer-type queue. Each item of the data body corresponds to a bit in the subset flag vector Sub, and 1 and 0 are used to distinguish whether it belongs to the specified subset. For example, if the bit is 1, it means that the data item belongs to the subset, otherwise the data item does not belong to the subset. For example, for a pointer-type queue with a depth of 4, if the head pointer Head = 2, the tail pointer Tail = 1, and the subset flag vector Sub = 4'b0101, then the mask vector MASK = 4'b1100, the result Sub&MASK = 4'b0100, and the result Sub&~MASK = 4'b0001.
[0033] In S103, perform fixed-priority arbitration on the result Sub&MASK to generate the vector Oldest_h. If the vector Oldest_h is not all zeros, then output the vector Oldest_h as the oldest item Oldest of the required subset. Otherwise, perform fixed-priority arbitration on the result Sub&~MASK to generate the vector Oldest_l and output it as the oldest item Oldest of the required subset. For example, for a pointer queue with a depth of 4, if the head pointer Head = 2, the tail pointer Tail = 1, the subset flag vector Sub = 4’b0101, then the mask vector MASK = 4’b1100, the result Sub&MASK = 4’b0100, the result Sub&~MASK = 4’b0001, the vector Oldest_h = 4’b0100, and the vector Oldest_l = 4’b0001.
[0034] See Figure 1 , after step S101 and before S102, it also includes determining whether the input subset flag vector Sub is all zeros. If it is all zeros, then output 0 as the oldest item Oldest of the required subset; otherwise, jump to step S102.
[0035] In step S101 of this embodiment, constructing the mask vector MASK according to the head pointer Head of the pointer queue includes: initializing the N-bit mask vector MASK, where N is the depth of the pointer queue; traversing the N items of the pointer queue. For the I-th item obtained by traversing, where the value range of I is 0 - N-1, if I is less than the head pointer Head, then set the I-th bit MASK[I] of the mask vector MASK to 1, otherwise set the I-th bit MASK[I] of the mask vector MASK to 0, and finally obtain the N-bit mask vector MASK. That is: for each I (value range 0 - N-1), if I < Head, then set MASK[I] = 1, otherwise MASK[I] = 0.
[0036] In step S103 of this embodiment, performing fixed-priority arbitration on the result Sub&MASK to generate the vector Oldest_h includes: scanning the value of the result Sub&MASK from the 0th bit to the (N-1)th bit. When the first bit that is 1 is scanned as i, then set the i-th bit of the vector Oldest_h to 1, end and exit, so that the finally obtained vector Oldest_h has only one bit as 1. It can be expressed as: scan the value of Sub&MASK from the 0th bit to the (N-1)th bit. Let the first bit that is 1 be I, then Oldest_h[i] = 1.
[0037] In step S101 of this embodiment, fixed-priority arbitration is performed on the result Sub&~MASK to generate Oldest_l, including: scanning the value of the result Sub&~MASK from bit 0 to bit N-1, and when the first bit set to 1 is i, setting the i-th bit of the vector Oldest_l to 1, ending and exiting, so that the final vector Oldest_l has only one bit set to 1; scanning the value of Sub&~MASK from bit 0 to bit N-1, and setting the first bit set to 1 to 1, then Oldest_l[i]=1.
[0038] In summary, the method for locating the oldest item in a pointer-type queue subset in this embodiment is designed for a pointer-type queue with a maximum depth of N. The head pointer (Head) of the pointer-type queue is calculated to obtain an N-bit classified mask vector MASK. Among all bits of this mask vector MASK, the values at index positions lower than Head are 0, and the values at other index positions are 1. The subset flag bit vector Sub is ANDed with MASK and ~MASK respectively, and then sent to two fixed-priority arbiters to obtain two arbitration results, Oldest_h and Oldest_l. If Oldest_h is 0, Oldest = ldest_l is output; otherwise, Oldest = ldest_h is output. The method for locating the oldest item in a pointer-type queue subset in this embodiment can efficiently realize the search for the oldest item in a subset of a pointer queue specified by a bit vector, greatly expanding the application scope of pointer-type queues, enabling their application in scenarios where the oldest item in any subset needs to be located.
[0039] When implementing the circuit design for the method for locating the oldest item in a pointer-type queue subset according to this embodiment, for a pointer-type queue with a maximum depth of N, a mask calculation module for the mask vector MASK is designed to ensure that the value of the mask vector MASK meets the requirements described above. This module also coordinates with two fixed-priority arbiters to perform fixed-priority arbitration on the results Sub&MASK and Sub&~MASK to locate the oldest item in the subset indicated by the input vector Sub. Furthermore, the circuit design for the method for locating the oldest item in a pointer-type queue subset according to this embodiment requires receiving two signal inputs: Sub and Head. Head is used to generate a subset grouping mask MASK. Sub is ANDed with MASK and ~MASK, respectively, and input to the two fixed-priority arbiters. The arbitration results (Oldest_h and Oldest_l) of the two fixed-priority arbiters are input to a two-way selector. This selector selects one of the two as the Oldest output by determining whether Oldest_h is all zeros.
[0040] like Figure 2 As shown, this embodiment further provides a device for locating the oldest item in a pointer-type queue subset, including:
[0041] The mask calculation module (indicated by MASK[I]=Head>=i in the figure) is used to construct a mask vector MASK based on the head pointer Head of the pointer-type queue, so as to divide the N items of the pointer-type queue into a part with an index lower than the head pointer Head and a part with an index not lower than the head pointer Head;
[0042] The first AND operation module (marked as AND in the figure) is used to perform an AND operation on the input subset flag vector Sub and the mask vector MASK to obtain the result Sub&MASK, where the width of the subset flag vector Sub is consistent with the data body depth of the pointer-type queue. Each item in the data body corresponds to a bit in the subset flag vector Sub, and 1 and 0 are used to distinguish whether it belongs to the specified subset;
[0043] The negation module is used to negate the mask vector MASK to obtain the inverse value ~MASK of the mask vector MASK;
[0044] The second AND operation module (marked as AND in the figure) is used to perform an AND operation on the input subset flag vector Sub and the inverse value ~MASK of the mask vector MASK to obtain the result Sub&~MASK;
[0045] A first fixed-priority arbiter is used to perform fixed-priority arbitration on the result Sub&MASK to generate a vector Oldest_h;
[0046] The second fixed-priority arbiter is used to perform fixed-priority arbitration on the result Sub&~MASK to generate a vector Oldest_l;
[0047] A judgment module is used to judge whether the vector Oldest_h is not all zeros;
[0048] The selector (marked as Mux in the figure) is used to select the vector Oldest_h or the vector Oldest_l as the oldest item Oldest of the required subset according to the judgment module. If the vector Oldest_h is not all zeros, the vector Oldest_h is output as the oldest item Oldest of the required subset; otherwise, the vector Oldest_l is output as the oldest item Oldest of the required subset;
[0049] The output end of the mask calculation module is respectively connected to an input end of the first AND operation module and to an input end of the second AND operation module through the negation module. The other input end of the first AND operation module and the second AND operation module are connected to the external input subset flag vector Sub. The output end of the first AND operation module is connected to an input end of the selector through a first fixed priority arbitrator, and the output end of the second AND operation module is connected to the other input end of the selector through a second fixed priority arbitrator. The control end of the selector is connected to the output end of the judgment module.
[0050] This embodiment further includes a subset flag vector Sub detection module, which is used to determine whether the input subset flag vector Sub is all zero. If it is all zero, 0 is output as the oldest item Oldest of the required subset.
[0051] In this embodiment, the mask calculation module constructs the mask vector MASK according to the head pointer Head of the pointer-type queue, including: initializing the N-bit mask vector MASK, where N is the depth of the pointer-type queue; traversing the N items of the pointer-type queue, and for the I-th item obtained through the traversal, I has a value range of 0-N-1. If I is less than the head pointer Head, the I-th bit MASK[I] of the mask vector MASK is set to 1; otherwise, the I-th bit MASK[I] of the mask vector MASK is set to 0, and finally an N-bit mask vector MASK is obtained. Figure 2 It is expressed as MASK[I]=Head>=i; the first fixed-priority arbiter performs fixed-priority arbitration on the result Sub&MASK to generate the vector Oldest_h, including: scanning the value of the result Sub&MASK from the 0th bit to the N-1th bit, and when the scan finds that the first bit set to 1 is i, then setting the i-th bit of the vector Oldest_h to 1, ending and exiting, so that the final vector Oldest_h has only one bit set to 1; the second fixed-priority arbiter performs fixed-priority arbitration on the result Sub&~MASK to generate Oldest_l, including: scanning the value of the result Sub&~MASK from the 0th bit to the N-1th bit, and when the scan finds that the first bit set to 1 is i, then setting the i-th bit of the vector Oldest_l to 1, ending and exiting, so that the final vector Oldest_l has only one bit set to 1.
[0052] In addition, this embodiment also provides a device for locating the oldest item in a pointer-type queue subset, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the method for locating the oldest item in the pointer-type queue subset.
[0053] In addition, this embodiment further provides a computer-readable storage medium, in which a computer program is stored. The computer program is used to be programmed or configured by a microprocessor to execute the method for locating the oldest item in the pointer-type queue subset.
[0054] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiment. All technical solutions based on the concept of the present invention are within the scope of protection of the present invention. It should be noted that for those skilled in the art, various improvements and modifications that do not depart from the principles of the present invention should also be considered within the scope of protection of the present invention.
Claims
1. A method for locating the oldest item in a pointer-type queue subset, characterized in that: include: S101, constructing a mask vector MASK according to a head pointer Head of a pointer-type queue, so as to divide N items of the pointer-type queue into a part with an index lower than the head pointer Head and a part with an index not lower than the head pointer Head; S102: Perform an AND operation on the input subset flag vector Sub and the mask vector MASK to obtain the result Sub & MASK, and the inverse value ~ MASK of the mask vector MASK to obtain the result Sub & ~ MASK. The width of the subset flag vector Sub is consistent with the depth of the data body of the pointer-type queue. Each item in the data body corresponds to a bit in the subset flag vector Sub, and 1 and 0 are used to distinguish whether it belongs to the specified subset. S103, performing fixed-priority arbitration on the result Sub & MASK to generate a vector Oldest_h. If the vector Oldest_h is not all zeros, the vector Oldest_h is output as the oldest item Oldest of the required subset. Otherwise, performing fixed-priority arbitration on the result Sub & ~MASK to generate a vector Oldest_l, which is output as the oldest item Oldest of the required subset.
2. The method for locating the oldest item in a pointer-type queue subset according to claim 1, characterized in that: After step S101 and before step S102, the process further includes determining whether the input subset flag vector Sub is all zero. If it is all zero, outputting 0 as the oldest item Oldest of the required subset. Otherwise, jump to step S102.
3. The method for locating the oldest item in a pointer-type queue subset according to claim 1, wherein: In step S101, constructing a mask vector MASK according to the head pointer Head of the pointer-type queue includes: initializing an N-bit mask vector MASK, where N is the depth of the pointer-type queue; traversing the N items of the pointer-type queue, and for the I-th item obtained through the traversal, I has a value in the range of 0-N-1. If I is less than the head pointer Head, the I-th bit MASK[I] of the mask vector MASK is set to 1; otherwise, the I-th bit MASK[I] of the mask vector MASK is set to 0, thereby finally obtaining an N-bit mask vector MASK.
4. The method for locating the oldest item in a pointer-type queue subset according to claim 1, wherein: In step S103, fixed-priority arbitration is performed on the result Sub & MASK to generate the vector Oldest_h. The process includes scanning the value of the result Sub & MASK from bit 0 to bit N-1. When the first bit set to 1 is i, the i-th bit of the vector Oldest_h is set to 1, and the process ends and exits, so that the final vector Oldest_h has only one bit set to 1.
5. The method for locating the oldest item in a pointer-type queue subset according to claim 1, wherein: In step S101, fixed-priority arbitration is performed on the result Sub & ~MASK to generate Oldest_1, which includes scanning the value of the result Sub & ~MASK from bit 0 to bit N-1. When the first bit set to 1 is i, the i-th bit of the vector Oldest_1 is set to 1, and the process ends and exits, so that the final vector Oldest_1 has only one bit set to 1.
6. A device for locating the oldest item in a pointer-type queue subset, characterized in that: include: a mask calculation module, configured to construct a mask vector MASK according to a head pointer Head of the pointer-type queue, so as to divide the N items of the pointer-type queue into a part with an index lower than the head pointer Head and a part with an index not lower than the head pointer Head; The first AND operation module is used to perform an AND operation on the input subset flag vector Sub and the mask vector MASK to obtain the result Sub & MASK, where the width of the subset flag vector Sub is consistent with the data body depth of the pointer-type queue. Each item in the data body corresponds to a bit in the subset flag vector Sub, and 1 and 0 are used to distinguish whether it belongs to the specified subset; The negation module is used to negate the mask vector MASK to obtain the inverse value ~MASK of the mask vector MASK; The second AND operation module is used to perform an AND operation on the input subset flag vector Sub and the inverse value ~MASK of the mask vector MASK to obtain the result Sub & ~MASK; A first fixed-priority arbiter is used to perform fixed-priority arbitration on the result Sub & MASK to generate a vector Oldest_h; The second fixed-priority arbiter is used to perform fixed-priority arbitration on the result Sub & ~MASK to generate a vector Oldest_l; A judgment module is used to judge whether the vector Oldest_h is not all zeros; A selector, configured to select, according to the judgment module, to output the vector Oldest_h or the vector Oldest_l as the oldest item Oldest of the required subset; if the vector Oldest_h is not all zero, then the vector Oldest_h is output as the oldest item Oldest of the required subset; otherwise, the vector Oldest_l is output as the oldest item Oldest of the required subset; The output end of the mask calculation module is respectively connected to an input end of the first AND operation module and to an input end of the second AND operation module through the negation module. The other input end of the first AND operation module and the second AND operation module are connected to the external input subset flag vector Sub. The output end of the first AND operation module is connected to an input end of the selector through a first fixed priority arbitrator, and the output end of the second AND operation module is connected to the other input end of the selector through a second fixed priority arbitrator. The control end of the selector is connected to the output end of the judgment module.
7. The device for locating the oldest item in a pointer-type queue subset according to claim 6, characterized in that: It also includes a subset flag vector Sub detection module, which is used to determine whether the input subset flag vector Sub is all zero. If it is all zero, 0 is output as the oldest item Oldest of the required subset.
8. The device for locating the oldest item in a pointer-type queue subset according to claim 7, wherein: The mask calculation module constructs a mask vector MASK according to the head pointer Head of the pointer-type queue, including: initializing an N-bit mask vector MASK, where N is the depth of the pointer-type queue; traversing the N items of the pointer-type queue, and for the traversed item I, the value range of I is 0-N-1, if I is less than the head pointer Head, setting the value of the I-th bit MASK[I] of the mask vector MASK to 1, otherwise setting the value of the I-th bit MASK[I] of the mask vector MASK to 0, and finally obtaining an N-bit mask vector MASK; the first fixed-priority arbiter performs fixed-priority arbitration on the result Sub & MASK to generate a vector Oldest_h, including: scanning the value of the result Sub & MASK from the 0th bit to the N-1th bit, when the scan finds that the first bit set to 1 is i, setting the i-th bit of the vector Oldest_h to 1, ending and exiting, so that the final vector Oldest_h has only one bit set to 1; the second fixed-priority arbiter performs fixed-priority arbitration on the result Sub & ~MASK to generate Oldest_l, including: The value of ~MASK is scanned from bit 0 to bit N-1. When the first bit set to 1 is i, the i-th bit of the vector Oldest_l is set to 1, and the process ends and exits, so that the final vector Oldest_l has only one bit set to 1.
9. A device for locating the oldest item in a pointer-type queue subset, comprising a microprocessor and a memory connected to each other, characterized in that: The microprocessor is programmed or configured to execute the method for locating the oldest item in the pointer-type queue subset according to any one of claims 1 to 5.
10. A computer-readable storage medium storing a computer program, wherein: The computer program is used to be programmed or configured by a microprocessor to execute the method for locating the oldest item in a pointer-type queue subset as claimed in any one of claims 1 to 5.
Citation Information
Patent Citations
Memory based method for searching quickly the longest matching of IP address
CN101043421A
Write-in cache circuit, data write-in method and memory
CN115994102A