Tri-state content addressable memory and method of updating the same

By optimizing the storage structure in TCAM to ensure that each layer has free space and using storage entry adjustment operations, the efficiency and accuracy issues of TCAM during the update process are solved, and efficient matching results are achieved under real-time changes.

CN116149562BActive Publication Date: 2025-11-07XIAMEN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310149594.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-02-22
Publication Date
2025-11-07
Estimated Expiration
2043-02-22

AI Technical Summary

Technical Problem

TCAM affects search efficiency and may output incorrect matching results during the storage entry update process, especially in real-time changing data environments, which existing technologies find difficult to effectively solve.

Method used

By adjusting storage entries, we ensure that each storage layer has free backup storage space, optimize the storage structure, reduce storage overflow, and use methods such as bubble sort to determine urgency and gradually adjust storage entries to ensure that each layer has free space to support real-time changes.

Benefits of technology

By reducing the impact of storage entry updates on efficiency during the TCAM lookup process, ensuring the correctness of matching results, reducing the risk of storage overflow, and improving lookup efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116149562B_ABST
    Figure CN116149562B_ABST
Patent Text Reader

Abstract

The application provides a method for updating a ternary content-addressable memory, comprising a storage entry adjustment operation, the storage entry adjustment operation comprising the following steps: calculating the urgency of each storage layer, determining a storage layer to be adjusted according to the urgency, then dividing an idle storage unit in the main storage space of a first adjacent storage layer to the storage layer to be adjusted, and repeating the above steps until the urgency of each storage layer is 0. Accordingly, the application also provides a ternary content-addressable memory having a first processing module for implementing the storage entry adjustment operation, which can implement the above updating method. Through the above updating method of the ternary content-addressable memory, the influence of the updating process of the storage entry on the search efficiency can be greatly reduced, and a correct matching result can be output.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of memory, in particular to a ternary content addressable memory and an updating method thereof. BACKGROUND

[0002] With the rapid development of the Internet, the number of nodes in the network has increased significantly, and the requirement for the interface rate of the router is also increasing, for example, the single packet forwarding processing time of the router supporting 10G rate has been required to be less than 50 nanoseconds, and the software routing lookup mechanism obviously cannot meet the line speed forwarding requirement. Since the ternary content addressable memory (TCAM) has fast lookup table speed and solves the problem of CIDR longest prefix matching, it has become the current hardware solution in the industry.

[0003] However, the defects of TCAM are also very obvious. Due to the ambiguous lookup of TCAM, a large number of addresses may be output in a matching data process. The usual processing method is to store all the TCAM internal storage entries according to the priority from low to high from the low bit of the address to the high bit. If multiple matching results are output at a time, the comparator of the TCAM output position will take the low address result as the standard. This solution method brings a new problem, the data to be matched in the network and computer system are changing in real time, which means that the storage entries stored in our TCAM need to change in real time, otherwise it may cause the matching result to be wrong. Moreover, the change of the storage entries must comply with the priority order of the storage entries in the TCAM, otherwise the matching result will also be wrong. If the time required for updating and sorting the storage entries in the TCAM is too long, the efficiency of the lookup process will be affected.

[0004] Therefore, how to reduce the impact of the TCAM in the process of updating the storage entries on the lookup efficiency and output the correct matching result is one of the research hotspots in the field. SUMMARY

[0005] In order to solve the above technical problems, the present application provides an updating method of a ternary content addressable memory, by performing a storage entry adjustment operation, to ensure that each storage layer has free backup storage space, so as to reduce the storage overflow when the storage entries change in real time, thereby ensuring that the storage entries of the TCAM can change in real time, and further improving the correctness of the output matching result.

[0006] The present application provides an updating method of a ternary content addressable memory, including a storage entry adjustment operation, wherein the storage entry adjustment operation includes the following steps:

[0007] S110, calculating an urgency degree of the i-th storage layer for the storage entry adjustment operation according to a number of idle storage units in the main storage space of the first adjacent storage layer, a number of idle storage units in the backup storage space of the i-th storage layer, and whether at least one storage unit in the backup storage space of the second adjacent storage layer stores a storage entry;

[0008] wherein the urgency degree of the i-th storage layer is 0 when the main storage space of the first adjacent storage layer has no idle storage unit or the main storage space of the i-th storage layer has idle storage units;

[0009] wherein the first adjacent storage layer and the second adjacent storage layer are one of the i+1-th storage layer and the i-1-th storage layer respectively;

[0010] S120, determining a storage layer to be adjusted, the storage layer to be adjusted being the i-th storage layer with the largest urgency degree;

[0011] S130, dividing one idle storage unit in the main storage space of the first adjacent storage layer to the storage layer to be adjusted; and

[0012] S140, repeating S120 and S130 until the urgency degree of each storage layer is 0.

[0013] In the above technical solution, the storage layer can perform the storage entry adjustment operation, and with the storage entry adjustment operation, the structure of the storage space is continuously optimized, and the storage units of the storage layer with less frequently used priority are continuously incorporated into the storage layer with more frequently used priority. Meanwhile, each storage layer has a certain number of backup storage spaces, so as to realize real-time change of the storage entry and prevent matching result error output caused by storage overflow.

[0014] wherein since the TCAM can move at most one storage entry each time, the storage layer with the largest urgency degree is preferentially subjected to the storage entry adjustment operation when the storage entry adjustment operation is performed, so as to maximize the effect of the storage entry adjustment operation.

[0015] In some possible implementation manners, the i+1-th storage layer is taken as the first adjacent storage layer, the i-1-th storage layer is taken as the second adjacent storage layer, the first urgency degree is calculated, the i-1-th storage layer is taken as the first adjacent storage layer, the i+1-th storage layer is taken as the second adjacent storage layer, the second urgency degree is calculated, and the urgency degree is the larger one of the first urgency degree and the second urgency degree;

[0016] when the urgency degree is the first urgency degree, the operation of S130 is to divide one idle storage unit in the main storage space of the i+1-th storage layer to the storage layer to be adjusted;

[0017] When the urgency level is the second urgency level, the operation of S130 is to allocate one free storage unit in the main storage space of the i-1th storage layer to the storage layer to be adjusted.

[0018] In the technical solution, the urgency levels of the i-th storage layer are calculated with the two adjacent storage layers of the i-th storage layer as the first adjacent storage layers, and the greater value is taken to determine the better direction of the i-th storage layer to perform the storage entry adjustment operation, thereby reducing the frequency of the storage entry adjustment operation in the long-term use of the TCAM.

[0019] In some possible implementation manners, when the urgency level is the first urgency level, the operation of allocating one free storage unit in the main storage space of the first adjacent storage layer to the storage layer to be adjusted is to move the storage entry with the highest storage address in the i-th storage layer to the free storage unit with the highest address in the i-1th storage layer, and modify the priority of the free storage unit with the highest address in the i-1th storage layer to the priority of the i-th storage layer.

[0020] When the urgency level is the second urgency level, the operation of allocating one free storage unit in the main storage space of the first adjacent storage layer to the storage layer to be adjusted is to move the storage entry with the lowest storage address in the i+1th storage layer to the free storage unit with the lowest address in the i+1th storage layer, and modify the priority of the free storage unit with the lowest address in the i+1th storage layer to the priority of the i-th storage layer.

[0021] In the technical solution, when the urgency level is the first urgency level, the i-th storage layer is adjusted to the i-1th storage space, and when the urgency level is the second urgency level, the i-th storage layer is adjusted to the i+1th storage space. In the two cases, only one storage entry is moved, the operation amount is small, and the operation can be completed quickly.

[0022] In a possible implementation manner, S120 further includes: before the operation of determining the storage layer to be adjusted, sorting the storage layers according to the urgency levels of the storage layers from large to small.

[0023] In the technical solution, the urgency levels of the storage layers are sorted, and then the storage entry adjustment operation is performed on the storage layers in sequence, which can reduce the calculation amount of selecting the storage layer to be adjusted and improve the efficiency of the storage entry adjustment operation. The sorting method of the urgency levels includes, but is not limited to, insertion sort, merge sort, counting sort and bubble sort.

[0024] In a possible implementation manner, the method of sorting the storage layers is bubble sort.

[0025] In the technical solution, the bubble sort has low space complexity, and the storage layer is sorted according to the urgency by the bubble sort method, so that the temporarily occupied space is small and the stability is high.

[0026] In a possible implementation, the updating method of the ternary content-addressable memory further includes a storage entry replacement operation, a storage entry deletion operation and a storage entry insertion operation.

[0027] The storage entry replacement operation on the i-th storage layer includes the following steps:

[0028] The storage entry deletion operation on the i-th storage layer includes the following steps:

[0029] S210, determine the storage location of the storage entry to be deleted, if the storage entry to be deleted is stored in the backup storage space of the i-th storage layer, execute S220, if the storage entry to be deleted is stored in the main storage space of the i-th storage layer, execute S230;

[0030] S220, delete the storage entry to be deleted, and then move the storage entry with the highest storage address in the i-th storage layer to the storage unit storing the storage entry to be deleted;

[0031] S230, delete the storage entry to be deleted, and then move the storage entry with the highest storage address in the i-th storage layer to the storage unit storing the storage entry to be deleted, and then move the backup storage space of the i-th storage layer to the direction of the lower address by one storage unit;

[0032] The storage entry insertion operation on the i-th storage layer includes the following steps:

[0033] S310, determine whether there is a free storage unit in the main storage space of the i-th storage layer, if yes, execute S321, otherwise execute S322;

[0034] S321, insert the storage entry to be inserted into the lowest free storage unit in the i-th storage layer, and move the backup storage space of the i-th storage layer to the direction of the higher address by one storage unit;

[0035] S322, insert the storage entry to be inserted into the lowest free storage unit in the i-th storage layer.

[0036] In the technical solution, the storage entry replacement operation only deletes one storage entry, then inserts a new storage entry, the storage entry deletion operation only deletes one storage entry, and the storage entry insertion operation only inserts one storage entry, all of which only involve operations on one or two storage entries, and the workload is less, and for TCAM, the operations can be completed in an instant, thus, the storage entry replacement operation, the storage entry deletion operation and the storage entry insertion operation can be performed at the same time as the TCAM performs the lookup operation without affecting the lookup efficiency, and the correctness of the output matching result can be ensured.

[0037] In a possible implementation, each storage layer is configured with three pointers Ppro[i], Pbot[i] and Ptop[i], wherein Ppro[i] points to the highest address of the backup storage space, Pbot[i] points to the highest address of the storage entry, and Ptop[i] points to the lowest address of the storage entry.

[0038] In a possible implementation, each storage layer is configured with two flags Dang[i] and Valid[i];

[0039] Valid[i] is used to determine whether the i-th main storage space is full, and the condition for determining true is Ppro[i]+1=Ptop[i+1];

[0040] Dang[i] is used to determine whether the i-th backup storage space stores at least one storage entry, and the condition for determining true is Ppro[i]-Pbot[i]<L.

[0041] In the technical solution, by configuring the three pointers Ppro[i], Pbot[i] and Ptop[i] and the two flags Dang[i] and Valid[i], the storage condition in the storage layer can be obtained more conveniently, the calculation amount when determining the storage condition in each operation in the updating method is reduced, and the updating efficiency is improved.

[0042] Correspondingly, the application also provides a ternary content addressable memory, comprising a first processing module, configured to implement the storage entry adjustment operation.

[0043] The ternary content addressable memory can implement the storage entry adjustment operation, has a better storage structure, and can output correct matching results.

[0044] In a possible implementation, the ternary content-addressable memory further comprises a second processing module and a third processing module, the second processing module is configured to perform a storage entry insertion operation, a storage entry replacement operation, and a storage entry deletion operation, and the third processing module is configured to query the storage entries stored in the ternary content-addressable memory.

[0045] When the third processing module is in the working state, the second processing module can simultaneously perform the storage entry insertion operation, the storage entry replacement operation, and / or the storage entry deletion operation.

[0046] When the third processing module is in the dormant state, the first processing module automatically performs the storage entry adjustment operation.

[0047] In the above technical solution, the first processing module is configured to automatically perform the storage entry adjustment operation when the third processing module is in the dormant state. When the third processing module performs the lookup, the storage entry may be inserted into the backup storage space multiple times. The above technical solution moves the storage entry in the backup storage space in batches during the non-lookup period, thereby reducing the number of operations.

[0048] Compared with the prior art, the updating method of the ternary content-addressable memory provided in the present application has a small amount of storage entry adjustment operation, and can be completed in the lookup state without the need to specially stop the lookup for adjustment. In addition, the storage entry adjustment operation ensures that each storage layer has a certain amount of free storage space in the backup storage space, thereby ensuring that the storage entry changes in real time during the lookup process and preventing the problem of storage overflow. Through the above updating method, the influence of the updating process of the storage entry on the lookup efficiency can be greatly reduced, and the correct matching result can be output.

[0049] Further, the storage entry replacement operation, the storage entry deletion operation, and the storage entry insertion operation also have the advantage of small operation amount, and can be completed instantaneously, so that the TCAM can perform the lookup at the same time without affecting the lookup efficiency.

[0050] In addition, since the storage units in the relatively free storage layer are continuously divided into the storage layer with more storage entries, the structure of the storage space can be dynamically optimized, and each storage layer has a certain amount of free storage space after adjustment, thereby preventing the time required for the storage entry adjustment operation from increasing over time. BRIEF DESCRIPTION OF DRAWINGS

[0051] The accompanying drawings are included to provide a further understanding of embodiments and are incorporated in and constitute a part of this specification. The drawings illustrate embodiments and, together with the description, serve to explain principles of the present application. Other embodiments and many of the intended advantages of the present application will be readily appreciated as the same becomes better understood by reference to the following detailed description. The elements of the drawings are not necessarily to scale relative to each other. Like reference numerals designate corresponding similar parts.

[0052] Figure 1 A schematic diagram of a structure of a storage space in one embodiment of the present application;

[0053] Figure 2 A schematic diagram of an operation of a storage entry replacement operation in one embodiment of the present application;

[0054] Figure 3a and Figure 3b A schematic diagram of an operation of a storage entry deletion operation in one embodiment of the present application;

[0055] Figure 4a and Figure 4b A schematic diagram of an operation of a storage entry insertion operation in one embodiment of the present application;

[0056] Figure 5 A flowchart of a bubble sort of urgency in one embodiment of the present application;

[0057] Figure 6 A schematic diagram of an operation of an upward adjustment in a storage entry adjustment operation in one embodiment of the present application;

[0058] Figure 7 A schematic diagram of an operation of a downward adjustment in a storage entry adjustment operation in one embodiment of the present application. DETAILED DESCRIPTION

[0059] In the following detailed description, reference is made to the accompanying drawings, which form a part hereof, and in which are shown by way of illustration illustrative embodiments in which the application can be practiced. For purposes of explanation and illustration, directional terms are used with reference to the orientation of the described figures. Because embodiments of the storage space can be positioned in a number of different orientations, the directional terminology is used with reference to the orientation of the figures as placed on a page, as it is intended for purposes of illustration and discussion. It is understood that other embodiments can be utilized and logical changes can be made without departing from the scope of the present application. The following detailed description is, therefore, not to be taken in a limiting sense, and the scope of the present application is defined by the appended claims.

[0060] A ternary content-addressable memory includes a storage module, a first processing module, a second processing module, and a third processing module.

[0061] The storage space of the storage module is initialized, as shown in the following table. Figure 1 The storage space includes S storage layers with priority i (0≤i

[0062] The first processing module is configured to perform a storage entry adjustment operation.

[0063] The second processing module is configured to perform a storage entry insertion operation, a storage entry replacement operation, and a storage entry deletion operation on the storage module.

[0064] The third processing module is configured to query the storage entries stored in the storage module.

[0065] When the third processing module is in a working state, the second processing module can simultaneously perform the storage entry insertion operation, the storage entry replacement operation, and / or the storage entry deletion operation.

[0066] Each storage layer is configured with three pointers, Ptop[i], Pbot[i], and Ppro[i], which respectively point to the lowest address of the storage entries, the highest address of the storage entries, and the highest address of the backup storage space. When the storage layer does not store the storage entries, Ptop[i]=Pbot[i]=i*N / S, and Ppro[i]=i*(N / S)+L, where Ptop[i] and Pbot[i] point to the storage unit with the lowest address in the ith storage layer.

[0067] In addition, in this embodiment, each storage layer is further configured with two flags, Dang[i] and Valid[i]. Among them, Valid[i] is used to determine whether the i-th main storage space is full. The determination condition is Ppro[i]+1 = Ptop[i+1], that is, whether the highest address of the spare storage space of this segment is adjacent to the lowest address of the main storage space of the next segment. If the condition is true, the value is 1; if the condition is false, the value is false. Dang[i] is used to determine whether there is at least one storage entry stored in the i-th spare storage space. The determination condition is Ppro[i]-Pbot[i]<L, that is, whether the number of storage units between the highest address of the spare storage space and the highest address of the storage entry with a stored entry is less than L. If the condition is true, the value is 1; if the condition is false, the value is false.

[0068] The real-time changes of TCAM storage entries include storage entry replacement operations, storage entry deletion operations, and storage entry insertion operations.

[0069] When a storage entry replacement operation is required, as Figure 2 shown, assuming that the storage entry 2 in the i-th storage layer needs to be replaced, only need to delete the storage entry 2 and insert the storage entry to be replaced into the storage unit that originally stored the storage entry 2. At this time, the three pointers Ptop[i], Pbot[i], and Ppro[i] all remain unchanged. In the above storage entry replacement operation, only the deleted storage entry and the storage entry to be replaced are deleted or inserted, and no other storage entries are involved in the operation.

[0070] The storage entry deletion operation includes the following steps:

[0071] S210. First, determine whether there is a storage entry stored in the spare storage space, that is, whether Dang[i] is 1. If there is no storage entry stored in the spare storage space, execute S221; otherwise, execute S222.

[0072] S221. As Figure 3a shown, if there is no storage entry stored in the spare storage space, delete the storage entry 2 that needs to be deleted, and then move the storage entry 4 with the highest storage address to the storage unit that originally stored the storage entry 2, and let Pbot[i] and Ppro[i] move up one storage unit respectively.

[0073] S222. As Figure 3b shown, if there is a storage entry stored in the spare storage space, delete the storage entry 2 that needs to be deleted, and then move the storage entry 5 with the highest storage address to the storage unit that originally stored the storage entry 2. Then let Pbot[i] move up one storage unit while Ppro[i] remains unchanged, which is equivalent to clearing one storage unit of the spare storage space after deleting the storage entry 2.

[0074] In the above storage entry deletion operation, only the storage entry to be deleted and the storage entry with the highest storage address are deleted or moved, and no operation is performed on other storage entries.

[0075] The storage entry insertion operation includes the following steps:

[0076] S310, determine whether the main storage space of the i-th storage layer to be inserted is full, i.e., whether Valid[i] is 1. If the value of Valid[i] is false, perform S311, otherwise perform S312;

[0077] S321, as shown in the following formula, the storage entry to be inserted is inserted into the storage unit with the lowest address, and Pbot[i] and Ppro[i] are moved down one storage unit respectively. Figure 4a

[0078] S322, as shown in the following formula, the storage entry to be inserted is inserted into the storage unit with the lowest address, and Pbot[i] is moved down one storage unit while Ppro[i] remains unchanged, which is equivalent to inserting the storage entry to be inserted into the standby storage space. Figure 4b

[0079] In the above storage entry insertion operation, only the storage entry to be inserted is inserted, and no operation is performed on other storage entries.

[0080] The above storage entry replacement operation, storage entry deletion operation and storage entry insertion operation have small operation amount, so that they can be quickly performed while the TCAM is searching, and the output correct matching result is ensured without affecting the TCAM search efficiency.

[0081] However, if only the above storage entry replacement operation, storage entry deletion operation and storage entry insertion operation are performed, over time, a situation may occur that some storage layers are full of storage while other storage layers still have many free storage units. Therefore, the storage structure needs to be optimized by the storage entry adjustment operation, so that the standby storage space of each storage layer has a certain free storage unit.

[0082] The operation of the storage entry adjustment operation is to move the storage entry in the standby storage space to the main storage space of the previous or next storage layer.

[0083] ​​Specifically, the storage entry adjustment operation needs to be assisted by three functions Max, Dire and Ran, wherein Max is used to represent the urgency of the storage layer to perform the storage entry adjustment operation, the greater Max(i) is, the more the storage layer needs to perform the storage entry adjustment operation, if Max(i)=0, it represents that the storage layer does not need to be adjusted, Dire(i) represents the moving direction of the storage layer to be adjusted, and Ran(i) represents the priority of the storage layer.

[0084] Wherein, Max(i) is taken from max0(i) or max1(i), and when Max(i)=max0(i), Dire(i)=0, the i-th storage layer is adjusted downward, that is, an idle storage unit in the main storage space of the i+1-th storage layer is divided to the storage layer to be adjusted, when Max(i)=max1(i), Dire(i)=1, the i-th storage layer is adjusted upward, that is, an idle storage unit in the main storage space of the i-1-th storage layer is divided to the storage layer to be adjusted, and Ran(i)=i.

[0085] For max0(i), when the standby storage space of the i-th storage layer does not store a storage entry, or the main storage space with priority i-1 has no idle storage unit, max0(i)=0, otherwise, max0(i)=a*(Ptop[i]-Ppro[i-1])+b*(L-(Ppro[i]-Pbot[i]))+c*Dang[i+1].

[0086] For max1(i), when the standby storage space of the i-th storage layer does not store a storage entry, or the main storage space with priority i+1 has no idle storage unit, max1(i)=0, otherwise, max1(i)=a*(Ptop[i+2]-Ppro[i+1])+b*(L-(Ppro[i]-Pbot[i]))+c*Dang[i-1].

[0087] When i=0, the storage entry in the storage layer can only be adjusted downward, therefore, Max(0)=max1(0), Dire(0)=1, and since there is no i-1-th storage layer, there is also no corresponding Dang[i-1], therefore, the weight parameter c=0.

[0088] When i=S-1, the storage layer can only be adjusted upward, therefore, Max(S-1)=max0(S-1), Dire(S-1)=0, and since there is no i+1-th storage layer, there is also no corresponding Dang[i+1], therefore, the weight parameter c=0.

[0089] For other segment storage layers, Max(i) is the larger one of max0(i) and max1(i), and c can be any non-negative number.

[0090] As shown in Figure 6 When the storage layer to be adjusted is the i-th segment storage layer and Dire(i) = 1, the storage entry 5 with the highest address in the i-th segment storage layer is inserted into the storage unit with the highest address in the i-1-th segment storage layer, and Ptop[i] = Ptop[i] - 1 and Pbot[i] = Pbot[i] - 1, which is equivalent to dividing one storage unit from the idle storage unit in the main storage space of the i-1-th segment storage layer to the i-th segment main storage space. In the above operation, only the storage entry 5 to be adjusted is moved, and the operation amount is small.

[0091] As shown in Figure 7 When the storage layer to be adjusted is the i-th segment storage layer and Dire(i) = 0, the storage entry 0 with the lowest address in the i+1-th segment storage layer is moved to the idle storage unit with the lowest address in the i+1-th segment, and Ppro[i] = Ppro[i] + 1, Ptop[i+1] = Ptop[i+1] + 1, Pbot[i+1] = Pbot[i+1] + 1, and Ppro[i+1] = Ppro[i+1] + 1, which is equivalent to moving down one storage unit of the i-th segment backup storage space and dividing one storage unit from the i+1-th segment main storage space to the i-th segment main storage space. In the above operation, only one storage entry is moved, and the operation amount is small.

[0092] In the above storage entry adjustment operation, the operation amount is small, which can be quickly completed in addition to the search without needing to specially interrupt the search process for adjustment. With the multiple storage entry adjustment operations, the structure of the storage space is continuously optimized, and the storage units of the storage layer with less frequently used priority are continuously integrated into the storage layer with more frequently used priority, and each segment storage layer has a certain amount of backup storage space to realize the real-time change of the storage entry and prevent the matching result error output caused by the storage overflow.

[0093] When there are multiple storage entries to be adjusted at the same time, Max(i) of each storage layer needs to be sorted. In the present embodiment, the bubble sort with an average space complexity of 1 is used, and in other possible implementation manners, the sorting manners such as the insertion sort, the merge sort and the counting sort can also be used.

[0094] The sorting of Max(i) of each storage layer in the present embodiment includes the following steps:

[0095] S110, i = 0, Max = Max(0), Dire = Dire(0), and Ran = Ran(0).

[0096] S120, i = i + 1, compare the size of Max and Max(i), if Max < Max(i), then Max = Max(i), Dire = Dire(i), otherwise Max and Dire are not changed,

[0097] S130, repeat S120 until i = S - 1.

[0098] In general, since the operation amount of the storage entry adjustment operation is small and the time required is extremely short, the movement of all storage entries to be adjusted can be completed in the non-search period, but in a few cases, the storage entry adjustment operation can be interrupted, at this time, since the storage entry adjustment operation is performed according to the urgency of the movement, a good adjustment effect can still be achieved.

[0099] In summary, the application provides a method for updating a ternary content addressable memory, including a storage entry adjustment operation, a storage entry replacement operation, a storage entry deletion operation and a storage entry insertion operation. Among them, the storage entry adjustment operation has a small operation amount, which can be completed in the search state without the need to stop searching specifically for adjustment, and since the storage entry adjustment operation ensures that each storage layer has a certain amount of free storage space, it ensures that the storage entry changes in real time during the search process without causing storage overflow. Through the above updating method, the influence of the updating process of the storage entry on the search efficiency can be greatly reduced, and the correct matching result can be output. The storage entry replacement operation, the storage entry deletion operation and the storage entry insertion operation also have the advantage of small operation amount, which can be completed instantaneously, so that the TCAM can be searched at the same time without affecting the search efficiency.

[0100] In addition, since the storage units in the relatively free storage layer are continuously divided into storage layers with more storage entries, the structure of the storage space can be dynamically optimized, and each storage layer has a certain amount of free storage space after adjustment, preventing the time required for the storage entry adjustment operation from increasing over time.

[0101] Obviously, those skilled in the art can make various modifications and changes to the embodiments of the application without departing from the spirit and scope of the application. In this way, if these modifications and changes are within the scope of the claims of the application and their equivalents, the application also aims to cover these modifications and changes. For example, the word "comprises" does not exclude the presence of other elements or steps not listed in the claims. The simple fact that certain measures are described in mutually different dependent claims does not mean that combinations of these measures cannot be used to advantage. Any reference signs in the claims should not be considered as limiting the scope.

Claims

1. A method of updating a ternary content-addressable memory, characterized by, The storage entry adjustment operation comprises the following steps: S110, calculating an urgency degree of the i-th storage layer for the storage entry adjustment operation according to the number of free storage units in the main storage space of the first adjacent storage layer, the number of free storage units in the backup storage space of the i-th storage layer, and whether at least one storage unit in the backup storage space of the second adjacent storage layer stores a storage entry; wherein, when the main storage space of the first adjacent storage layer has no free storage unit or the main storage space of the i-th storage layer has a free storage unit, the urgency degree of the i-th storage layer is 0; wherein, the first adjacent storage layer and the second adjacent storage layer are one of the i+1-th storage layer and the i-1-th storage layer respectively; S120, determining a storage layer to be adjusted, which is the i-th storage layer with the largest urgency degree; S130, dividing one free storage unit in the main storage space of the first adjacent storage layer to the storage layer to be adjusted; and S140, repeating the S120 and the S130 until the urgency degree of each storage layer is 0; taking the i+1-th storage layer as the first adjacent storage layer and the i-1-th storage layer as the second adjacent storage layer to calculate a first urgency degree, and taking the i-1-th storage layer as the first adjacent storage layer and the i+1-th storage layer as the second adjacent storage layer to calculate a second urgency degree, wherein the urgency degree is the larger one of the first urgency degree and the second urgency degree; when the urgency degree is the first urgency degree, the operation of the S130 is to divide one free storage unit in the main storage space of the i+1-th storage layer to the storage layer to be adjusted; when the urgency degree is the second urgency degree, the operation of the S130 is to divide one free storage unit in the main storage space of the i-1-th storage layer to the storage layer to be adjusted.

2. The method of updating a TCAM according to claim 1, wherein, when the urgency degree is the first urgency degree, the operation of dividing one free storage unit in the main storage space of the first adjacent storage layer to the storage layer to be adjusted is to move the storage entry with the highest storage address in the i-th storage layer to the free storage unit with the highest address in the i-1-th storage layer, and to modify the priority of the free storage unit with the highest address in the i-1-th storage layer to the priority of the i-th storage layer; when the urgency degree is the second urgency degree, the operation of dividing one free storage unit in the main storage space of the first adjacent storage layer to the storage layer to be adjusted is to move the storage entry with the lowest storage address in the i+1-th storage layer to the free storage unit with the lowest address in the i+1-th storage layer, and to modify the priority of the free storage unit with the lowest address in the i+1-th storage layer to the priority of the i-th storage layer.

3. The method of updating a TCAM according to any one of claims 1-2, wherein, The S120 further comprises: before the operation of determining the storage layer to be adjusted, sorting the storage layers according to the urgency degree of each storage layer from large to small.

4. The method of updating a TCAM according to claim 3, wherein, The method for sorting the storage layers is bubble sort.

5. The method of updating a TCAM according to claim 1, wherein, The storage entry adjustment operation further comprises a storage entry replacement operation, a storage entry deletion operation and a storage entry insertion operation. The storage entry replacement operation on the i-th storage layer comprises the following steps: The storage entry deletion operation on the i-th storage layer comprises the following steps: S210, judging whether the storage entry is stored in the standby storage space, if the storage entry is not stored in the standby storage space, executing S221, otherwise executing S222; S221, deleting the storage entry to be deleted, then moving the storage entry with the highest storage address in the i-th storage layer to the storage unit storing the storage entry to be deleted, then moving the standby storage space of the i-th storage layer to the direction of low address by one storage unit; The storage entry insertion operation on the i-th storage layer comprises the following steps: S222, deleting the storage entry to be deleted, then moving the storage entry with the highest storage address in the i-th storage layer to the storage unit storing the storage entry to be deleted; S310, judging whether there is an idle storage unit in the main storage space of the i-th storage layer, if yes, executing S321, otherwise executing S322; S321, inserting the storage entry to be inserted into the idle storage unit with the lowest storage address in the i-th storage layer, and moving the standby storage space of the i-th storage layer to the direction of high address by one storage unit; S322, inserting the storage entry to be inserted into the idle storage unit with the lowest storage address in the i-th storage layer.

6. The method of updating a TCAM according to claim 1, wherein, Each of the storage layers is configured with three pointers Ppro[i], Pbot[i] and Ptop[i], wherein the Ppro[i] points to the highest address of the standby storage space, the Pbot[i] points to the highest address storing the storage entry, and the Ptop[i] points to the lowest address storing the storage entry.

7. The method of updating a TCAM according to claim 6, wherein, Each of the storage layers is configured with two flags Dang[i] and Valid[i]; The Valid[i] is used to determine whether the i-th main storage space is full, and the condition for determining true is Ppro[i]+1=Ptop[i+1]; The Dang[i] is used to determine whether the i-th standby storage space stores at least one storage entry, and the condition for determining true is Ppro[i]-Pbot[i]<l.

8. A ternary content addressable memory, characterized by The first processing module is configured to implement the storage entry adjustment operation in any one of claims 1-7.

9. The TCAM of claim 8, wherein, The second processing module is used for performing a storage entry insertion operation, a storage entry replacement operation and a storage entry deletion operation, and the third processing module is used for querying the storage entry stored in the ternary content-addressable memory. When the third processing module is in a working state, the second processing module can simultaneously perform the storage entry insertion operation, the storage entry replacement operation and / or the storage entry deletion operation. When the third processing module is in a dormant state, the first processing module automatically performs the storage entry adjustment operation.

Citation Information

Patent Citations

  • Method and system for storing elements of tri-state content addressable memory without ordering

    CN101350771A

  • Addressing method and device for three-state content addressable memory TCAM

    CN101699442A