CN102364463A - Hash-based method for searching CAM (central address memory) - Google Patents
Hash-based method for searching CAM (central address memory) Download PDFInfo
- Publication number
- CN102364463A CN102364463A CN2011102768229A CN201110276822A CN102364463A CN 102364463 A CN102364463 A CN 102364463A CN 2011102768229 A CN2011102768229 A CN 2011102768229A CN 201110276822 A CN201110276822 A CN 201110276822A CN 102364463 A CN102364463 A CN 102364463A
- Authority
- CN
- China
- Prior art keywords
- data
- cam
- hash
- search
- address
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
Abstract
The invention provides a hash-based method for searching a CAM (central address memory). The CAM has a data storage function and a high-speed data content searching function and also supports multiple instructions such as reading, writing and searching. However, the most important function of the CAM is the high-speed data content searching function, and the searching function is based on other functions of the CAM. Therefore, the core of the design of a CAM functional model is the design of a high-speed searching engine. The searching engine can maintain a sheet and receive external input data. The input data and each item in the sheet are completely compared (accurate) or partially compared (Don'tcare function) through a certain search algorithm in the searching engine, and then comparison results are output. The rapid CAM content search can be achieved via a hash function. When a request is searched through the CAM, hash calculation is carried out for data to be searched to obtain a hashkey, a first address of a CAM table item data linked list is obtained via access to a hash entry table according to the hashkey (as a hash entry table address), the access to the CAM data table item linked list is completed, the data to be searched and items in the CAM data linked list are compared one by one, and finally CAM search results are returned.
Description
Technical field
The present invention relates to communicate by letter, data search coupling or chip design art field under the express network, specifically a kind of method of searching CAM based on Hash.
Background technology
Along with the fast development of the communication technology, on the one hand, increasing at the data bandwidth of transmission through network.On the other hand, the continuous change and progress of various application in the network, present IP network need provide more COSs and better service quality for the user; Require router to provide extra treatment mechanism to realize Differentiated Services, message classification, security intrusion monitoring; Firewall access control, Virtual Private Network, fast routing lookups; The network address transforms, and waits some network key technology.
For the increasing development trend of the data traffic that adapts to network, guarantee the unobstructed property of network link, router performance has been proposed new challenge---how the through street by.Development of internet technology, these key network techniques all relate to searches matching problem, and based on software to search matching efficiency low, the method that traditional software is realized for the development of express network show unable to do what one wishes.
The CAM chip search matching properties fast, make CAM in network, be widely used.The characteristics of searching coupling fast of CAM chip are for a lot of crucial application in the network provide new solution.Can realize fast routing lookups with CAM, message classification, Differentiated Services, intrusion detections etc. need be searched the gordian technique of coupling fast.
Summary of the invention
The purpose of this invention is to provide a kind of method of searching CAM based on Hash.
The objective of the invention is to realize by following mode; Of the present inventionly search matching principle through Hash; Its logic is described with hardware circuit, and data to be looked into write memory bank, and two textural associations become content addressable storage body (Content Addressable Memory).Design is divided into following functional module:
1) bus; 2) Hash function look-up table; 3) Hash goes into oral thermometer; 4) data back; 5) match circuit; 6) RAM control circuit, wherein:
Bus 1) is the passage of CAM and PERCOM peripheral communication.Bus is divided into request bus and response bus in CAM.The request bus is a two-way multiplex bus, and the request bus is made up of command line and request msg bus.Command line is handled input command, and the request bus is the general data passage.All are to the operation command signal of CAM, and the data-signal that is input in addition among the CAM all transmits through the request bus.
Hash function look-up table 2) through the mode of look-up table Hash is searched the function logic and realize that the Hash lookup step is: establishing Hash table is HST [0 ~ M-1], and hash function is got H (key), and the method that manages conflict is R (x); The first step is calculated Hash address D i=H (k) to given k value; If HST is empty, then search failure; If HST=k then searches successfully; Otherwise, carried out for second step (handling conflict).The next memory address Dk=R (Dk-1) of conflict is handled in the second step double counting, is empty up to HST [Dk], or till HST [Dk]=k.If HST [Dk]=K then searches successfully, otherwise searches failure.According to the conflict processing method of selecting, calculate the next memory address of key word key.If next memory address is still occupied, then continue to carry out for second step, till the memory address that finds ability usefulness.
Hash goes into oral thermometer 3) in deposit the Key value through Hash_Key after the Hash function calculation and corresponding with it data table items entry value.
Data back 4) as deposit data district to be found; Confirm the data width and the data depth of this memory bank according to the data layout of system; After finding address through Hash_Key corresponding to data back; System is through RAM control circuit 6) this memory bank is carried out memory access, the data in the reading of data list item.
After reading out the data in the list item, through match circuit 5) will treat that the content of addressing and list item data compare, if coupling is then exported match address, draw high the Data Matching sign.
The search program flow process is following:
1. carry out hash and calculate Hash key according to the data of searching of input, remove to visit Hash with Hash key and go into oral thermometer.If it is 0 that Hash goes into the content of oral thermometer, then jump to 3; If it is not 0 that Hash goes into the content of oral thermometer, then jump to 2;
2. go into the content of oral thermometer according to Hash, remove to visit CAM data item chained list, and compare (from linked list head to the chained list tail) one by one with the data of CAM data item chained list searching data.Begin comparison from linked list head, search unsuccessfully, then search the next item down of chained list, till the chained list tail, jump to 3; Search successfully (value of searching data is identical with one value in the CAM data item chained list) and then note this CAM address; Then search the next item down of chained list; If also success relatively the CAM address therewith before the size of CAM address of record; Finally get CAM address reckling, search like this until till the chained list tail, jump to 3;
3. search successfully, return the information that CAM address and CAM hit, jump to 4; Search unsuccessfully, return and search end, return the information that CAM does not hit, jump to 4;
4. EO returns.
The invention has the beneficial effects as follows: the high efficiency based on Hash searches algorithm can find out matched data, the number of comparisons when having reduced data search fast; Only need once can find out data; Improve search efficiency, practiced thrift system time, improved the throughput of data communication.
Description of drawings
Accompanying drawing 1 is that Hash searches the CAM structural drawing.
Embodiment
Explanation at length below with reference to Figure of description method of searching CAM based on Hash of the present invention being done.
A kind of method of searching CAM of the present invention based on Hash, its structure is by described in summary of the invention, and architecture of the present invention mainly comprises:
1) bus; 2) Hash function look-up table; 3) Hash goes into oral thermometer; 4) data back; 5) match circuit; 6) RAM control circuit.
CAM has data storage function and high-speed data content search function; Many instructions such as support reading and writing simultaneously, search; But the topmost function of CAM is the high-speed content locating function; And other function is all done the basis for locating function, so the core of the design of CAM functional mode is the design of high-speed searching engine.Search engine itself and safeguard a table, and can receive outer input data.Algorithm is searched through certain in its inside will import that each item all compares (accurately) or part (Don ' t care function) comparison in data and the table, export comparative result then.
Carry out quick CAM content search with the method for hash function.When carrying out the CAM search request; Carry out hash to the data of searching earlier and calculate a hash key; Then removing to visit hash according to this hash key (as hash inlet table address) goes into oral thermometer and obtains content-addressable memory association chained list first address; Remove to visit CAM data table items chained list then, at last the data that will search with one by one the comparison of item in the CAM data link table, return the CAM lookup result at last.
Wherein CAM searches engine and has adopted Hash to search that algorithm realizes.The CAM model general structure of searching engine based on Hash is promptly searched engine with Hash and is searched engine as CAM; When searching engine and receiving from the Logic control module request; Data are searched in reception and storing in the data register, the content-addressable memory item in the reading of data storer compares through data comparator then; When the content-addressable memory item in comparing success or data-carrier store has all compared one time, return the successful content-addressable memory item address in data-carrier store of comparison.
The search program flow process is following:
1. carry out hash and calculate Hash key according to the data of searching of input, remove to visit Hash with Hash key and go into oral thermometer.If it is 0 that Hash goes into the content of oral thermometer, then jump to 3; If it is not 0 that Hash goes into the content of oral thermometer, then jump to 2;
2. go into the content of oral thermometer according to Hash, remove to visit CAM data item chained list, and compare (from linked list head to the chained list tail) one by one with the data of CAM data item chained list searching data.Begin comparison from linked list head, search unsuccessfully, then search the next item down of chained list, till the chained list tail, jump to 3; Search successfully (value of searching data is identical with one value in the CAM data item chained list) and then note this CAM address; Then search the next item down of chained list; If also success relatively the CAM address therewith before the size of CAM address of record; Finally get CAM address reckling, search like this until till the chained list tail, jump to 3;
3. search successfully, return the information that CAM address and CAM hit, jump to 4; Search unsuccessfully, return and search end, return the information that CAM does not hit, jump to 4;
4. EO returns.
Embodiment
1) utilize Hash to search the form that function exists, comprising: direct method, subraction, method of residues, numerical value extracting method, intermediate means method, folding method, rotary process, pseudo random number method, design setting model adopts top-down analysis design method; Be divided into a plurality of modules to total system, each module continues refinement again, brings the degree of coding up to minimum one-level; Carry out the exploitation of bottom module one by one; The module uniting and adjustment are carried out in debugging then, last total system uniting and adjustment;
2) the Hash collision problem in searching for Hash, solution comprises: (1) linear open addressing method; (2) difference solves method; (3) chained list solves method; (4) divide bucket Hash method;
3) memory bank based on CAM not only has data storage capacities; Also has the data compare facility; Memory bank receives comparing data; And be broadcast to it in each corresponding associated memory, associated memory compares the data of data with own storage, and associated memory is given priority encoder comparative result at last;
4) for each function of CAM, describe in detail and analyze, correspond to concrete design proposal and hardware and realize having corresponding sequential relationship;
5) search function logic realization method based on Hash;
6) search inlet table address visit data table by Hash, the correlation data contents in table with search content, the output matching result;
7) memory bank is carried out type selecting, choose the best alternatives.
Except that the described technical characterictic of instructions, be the known technology of those skilled in the art.
Claims (1)
1. method of searching CAM based on Hash; It is characterized in that the function that CAM provides reading and writing, searches, moves, checks to the user; List item in computing through specific Hash function and the Hash table is complementary and tries to achieve the position of data; Carry out data again and promptly obtain the address of desiring to search after relatively, concrete steps are following:
Search matching principle through Hash, its logic is described with hardware circuit, data to be looked into write memory bank, and two textural associations become the content addressable storage body, and design is divided into following functional module:
1) bus; 2) Hash function look-up table; 3) Hash goes into oral thermometer; 4) data back; 5) match circuit; 6) RAM control circuit; Wherein:
Bus 1) be the passage of CAM and PERCOM peripheral communication, bus is divided into request bus and response bus in CAM; The request bus is a two-way multiplex bus; The request bus is made up of command line and request msg bus; Command line is handled input command; The request bus is the general data passage, and all are to the operation command signal of CAM, and the data-signal that is input in addition among the CAM all transmits through the request bus;
Hash function look-up table 2) through the mode of look-up table Hash is searched the function logic and carry out, the Hash lookup step is: establishing Hash table is HST [0 ~ M-1], and hash function is got H (key), and the method that manages conflict is R (x); The first step is calculated Hash address D i=H (k) to given k value; If HST is empty, then search failure; If HST=k then searches successfully; Otherwise, carried out for second step and handle conflict; The next memory address Dk=R (Dk-1) of conflict is handled in the second step double counting, is empty up to HST [Dk], or till HST [Dk]=k; If HST [Dk]=K then searches successfully, otherwise searches failure; According to the conflict processing method of selecting, the next memory address of calculating key word key if next memory address is still occupied, then continues to carry out for second step, till the memory address that finds ability usefulness;
Hash goes into oral thermometer 3) in deposit the Key value through Hash_Key after the Hash function calculation and corresponding with it data table items entry value;
Data back 4) as deposit data district to be found; Confirm the data width and the data depth of this memory bank according to the data layout of system; After finding address through Hash_Key corresponding to data back; System is through RAM control circuit 6) this memory bank is carried out memory access, the data in the reading of data list item;
After reading out the data in the list item, through match circuit 5) will treat that the content of addressing and list item data compare, if coupling is then exported match address, draw high the Data Matching sign;
The search program flow process is following:
1) carrying out hash and calculate Hash key according to the data of searching of input, remove to visit Hash with Hash key and go into oral thermometer, is 0 if Hash goes into the content of oral thermometer, then jumps to 3; If it is not 0 that Hash goes into the content of oral thermometer, then jump to 2;
2) go into the content of oral thermometer according to Hash, remove to visit CAM data item chained list, and compare one by one searching the data of data with CAM data item chained list; To the chained list tail, begin comparison from linked list head, search unsuccessful from linked list head; Then search the next item down of chained list, till the chained list tail, jump to 3; Search successfully; The value of searching data is identical with one value in the CAM data item chained list, then notes this CAM address, then searches the next item down of chained list; If also success relatively the CAM address therewith before the size of CAM address of record; Finally get CAM address reckling, search like this until till the chained list tail, jump to 3;
3) search successfully, return the information that CAM address and CAM hit, jump to 4; Search unsuccessfully, return and search end, return the information that CAM does not hit, jump to 4;
4) EO returns.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN 201110276822 CN102364463B (en) | 2011-09-19 | 2011-09-19 | Hash-based method for searching CAM (central address memory) |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN 201110276822 CN102364463B (en) | 2011-09-19 | 2011-09-19 | Hash-based method for searching CAM (central address memory) |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102364463A true CN102364463A (en) | 2012-02-29 |
CN102364463B CN102364463B (en) | 2013-07-10 |
Family
ID=45691029
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN 201110276822 Active CN102364463B (en) | 2011-09-19 | 2011-09-19 | Hash-based method for searching CAM (central address memory) |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102364463B (en) |
Cited By (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102694798A (en) * | 2012-05-15 | 2012-09-26 | 浪潮电子信息产业股份有限公司 | Method for high-speed serial interconnection based on Hash mapping table |
CN103227751A (en) * | 2013-05-14 | 2013-07-31 | 盛科网络(苏州)有限公司 | Method and device for improving spatial utilization ratio of forwarding table item |
CN103631959A (en) * | 2013-12-17 | 2014-03-12 | 江苏名通信息科技有限公司 | Method for supporting million user data sub-meter based on Hash algorithm |
CN103793329A (en) * | 2012-10-26 | 2014-05-14 | 腾讯科技(北京)有限公司 | Method and device for data storage |
CN103929644A (en) * | 2014-04-01 | 2014-07-16 | Tcl集团股份有限公司 | Video fingerprint database building method and device and video fingerprint recognition method and device |
CN104050279A (en) * | 2014-06-27 | 2014-09-17 | Tcl集团股份有限公司 | Method and device for feature matching and image identification device |
WO2015127721A1 (en) * | 2014-02-25 | 2015-09-03 | 深圳市中兴微电子技术有限公司 | Data matching method and apparatus and computer storage medium |
WO2016070793A1 (en) * | 2014-11-04 | 2016-05-12 | Huawei Technologies Co., Ltd. | Memory addressing mechanism using buffer of hierarchy of collision free hash tables |
CN108347383A (en) * | 2018-02-05 | 2018-07-31 | 吴子仪 | A kind of concurrent multichannel routing inquiry implementation method based on assembly line |
CN109039911A (en) * | 2018-07-27 | 2018-12-18 | 烽火通信科技股份有限公司 | It is a kind of to search the method and system that mode shares RAM based on HASH |
CN111177198A (en) * | 2019-12-27 | 2020-05-19 | 芯启源(南京)半导体科技有限公司 | Content searching method for chip |
CN117544598A (en) * | 2024-01-03 | 2024-02-09 | 成都电科星拓科技有限公司 | I2C bus address automatic allocation method |
Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030204703A1 (en) * | 2002-04-25 | 2003-10-30 | Priya Rajagopal | Multi-pass hierarchical pattern matching |
CN1794236A (en) * | 2004-12-21 | 2006-06-28 | 英特尔公司 | Efficient CAM-based techniques to perform string searches in packet payloads |
CN102147798A (en) * | 2010-02-10 | 2011-08-10 | 华为技术有限公司 | Method and device for handling Hashed search conflicts |
-
2011
- 2011-09-19 CN CN 201110276822 patent/CN102364463B/en active Active
Patent Citations (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030204703A1 (en) * | 2002-04-25 | 2003-10-30 | Priya Rajagopal | Multi-pass hierarchical pattern matching |
CN1794236A (en) * | 2004-12-21 | 2006-06-28 | 英特尔公司 | Efficient CAM-based techniques to perform string searches in packet payloads |
CN102147798A (en) * | 2010-02-10 | 2011-08-10 | 华为技术有限公司 | Method and device for handling Hashed search conflicts |
Cited By (20)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102694798A (en) * | 2012-05-15 | 2012-09-26 | 浪潮电子信息产业股份有限公司 | Method for high-speed serial interconnection based on Hash mapping table |
CN103793329A (en) * | 2012-10-26 | 2014-05-14 | 腾讯科技(北京)有限公司 | Method and device for data storage |
CN103227751A (en) * | 2013-05-14 | 2013-07-31 | 盛科网络(苏州)有限公司 | Method and device for improving spatial utilization ratio of forwarding table item |
CN103631959A (en) * | 2013-12-17 | 2014-03-12 | 江苏名通信息科技有限公司 | Method for supporting million user data sub-meter based on Hash algorithm |
US10671667B2 (en) | 2014-02-25 | 2020-06-02 | Sanechips Technology Co., Ltd. | Data matching method and apparatus and computer storage medium |
WO2015127721A1 (en) * | 2014-02-25 | 2015-09-03 | 深圳市中兴微电子技术有限公司 | Data matching method and apparatus and computer storage medium |
CN103929644A (en) * | 2014-04-01 | 2014-07-16 | Tcl集团股份有限公司 | Video fingerprint database building method and device and video fingerprint recognition method and device |
CN103929644B (en) * | 2014-04-01 | 2018-08-31 | Tcl集团股份有限公司 | A kind of video finger print library establishes, video fingerprint recognition method and device |
CN104050279B (en) * | 2014-06-27 | 2018-03-06 | Tcl集团股份有限公司 | The method, apparatus and image recognition apparatus of a kind of characteristic matching |
CN104050279A (en) * | 2014-06-27 | 2014-09-17 | Tcl集团股份有限公司 | Method and device for feature matching and image identification device |
CN107077419A (en) * | 2014-11-04 | 2017-08-18 | 华为技术有限公司 | Use the memory addressing mechanism of the buffer of Lothrus apterus hash table level |
US9361238B2 (en) | 2014-11-04 | 2016-06-07 | Futurewei Technologies, Inc. | Memory addressing mechanism using a buffer of a hierarchy of collision free hash tables |
WO2016070793A1 (en) * | 2014-11-04 | 2016-05-12 | Huawei Technologies Co., Ltd. | Memory addressing mechanism using buffer of hierarchy of collision free hash tables |
CN107077419B (en) * | 2014-11-04 | 2020-02-14 | 华为技术有限公司 | Method, apparatus and system for storing an address associated with a data element |
CN108347383A (en) * | 2018-02-05 | 2018-07-31 | 吴子仪 | A kind of concurrent multichannel routing inquiry implementation method based on assembly line |
CN109039911A (en) * | 2018-07-27 | 2018-12-18 | 烽火通信科技股份有限公司 | It is a kind of to search the method and system that mode shares RAM based on HASH |
CN111177198A (en) * | 2019-12-27 | 2020-05-19 | 芯启源(南京)半导体科技有限公司 | Content searching method for chip |
CN111177198B (en) * | 2019-12-27 | 2023-06-16 | 芯启源(南京)半导体科技有限公司 | Content searching method for chip |
CN117544598A (en) * | 2024-01-03 | 2024-02-09 | 成都电科星拓科技有限公司 | I2C bus address automatic allocation method |
CN117544598B (en) * | 2024-01-03 | 2024-03-29 | 成都电科星拓科技有限公司 | I2C bus address automatic allocation method |
Also Published As
Publication number | Publication date |
---|---|
CN102364463B (en) | 2013-07-10 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN102364463B (en) | Hash-based method for searching CAM (central address memory) | |
US6633953B2 (en) | Range content-addressable memory | |
US9269411B2 (en) | Organizing data in a hybrid memory for search operations | |
CN102377664B (en) | TCAM (ternary content addressable memory)-based range matching device and method | |
US6957215B2 (en) | Multi-dimensional associative search engine | |
Waldvogel et al. | Scalable high-speed prefix matching | |
CN101141389B (en) | Reinforcement multidigit Trie tree searching method and apparatus | |
WO2011035595A1 (en) | Method and apparatus for hash look-up table | |
CN104303482A (en) | A method and apparatus for packet classification | |
CN1327674C (en) | Double stack compatible router searching device supporting access control listing function on core routers | |
CN104077297B (en) | Query method and query device based on body | |
Yang et al. | Practical multituple packet classification using dynamic discrete bit selection | |
CN100442255C (en) | Associative memory with entry groups and skip operations | |
CN104158744A (en) | Method for building table and searching for network processor | |
US20140358886A1 (en) | Internal search engines architecture | |
CN100426791C (en) | Engine apparatus for route forwarding table address searching | |
CN101848248A (en) | Rule searching method and device | |
CN103414603B (en) | Ipv6 deep packet inspection method based on Hash method for folding | |
CN101500012B (en) | Packet classification method and system | |
CN103023782A (en) | Method and device for accessing ternary content addressable memory (TCAM) | |
CN102289453A (en) | TCAM (ternary content addressable memory) rule storing method, device and network equipment | |
Kuo et al. | A memory-efficient TCAM coprocessor for IPv4/IPv6 routing table update | |
JP5998381B2 (en) | Semiconductor memory device | |
CN105095100B (en) | A kind of hardware realizes the device of hash chained lists | |
CN103309950A (en) | Searching method for key value |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant |