CAM (content-addressable memory)

acronym

networking

Kept in this browser · My desk

Stands for: content-addressable memory: a memory that compares a search word with every stored word at once and returns where it matched

A memory searched by content rather than by address: it compares a search word with every stored word in parallel and returns the location of the match, in a single clock cycle.

CAM gave the switch's MAC table one of its names, the CAM table, still used in Cisco's commands. Pagiamtzis and Sheikholeslami's 2006 survey describes a CAM as a memory that implements the lookup-table function in a single clock cycle with dedicated comparison circuitry, popular in routers for packet forwarding and classification, and names its cost: the power drawn by so much parallel circuitry. A binary CAM matches exact keys, which is what a MAC table needs; the ternary kind, TCAM, adds a don't-care state for prefixes and access lists.

What it is. A content-addressable memory (CAM) inverts the question a random-access memory (RAM) answers. A RAM is given an address and returns the word stored there; a CAM is given a word and returns the address, or addresses, where that word is stored, comparing the search word with every stored word at once. Pagiamtzis and Sheikholeslami's survey in the IEEE (Institute of Electrical and Electronics Engineers) Journal of Solid-State Circuits (March 2006) likens it to the tag half of a fully associative cache, with one difference: a cache expects a single match and reads its data directly, while a large CAM may find several and needs a priority encoder to choose.

How it works. Each stored word has its own match line; the search word is driven onto search lines that reach every word, every word compares at once, and an encoder (a priority encoder where several may match) returns the matching location. In the survey's description a search begins by loading the search word into registers and precharging every match line high, putting all of them temporarily in the match state; then the search-line drivers broadcast the word, each core cell compares its stored bit with the bit on its search lines, match lines with even one mismatching bit discharge to ground, and match line sense amplifiers report which stayed high. The cells are built on static RAM (SRAM) storage: the common NOR-type cell uses 10 transistors and the NAND-type 9, six of them the SRAM cell and its access transistors. The survey's rule of thumb for capacity, that the largest available CAM chip is about half the size of the largest SRAM chip, rests on a typical CAM cell consisting of two SRAM cells. In 2006 the largest commercial single-chip CAMs held 18 Mbit and the largest reported in the literature 9 Mbit; the survey puts typical sizes of the time between a few hundred and 32K entries and word widths of 36 to 144 bits, and plots published capacities from 1985 to 2004 growing exponentially, like other memories.

Worked lookup. The survey's routing example uses four 5-bit entries, some with "X" (don't care) bits, followed by a RAM of output ports. The destination 01101 matches entries 2 and 3; the priority encoder picks the upper one, entry 2, which has the fewest X bits, the longest prefix; its location, 01, is the address of a RAM word that holds the output port, port B. The CAM finds; the RAM holds the associated data. A MAC (media access control) table built this way would store a 48-bit address plus a VLAN (virtual local area network) identifier as the key and keep the port in RAM.

Binary and ternary. A binary CAM matches exact keys, which is what a MAC table needs; the ternary kind, TCAM (ternary content-addressable memory), stores an X state as well, so one entry can match a prefix or a masked pattern, which is what routes and access control lists (ACLs) need. The flexibility costs more transistors per bit and more power per search.

Why switches moved on. A content-addressable search is fast but expensive in silicon area and power, so the large MAC tables of modern switches are mostly built differently: Extreme's event messages say the hardware FDB (forwarding database) "is organized as a hash table" and log entries refused because their hash bucket is full while other buckets still have room, Huawei lets the administrator choose a hash based on a cyclic redundancy check (CRC) for the MAC table, and Arista documents hash collisions in the hardware table, with a command from EOS 4.31.0F (29 November 2023) listing the addresses not learned because of them. Juniper's unified forwarding table shares one memory between MAC, host and LPM (longest prefix match) entries and keeps TCAM for longest prefix match. Before any of this, Digital's 1983 bridge kept learned addresses in an ordinary look-up RAM searched by a lookup controller; Alan Kirby's account of it describes a lookup engine of programmable array logic with dedicated static RAM for the 48-bit addresses.

The name that stayed. The name stayed: Cisco's 17.12 command reference still prints "CAM-table", and one line even expands it as "Counter-Addressable Memory", a slip for content-addressable. Engineers say "CAM table" for the MAC address table whatever memory holds it, so the word in a log or a command says nothing about the silicon.

What goes wrong. A hash table can be full for one address while it has room for others, so a switch can refuse to learn a particular station long before its advertised capacity, and the result is the same unknown unicast flooding as a genuinely full table. Power is the other limit: every search activates every match line, which is why the survey's main concern is match line power and why designers keep CAM for the lookups that need it. Neighbours: TCAM, the MAC address table, hash function, ASIC (application-specific integrated circuit) and unknown unicast flooding.

Also known as: cam, content addressable memory, associative memory, memória endereçável por conteúdo

Sources

← Back to C Back to the glossary