Data query method, controller and processor

By using encoding algorithms and fill-in rules in content addressing memory to convert and query data, the problem of unsatisfactory efficiency of traditional data query methods is solved, and a more efficient data query process is achieved.

CN117555817BActive Publication Date: 2025-02-11YUSUR TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Traditional data query methods are not very efficient in content addressing memory, especially when the amount of data is large, resulting in query delays.

Method used

The pre-set encoding algorithm converts the query data into the encoding result of the first length, and extracts continuous encodings as meta-address information according to the encoding extraction rules, adds the fill data to obtain longer address information, and then querys the content addressing Memory to determine the target storage space.

Benefits of technology

Reduce the length of query data, save resources, and improve query efficiency. Compared with the hash search method, only a part of the storage space is required to query for sequential search method, which significantly improves query speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117555817B_ABST
    Figure CN117555817B_ABST
Patent Text Reader

Abstract

The present application discloses a data query method, a controller and a processor. The method is applied to the controller of a content-addressable memory, including: performing a series of operations through a pre-set encoding algorithm, encoding extraction rule and padding rule, obtaining first address information according to the query data, and then querying whether the storage space identified by the first address information in the content-addressable memory stores data. If the storage space identified by the first address information stores data, the padding data in the first address information is updated according to the padding rule to obtain at least one second address information, and finally determining the target address information of the storage space storing the query data in the content-addressable memory according to the first address information and the second address information. The present application can save resources compared to the hash search method, and has higher query efficiency compared to the sequential search method because only the storage space identified by the first address information and the second address information needs to be queried.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a data query method, a controller and a processor. Background Art

[0002] There are some internal storage blocks in the Field Programmable Gate Array (FPGA) to store data. With the development of digital information, the demand for storage capacity is gradually increasing. However, the mainstream internal storage block in FPGA, Random Access Memory (RAM), uses sequential search. When the amount of data is large, RAM will cause obvious delays when querying data.

[0003] Currently, content-addressable memory (CAM) is usually used to replace RAM, and its query speed is greatly improved compared to RAM.

[0004] However, the capacity of CAM is relatively low. In order to combine the advantages and disadvantages of CAM and RAM, a cache memory (Cache) is usually used to balance performance and resources. However, the efficiency of data query on Cache using the data query method commonly used in CAM and RAM is not ideal. Summary of the invention

[0005] In view of this, the present application provides a data query method, a controller and a processor to solve the technical problem that the efficiency of data query in traditional data query methods is not ideal.

[0006] The first aspect of the present application provides a data query method, which is applied to a controller of a content-addressable memory, comprising: converting query data into a first encoding result of a first length through a preset encoding algorithm; extracting at least part of the continuous encoding in the first encoding result as first meta-address information according to a preset encoding extraction rule; adding padding data to the first meta-address information according to a preset padding rule to obtain first address information, wherein the length of the first address information is a second length, and the second length is greater than the first length; querying whether a storage space identified by the first address information in the content-addressable memory stores data; if the storage space identified by the first address information stores data, updating the padding data in the first address information according to the padding rule to obtain at least one second address information; and determining the target address information of the storage space storing the query data in the content-addressable memory according to the first address information and the second address information.

[0007] Optionally, the process of updating the replacement data in the first address information according to the replacement rule to obtain at least one second address information may also include: updating the replacement data in the first address information according to the replacement rule to obtain the first second address information, wherein the replacement data in the first second address information is different from the replacement data in the first address information; setting i=1; querying whether the storage space identified by the i-th second address information stores data; if the storage space identified by the i-th second address information does not store data, obtaining the i-th second address information; if the storage space identified by the i-th second address information stores data, updating the replacement data in the first address information according to the replacement rule to obtain the i+1th second address information, and setting i=i+1 before executing the query whether the storage space identified by the i-th second address information stores data, wherein the replacement data in the i+1th second address information is different from the replacement data in the i-th second address information and the first address information.

[0008] Optionally, the process of determining the target address information of the storage space storing the query data in the content-addressable memory based on the first address information and the second address information may also include: querying the storage space identified by the first address information and the second address information, and determining the first address information or the second address information of the query data stored in the identified storage space as the target address information.

[0009] Optionally, the process of converting the query data into a first encoding result of a first length by using a preset encoding algorithm may further include: converting the query data into a first encoding result of a length of 32 bits by using a cyclic redundancy check algorithm.

[0010] Optionally, the process of extracting at least part of the continuous codes in the first coding result as the first meta address information may further include: extracting continuous 12-bit codes in the high or low order in the first coding result as the first meta address information.

[0011] Optionally, the data query process may further include: if the storage space identified by the first address information does not store data, returning query failure information, wherein the query failure information indicates that the queried data is not stored in the content-addressable memory.

[0012] Optionally, the data query process may also include: clearing the content-addressable memory; converting the data to be written into a second encoding result of the first length through the encoding algorithm; extracting at least part of the continuous encoding in the second encoding result as second meta-address information according to the encoding extraction rule; adding padding data to the second meta-address information according to the padding rule to obtain third address information, wherein the length of the third address information is the second length; querying whether the storage space identified by the third address information in the content-addressable memory stores data; if the storage space identified by the third address information stores data, updating the padding data in the third address information according to the padding rule to obtain fourth address information in which the identified storage space does not store data; and writing the data to be written into the storage space identified by the fourth address information.

[0013] Optionally, the process of updating the replacement data in the third address information according to the replacement rule to obtain the fourth address information where the identified storage space does not store data may also include: updating the replacement data in the third address information according to the replacement rule to obtain alternative address information, wherein the replacement data in the alternative address information is different from the replacement data in the third address information; querying whether the storage space identified by the alternative address information stores data; if the storage space identified by the alternative address information does not store data, determining the alternative address information as the fourth address information; if the storage space identified by the alternative address information stores data, re-updating the replacement data in the third address information according to the replacement rule until the alternative address information where the identified storage space does not store data is obtained.

[0014] According to a second aspect of the present application, there is provided a controller, which is applied to a content-addressable memory, and includes: a conversion module, which is used to convert query data into a first encoding result of a first length through a preset encoding algorithm; an extraction module, which is used to extract at least part of the continuous encoding in the first encoding result as the first meta-address information according to a preset encoding extraction rule; a padding module, which is used to add padding data to the first meta-address information according to a preset padding rule to obtain the first address information, wherein the length of the first address information is a second length, and the second length is greater than the first length; a query module, which is used to query whether the storage space identified by the first address information in the content-addressable memory stores data, and if the storage space identified by the first address information stores data, the padding data in the first address information is updated according to the padding rule to obtain at least one second address information; a determination module, which is used to determine the target address information of the storage space storing the query data in the content-addressable memory according to the first address information and the second address information.

[0015] According to a third aspect of an embodiment of the present application, a processor is provided, comprising: a content-addressable memory, a controller and a processing unit; the processing unit is used to send query data to the controller; the controller is used to execute the method described in the first aspect, query the target address information of the storage space storing the query data in the content-addressable memory, and send the target address information to the processing unit.

[0016] The present application converts the query data through a preset encoding algorithm, which can reduce the length of the query data. At the same time, the first address information and the second address information are obtained through the padding rule, and the data is further compared. Compared with the hash search method, it can save resources. At the same time, compared with the sequential search method, since only the storage space identified by the first address information and the second address information needs to be queried, it has higher query efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0018] Figure 1 is a flowchart of the steps of a data query method according to an embodiment of the present application;

[0019] Figure 2 is a flowchart of the steps of a method for obtaining second address information according to an embodiment of the present application;

[0020] Figure 3 is a flowchart of the steps of a data writing method according to an embodiment of the present application;

[0021] Figure 4 is a schematic diagram of the structure of a controller according to an embodiment of the present application;

[0022] Figure 5 It is a structural diagram of a processor according to an embodiment of the present application. DETAILED DESCRIPTION

[0023] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the embodiments of the present application should fall within the scope of protection of the embodiments of the present application.

[0024] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0025] It should be understood that although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0026] The technical solutions in the embodiments of the present application are clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present application. In the absence of conflict, the following embodiments and their technical features can be combined with each other.

[0027] In the prior art, the method of querying data on RAM is to query data by address, and the method of querying data on CAM is to query data by address. At present, the search methods for RAM and CAM are mainly sequential search, matching the query address or data in sequence, or by calculating the hash value of the query address or data, and querying the hash table generated by querying the data or address stored in RAM. The sequential search method occupies fewer resources, but the query time is longer, while the hash search method has a shorter query time, but the occupied resources are extremely high. The efficiency of the above two methods for data query is not ideal. The resources occupied by the sequential search method and the hash search method in a cache can be shown in Table 1:

[0028] Table 1

[0029] category Sequential search method Hash search method Occupied resources (bits) 15524K 40113K

[0030] It can be seen that the resources occupied by the hash search method are relatively high, and this data query method has an impact on the operation of the processor.

