Also known as "associative storage," content-addressable memory is a chip that provides fast table lookups, most notably in network routers and switches. For example, Internet routers search a lookup table millions of times per second to find the appropriate port to output packets to. When a set of search data is presented to content-addressable memory, the memory hardware delivers the results in one clock cycle.
Content-addressable memory (CAM) is constructed of SRAM cells (see static RAM
) but is considerably more expensive and holds much less data than regular SRAM chips. See routing protocol
, wild card
and table lookup
Direct Lookup Tables
Depending on the distribution of characters in a given set of data, lookup tables may be designed to find the data from the address. CAM is used in an opposite manner to find the address from the data.
Tables May Require a Lot of Comparing
A table may be designed as key-value pairs, wherein many keys are compared to find a match. In this example, packet addresses are the keys, and the port numbers are the values. In one clock cycle, the CAM hardware does the search and delivers the port number as the result.
Binary CAM vs. Ternary CAM
Binary CAM requires an exact match, while ternary CAM uses the X bit (don't care bit) for a wild card match. With ternary CAM, the address that matches the most bits is the one selected. This is known as "longest-prefix matching," the routing table lookup method of the Internet protocol.