[0031] The query cycles required by the sequential search method and the hash search method to query data stored in different locations in the cache can be shown in Table 2:

[0032] Table 2

[0033] category Sequential search method Hash search method Storage location 1 query time 100CLK 1CLK Storage location 2 query time 1000CLK 1CLK Storage location 3 query time 10000CLK 1CLK

[0034] Storage location 1 precedes storage location 2, which precedes storage location 3.

[0035] It can be seen that the larger the amount of data in the cache, the longer the query time of the sequential search method, while the query time of the hash search method is very short. The sequential search method requires one-to-one comparison. When searching for data at a later storage location in the cache, the query time becomes significantly longer.

[0036] Therefore, a relatively compromise query method is needed to balance the search resources and search time.

[0037] Figure 1 is a flowchart of the steps of a data query method according to an embodiment of the present application. Figure 1 The data query method applied to the controller of the content addressable memory comprises the following steps:

[0038] Step 101: Convert query data into a first encoding result of a first length using a preset encoding algorithm.

[0039] When querying data, the query data can first be uniformly encoded through a coding algorithm. For example, the query data can be converted into a first encoding result of a first length through a coding algorithm such as a cyclic redundancy check algorithm or a cyclic redundancy check algorithm. The first length can be 32 bits, 16 bits, or other data lengths commonly used in encoding, but the first length is smaller than the data length of the query data.

[0040] It should be noted that, in order to improve the query efficiency, the query data is converted into the first encoding result of the first length through the encoding algorithm, which actually converts the length of the query data into the first encoding result with a shorter data length. For example, the query data is 64 bits, and the converted first encoding result is 32 bits. As the data length becomes shorter, data conflicts may occur. In order to verify the impact of the converted query data, a large number of random numbers are generated and data is written for verification. For example, the function of the CAM controller is tested through the verification environment established by Verilog. Through the whole process of initialization-data algorithm-conflict calculation-data writing-data reading-data comparison, the record of the change in the number of conflicts when the number of packets sent changes from small to large is obtained. The specific record is shown in Table 3:

[0041] Table 3

[0042] Number of packages Conflict Results 100 0 1000 0 10000 4

[0043] It can be seen that only when the number of packets sent is quite large will a small number of conflicts occur. Therefore, the query data is converted into a first encoding result of a first length through a preset encoding algorithm, which will not affect normal operation while improving query efficiency.

[0044] Step 102: extract at least part of the continuous codes in the first coding result as first meta-address information according to a preset code extraction rule.

[0045] The addresses stored in the content addressable memory are generated by extracting at least part of the continuous codes after the coding algorithm encodes the written data. Therefore, when querying, at least part of the continuous codes in the first coding result are extracted as the first meta address information, so as to perform address matching after the first meta address information is subsequently processed, thereby completing the data query. For example, if the first coding result is 32 bits, the code extraction rule may be to extract 12 consecutive bits in the first coding result as the first meta address information.

[0046] Step 103: Add the padding data to the first meta-address information according to a preset padding rule to obtain the first address information.

[0047] Since the encoding algorithm may convert the written data to duplicate during the writing process, the converted result will be modified by adding padding data as the address of the written data during the writing process. Therefore, when querying, the data queried through the first meta address information may not match the query data, so an incorrect address will be obtained. In order to avoid this situation, padding data is added to the first meta address information to obtain the first address information. The length of the first address information is the second length, and the second length is greater than the first length. For example, the length of the first meta address information is 12 bits, the padding data is 2 bits, and the first address information obtained is 14 bits.

[0048] Step 104: Query whether the storage space identified by the first address information in the content-addressable memory stores data.

[0049] After the first address information is obtained, the content-addressable memory is queried using the first address information as a query address, and further obtaining whether data is stored in the storage space identified by the first address information.

[0050] Step 105: If the storage space identified by the first address information stores data, update the padding data in the first address information according to the padding rule to obtain at least one second address information.

[0051] If the storage space identified by the first address information is found to store data during the query, the data may be the same as the query data, or it may be other data that is the same as the query data after conversion through the encoding algorithm during the writing process. Therefore, it is necessary to further update the second address information obtained after the replacement data in the first address information is updated and query again. Until the storage space identified by the updated second address information does not store data, it can be determined that all other data that is the same as the query data after conversion through the encoding algorithm during the writing process and the data to be queried have been queried, and all second address information updated and generated in this process can be obtained.

[0052] Step 106: Determine target address information of a storage space storing query data in the content addressable memory according to the first address information and the second address information.

[0053] After obtaining at least one second address information, the target address information of the storage space storing the query data in the content addressable memory is one of the first address information and the second address information, so further data comparison can be performed to determine the target address information.

[0054] In an embodiment of the present application, query data is converted through a pre-set encoding algorithm, which can reduce the length of the queried data. At the same time, the first address information and the second address information are obtained through the padding rule, and the data is further compared. Compared with the hash search method, it can save resources. At the same time, compared with the sequential search method, since only the storage space identified by the first address information and the second address information needs to be queried, it has higher query efficiency.

[0055] In one possible implementation, the process of determining the target address information of the storage space storing the query data in the content-addressable memory based on the first address information and the second address information may also include: querying the storage space identified by the first address information and the second address information, and determining the first address information or the second address information of the query data stored in the identified storage space as the target address information.

[0056] As mentioned above, during the writing process, the encoding algorithm may cause duplication of the converted write data. Therefore, during the writing process, the converted result will be modified by adding padding data as the address of the write data. Therefore, the data stored in the storage space identified by the first address information and the second address information may be the same as the query data. By comparing the data stored in the storage space identified by the first address information and the second address information with the query data, the first address information or the second address information can be determined as the target address information.

[0057] In an embodiment of the present application, by narrowing the query scope to the first address information or the second address information, the number of data comparisons required is at most the sum of the number of first address information or the second address information minus one, and the target address information corresponding to the data to be queried can be determined, thereby improving the efficiency of data query.

[0058] In a possible implementation, the process of converting the query data into a first encoding result of a first length by using a preset encoding algorithm may further include: converting the query data into a first encoding result of a length of 32 bits by using a cyclic redundancy check algorithm.

[0059] The preset encoding algorithm may be a cyclic redundancy check algorithm, and the query data may be converted into a first encoding result with a length of 32 bits by the cyclic redundancy check algorithm.

[0060] It should be noted that the cyclic redundancy check algorithm (CRC) is an operation based on polynomials, with polynomial arithmetic as the mathematical basis, that is, the remainder operation of (modulo-2) division. Different divisors are used, and the types of CRC are also different. For example, CRC includes CRC4, CRC8, CRC12, CRC16, CRC32 and other types. Since the query data needs to be converted into a first encoding result with a length of 32 bits, CRC32 is selected as the encoding algorithm.

[0061] In the embodiments of the present application, a cyclic redundancy check algorithm is used as the encoding algorithm, and the algorithm is implemented by XOR, which has lower complexity than the hash algorithm and can save system resources.

[0062] In a possible implementation, the process of extracting at least part of the continuous codes in the first coding result as the first meta address information may also include: extracting continuous 12-bit codes in the high or low order of the first coding result as the first meta address information.

[0063] When extracting at least part of the continuous codes in the first coding result as the first meta-address information, the continuous 12-bit codes in the high or low order in the first coding result can be selected as the first meta-address information. For example, the first coding result is 1001011010100101010101010010101, the continuous 12-bit codes in the high order 100101101010 can be selected as the first meta-address information, or the continuous 12-bit codes in the low order 101010010101 can be selected as the first meta-address information.

[0064] In the embodiment of the present application, by selecting the continuous 12-bit code in the high or low position in the first coding result as the first meta-address information, the query complexity can be reduced while ensuring that the code is not discrete.

[0065] In a possible implementation, the data query process may further include: if the storage space identified by the first address information does not store data, returning query failure information, wherein the query failure information indicates that the queried data is not stored in the content-addressable memory.

[0066] If it is found during the query that the storage space identified by the first address information does not store data, it proves that the content-addressable memory does not store data matching the query data, and a query failure message is returned to prompt the user to verify whether the query data is correct, or to replace the query data for query.

[0067] In the embodiment of the present application, by returning query failure information when no data matching the query data is stored in the content-addressable memory, a prompt can be given to the user, thereby improving the user experience.

[0068] Figure 2 is a flowchart of the steps of a method for obtaining second address information according to an embodiment of the present application. Figure 2 As shown, the second address information obtaining method includes the following steps:

[0069] Step 201: Update the padding data in the first address information according to the padding rule to obtain the first second address information.

[0070] After determining that the storage space identified by the first address information stores data, in order to find other data that is the same as the data stored in the storage space identified by the first address information after the encoding algorithm is converted, it is necessary to update the bit-filling data in the first address information according to the bit-filling rule. The bit-filling data in the first second address information is different from the bit-filling data in the first address information. For example, if the first address information is 00100101101010, the bit-filling rule is to sequentially modify the bit-filling data 00 to obtain the first second address information of 01100101101010.

[0071] It should be noted that the number of bits of the padding data can be modified according to the situation of data conflict. In the above example, since the possibility of duplication of the 12-bit first element address information is low, the padding data is set to two bits, initially "00", but the padding data can also be set to three, four or other bits.

[0072] Step 202: Set i=1.

[0073] Since the first second address information may still find that the identified storage space stores data when it is queried, a loop query process may be set, starting from the first second address information as a loop.

[0074] Step 203, query whether the storage space identified by the i-th second address information stores data. If the storage space identified by the i-th second address information does not store data, execute step 204; if the storage space identified by the i-th second address information stores data, execute step 205.

[0075] Step 204: Obtain i pieces of second address information and end the current process.

[0076] During the execution of the loop, if it is found that the storage space identified by the i-th second address information does not store data, it proves that the data that may be the same as the query data has been queried. At this time, i second address information is obtained, but since the storage space identified by the i-th second address information does not store data, the target address information of the query data may be the first address information and one of the first second address information to the i-1th address information. When i=1, the target address information of the query data may be one of the first address information and the first second address information.

[0077] Step 205 , update the padding data in the first address information according to the padding rule to obtain the (i+1)th second address information, and execute step 203 after setting i=i+1.

[0078] If it is found that the storage space identified by the i-th second address information stores data, it is possible that the data identical to the query data has not been exhausted, and the replacement data in the first address information needs to be updated for the i+1th time according to the replacement rule to obtain the i+1th second address information. The replacement data in the i+1th second address information is different from the replacement data in the i-th second address information and the first address information. Then, i=i+1 is set to perform the cyclic query operation again.

[0079] In the embodiment of the present application, through the above-mentioned loop process, i second address information can be obtained with low operation complexity, thereby improving the efficiency of determining the target address information.

[0080] Figure 3 is a flowchart of the steps of a data writing method according to an embodiment of the present application. Figure 3 As shown, the data writing method includes the following steps:

[0081] Step 301: Clear the content addressable memory.

[0082] In order to cooperate with the data query method, when writing data into the content addressable memory, the content addressable memory is first initialized and all data are cleared.

[0083] Step 302: Convert the data to be written into a second encoding result of the first length through an encoding algorithm.

[0084] The data to be written is converted into a second encoding result of the first length through the encoding algorithm for converting the query data.

[0085] Step 303: extract at least part of the continuous codes in the second coding result as the second meta-address information according to the code extraction rule.

[0086] After obtaining the second coding result, at least part of the continuous coding in the second coding result is extracted as the second meta-address information according to the same coding extraction rule used in the above-mentioned query data. For example, if the second coding result is 64 bits, the coding extraction rule may be to extract 32 consecutive bits in the second coding result as the second meta-address information.

[0087] Step 304: Add the padding data to the second meta-address information according to the padding rule to obtain the third address information.

[0088] Since the encoding algorithm may cause duplication of the written data after conversion during the writing process, after obtaining the second meta address information, the padding data is added to the second meta address information according to the same padding rule used when querying the data, to obtain the third address information. For example, the length of the second meta address information is 32 bits, the padding data is 4 bits, and the obtained third address information is 36 bits. The length of the third address information is the second length that is the same as the length of the first address information.

[0089] Step 305: Query whether the storage space identified by the third address information in the content-addressable memory stores data.

[0090] Step 306: If the storage space identified by the third address information stores data, update the padding data in the third address information according to the padding rule to obtain fourth address information of the identified storage space that does not store data.

[0091] Step 307: Write the data to be written into the storage space identified by the fourth address information.

[0092] If it is found during writing that the storage space identified by the third address information stores data, the writing process will produce address duplication. In order to avoid address conflicts, the third address information needs to be updated. The third address information can be updated according to the filling rule used in the above query process to obtain the fourth address information of the identified storage space where no data is stored, and the data to be written can be written into the fourth address information of the identified storage space where no data is stored.

[0093] In the embodiment of the present application, by using the same encoding algorithm, encoding extraction rules and padding rules as the query data to determine the address where the data to be written can be written, the efficiency of querying the data can be improved while reducing the writing complexity.

[0094] In one possible implementation, the process of updating the replacement data in the third address information according to the replacement rule to obtain the fourth address information where the identified storage space does not store data may also include: updating the replacement data in the third address information according to the replacement rule to obtain the alternative address information, and then querying whether the storage space identified by the alternative address information stores data; if the storage space identified by the alternative address information does not store data, determining the alternative address information as the fourth address information; if the storage space identified by the alternative address information stores data, re-updating the replacement data in the third address information according to the replacement rule until the alternative address information where the identified storage space does not store data is obtained.

[0095] After updating the replacement data in the third address information and obtaining the alternative address information, it is necessary to further determine whether the storage space identified by the alternative address information stores data. If so, the third address information is updated again until the alternative address information is obtained in which the identified storage space does not store data, and the alternative address information is determined as the fourth address information.

[0096] In an embodiment of the present application, by performing a data query on the alternative address information to update the fill-in data in the third address information, fourth address information of the identified storage space where no data is stored is obtained, thereby avoiding address conflicts in the data to be written into the content-addressable memory.

[0097] Figure 4 is a schematic diagram of the structure of a controller according to an embodiment of the present application. Figure 4 As shown, the controller 400 includes: a conversion module 401, an extraction module 402, a filling module 403, a query module 404 and a determination module 405.

[0098] The conversion module 401 is used to convert the query data into a first encoding result of a first length by using a preset encoding algorithm.

[0099] When querying data, the conversion module 401 can first uniformly encode the query data through a coding algorithm. For example, the query data can be converted into a first coding result of a first length through a coding algorithm such as a cyclic redundancy check algorithm or a cyclic redundancy check algorithm. The first length can be a data length commonly used in encoding, such as 32 bits and 16 bits, but the first length is smaller than the data length of the query data.

[0100] The extraction module 402 is used to extract at least part of the continuous codes in the first coding result as the first meta-address information according to a preset code extraction rule.

[0101] The addresses stored in the content addressable memory are generated by extracting at least part of the continuous codes after the coding algorithm encodes the written data. Therefore, when querying, the extraction module 402 extracts at least part of the continuous codes in the first coding result as the first meta address information, so as to perform address matching after the first meta address information is subsequently processed, thereby completing the data query. For example, if the first coding result is 32 bits, the code extraction rule may be to extract 12 consecutive bits in the first coding result as the first meta address information.

[0102] The padding module 403 is used to add padding data to the first meta-address information according to a preset padding rule to obtain the first address information, wherein the length of the first address information is the second length, and the second length is greater than the first length.

[0103] Since the encoding algorithm may convert the written data to be repeated during the writing process, the converted result will be modified by adding padding data as the address of the written data during the writing process. Therefore, when querying, the data queried through the first meta address information may not match the query data, so an incorrect address will be obtained. In order to avoid this situation, the padding module 403 adds padding data to the first meta address information to obtain the first address information. The length of the first address information is the second length, and the second length is greater than the first length. For example, the length of the first meta address information is 12 bits, the padding data is 2 bits, and the first address information obtained is 14 bits.

[0104] The query module 404 is used to query whether the storage space identified by the first address information in the content-addressable memory stores data. If the storage space identified by the first address information stores data, the padding data in the first address information is updated according to the padding rule to obtain at least one second address information.

[0105] After the filling module 403 obtains the first address information, the query module 404 uses the first address information as the query address to query the content-addressable memory, and further obtains whether there is data stored in the storage space identified by the first address information. If it is found during the query by the query module 404 that there is data stored in the storage space identified by the first address information, the data may be the same as the query data, or it may be other data that is the same as the query data after conversion by the encoding algorithm during the writing process. Therefore, it is necessary to further update the second address information obtained after the filling data in the first address information is updated and query again. Until there is no data stored in the storage space identified by the updated second address information, it can be determined that all other data that is the same as the query data after conversion by the encoding algorithm during the writing process and the data that needs to be queried have been queried, and all the second address information updated and generated in this process are obtained.

[0106] The determination module 405 is used to determine the target address information of the storage space storing the query data in the content addressable memory according to the first address information and the second address information.

[0107] After the query module 404 obtains at least one second address information, the target address information of the storage space storing the query data in the content addressable memory is one of the first address information and the second address information, so the determination module 405 can determine the target address information by further data comparison.

[0108] In an embodiment of the present application, query data is converted through a pre-set encoding algorithm, which can reduce the length of the queried data. At the same time, the first address information and the second address information are obtained through the padding rule, and the data is further compared. Compared with the hash search method, it can save resources. At the same time, compared with the sequential search method, since only the storage space identified by the first address information and the second address information needs to be queried, it has higher query efficiency.

[0109] It should be noted that the information interaction, execution process, etc. between the conversion module 401, extraction module 402, filling module 403, query module 404 and determination module 405 in the above-mentioned controller 400 are based on the same concept as the aforementioned data query method embodiment. The specific contents can be found in the description in the aforementioned data query method embodiment and will not be repeated here.

[0110] Figure 5 is a schematic diagram of the structure of a processor according to an embodiment of the present application. Figure 5 As shown, the processor 500 includes: a content addressable memory 501 , a controller 400 and a processing unit 502 .

[0111] The processing unit 502 is used to send query data to the controller 400 .

[0112] After receiving the query data to be queried, the processing unit 502 sends the query data to the controller 400. The query data can be obtained by receiving data input by the user through the front-end interface, or by pulling data from the network.

[0113] The controller 400 is used to execute the method of the first aspect of the embodiment, query the target address information of the storage space storing the query data in the content addressable memory 501, and send the target address information to the processing unit 502.

[0114] After receiving the query data sent by the processing unit 502, the controller 400 queries the target address information of the storage space storing the query data in the content addressable memory 501. The specific query method can be found in the description of the aforementioned data query method embodiment, which will not be repeated here.

[0115] In an embodiment of the present application, query data is converted through a pre-set encoding algorithm, which can reduce the length of the queried data. At the same time, the first address information and the second address information are obtained through the padding rule, and the data is further compared. Compared with the hash search method, it can save resources. At the same time, compared with the sequential search method, since only the storage space identified by the first address information and the second address information needs to be queried, it has higher query efficiency.

[0116] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.

[0117] The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or implemented as software or computer code that can be stored in a recording medium (such as CD ROM, RAM, floppy disk, hard disk or magneto-optical disk), or implemented as a computer code originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a special-purpose processor or programmable or special-purpose hardware (such as ASIC or FPGA). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (for example, RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the method shown here, the execution of the code converts the general-purpose computer into a special-purpose computer for executing the method shown here. Although the present application has been shown and described with respect to one or more implementations, those skilled in the art will think of equivalent deformations and modifications based on the reading and understanding of this specification and the accompanying drawings. The present application includes all such modifications and variations, and is limited only by the scope of the appended claims. In particular, with respect to the various functions performed by the above-described components, the terms used to describe such components are intended to correspond to any component that performs the specified function of the component (e.g., which is functionally equivalent) (unless otherwise indicated), even if not structurally equivalent to the disclosed structure that performs the function in the exemplary implementation of the present specification shown herein.

[0118] That is, the above description is only an embodiment of the present application, and does not limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the specification and drawings of the present application, such as the mutual combination of technical features between the embodiments, or direct or indirect application in other related technical fields, are also included in the patent protection scope of the present application.

[0119] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of this application, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.

[0120] In order to enable any technician in the field to implement and use the application, the application provides the above description. In the above description, various details are listed for the purpose of explanation. It should be understood that those of ordinary skill in the art can recognize that the application can also be implemented without using these specific details. In other embodiments, the well-known process will not be elaborated in detail to avoid unnecessary details that make the description of the application obscure. Therefore, the application is not intended to be limited to the embodiments shown, but is consistent with the widest range of principles and features disclosed in the application.

[0121] It should be noted that, under the premise of no conflict, the various embodiments and / or the technical features in the various embodiments described in this application can be arbitrarily combined with each other, and the technical solution obtained after the combination should also fall within the protection scope of this application.

[0122] It should be understood that the specific examples in the embodiments of the present application are only to help those skilled in the art to better understand the embodiments of the present application, rather than to limit the scope of the embodiments of the present application. Those skilled in the art can make various improvements and modifications based on the above embodiments, and these improvements or modifications all fall within the scope of protection of the present application.

[0123] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A data query method, applied to a controller of a content addressable memory, characterized in that: The method comprises: Convert the query data into a first encoding result of a first length by using a preset encoding algorithm; According to a preset code extraction rule, extracting at least part of the continuous codes in the first coding result as the first meta-address information; According to a preset padding rule, adding padding data to the first meta-address information to obtain first address information, wherein the length of the first address information is a second length, and the second length is greater than the first length; querying whether the storage space identified by the first address information in the content-addressable memory stores data; If the storage space identified by the first address information stores data, updating the bit-filling data in the first address information according to the bit-filling rule to obtain at least one second address information; Determining target address information of a storage space storing the query data in the content-addressable memory according to the first address information and the second address information; The updating of the padding data in the first address information according to the padding rule to obtain at least one second address information includes: updating the padding data in the first address information according to the padding rule to obtain the first second address information, wherein the padding data in the first second address information is different from the padding data in the first address information; Set i=1; Query whether the storage space identified by the i-th second address information stores data; If the storage space identified by the i-th second address information does not store data, obtaining the i-th second address information; If the storage space identified by the i-th second address information stores data, the padding data in the first address information is updated according to the padding rule to obtain the i+1-th second address information, and after setting i=i+1, the query is performed to determine whether the storage space identified by the i-th second address information stores data, wherein the padding data in the i+1-th second address information is different from the padding data in the i-th second address information and the first address information that have been obtained; The determining, according to the first address information and the second address information, target address information of a storage space storing the query data in the content addressable memory comprises: The storage space identified by the first address information and the second address information is queried, and the first address information or the second address information in which the queried data is stored in the identified storage space is determined as the target address information.

2. The method according to claim 1, characterized in that The step of converting the query data into a first encoding result of a first length by using a preset encoding algorithm includes: The query data is converted into a first encoding result with a length of 32 bits through a cyclic redundancy check algorithm.

3. The method according to claim 2, characterized in that The step of extracting at least a portion of continuous codes from the first coding result as first meta address information includes: A continuous 12-bit code at a high or low position in the first coding result is extracted as the first meta address information.

4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: If the storage space identified by the first address information does not store data, query failure information is returned, wherein the query failure information indicates that the queried data is not stored in the content-addressable memory.

5. The method according to claim 1, characterized in that: The method further comprises: Clearing the content addressable memory; Converting the data to be written into a second encoding result of the first length by using the encoding algorithm; According to the code extraction rule, extract at least part of the continuous codes in the second coding result as the second meta-address information; According to the padding rule, adding padding data to the second meta-address information to obtain third address information, wherein the length of the third address information is the second length; querying whether the storage space identified by the third address information in the content-addressable memory stores data; If the storage space identified by the third address information stores data, updating the padding data in the third address information according to the padding rule to obtain fourth address information of the identified storage space where no data is stored; The data to be written is written into the storage space identified by the fourth address information.

6. The method according to claim 5, characterized in that The updating of the padding data in the third address information according to the padding rule to obtain fourth address information of the identified storage space where no data is stored includes: updating the replacement data in the third address information according to the replacement rule to obtain candidate address information, wherein the replacement data in the candidate address information is different from the replacement data in the third address information; Query whether the storage space identified by the candidate address information stores data; If the storage space identified by the candidate address information does not store data, determining the candidate address information as the fourth address information; If the storage space identified by the candidate address information stores data, the replacement data in the third address information is updated again according to the replacement rule until the candidate address information of the storage space identified by the candidate address information that does not store data is obtained.

7. A controller, applied to a content addressable memory, characterized in that: include: A conversion module, used to convert the query data into a first encoding result of a first length by using a preset encoding algorithm; An extraction module, configured to extract at least a portion of continuous codes in the first coding result as first meta-address information according to a preset code extraction rule; a padding module, configured to add padding data to the first meta-address information according to a preset padding rule to obtain first address information, wherein the length of the first address information is a second length, and the second length is greater than the first length; a query module, configured to query whether the storage space identified by the first address information in the content-addressable memory stores data, and if the storage space identified by the first address information stores data, update the padding data in the first address information according to the padding rule to obtain at least one second address information; a determination module, configured to determine target address information of a storage space storing the query data in the content addressable memory according to the first address information and the second address information; The query module is used to update the padding data in the first address information according to the padding rule to obtain the first second address information, wherein the padding data in the first second address information is different from the padding data in the first address information, set i=1, query whether the storage space identified by the i-th second address information stores data, if the storage space identified by the i-th second address information does not store data, obtain the i-th second address information, if the storage space identified by the i-th second address information stores data, update the padding data in the first address information according to the padding rule to obtain the i+1th second address information, and after setting i=i+1, execute the query whether the storage space identified by the i-th second address information stores data, wherein the padding data in the i+1th second address information is different from the padding data in the i-th second address information and the first address information that have been obtained; The determination module is used to query the storage space identified by the first address information and the second address information, and determine the first address information or the second address information in which the query data is stored in the identified storage space as the target address information.

8. A processor, characterized in that: include: content-addressable memory, controller, and processing unit; The processing unit is used to send query data to the controller; The controller is used to execute the method according to any one of claims 1 to 6, query the target address information of the storage space storing the query data in the content addressable memory, and send the target address information to the processing unit.

Citation Information

Patent Citations

  • Ternary content-addressable memory

    CN103531231A

  • CPIR-V nearest neighbor privacy-preserving query method based on Spark and Huffman coding

    CN107291935A