Content-Addressable Memory
Content-addressable memory searches all its stored words in parallel and returns where a match is found, rather than reading by address.
Search Instead of Read
Ordinary RAM answers the question 'what is stored at this address?' A content-addressable memory (CAM) answers the reverse: 'which address, if any, holds this data?' You present a search word, and every stored entry compares itself against it simultaneously. Matching rows assert a match line; a priority encoder converts those lines into an address.
Because all entries compare in parallel, a CAM finds a match in one cycle regardless of table size. That speed is its whole reason to exist, and it comes at a real cost in area and power.
Binary and Ternary CAM
A binary CAM stores 0s and 1s and matches exactly. A ternary CAM (TCAM) adds a third 'don't care' state per bit, so an entry can match a range of search words. TCAM is the backbone of network routers, where longest-prefix matching on IP addresses needs exactly this wildcard behavior.
- Parallel compare across all rows in one cycle
- Match lines feed a priority encoder for the result address
- TCAM adds per-bit wildcards for range and prefix matching
Inside the Cell
A CAM cell combines a storage element with comparison logic. Each cell pulls the row's match line low if its stored bit disagrees with the corresponding search bit; a row stays matched only if every cell agrees. Because match lines are precharged and then conditionally discharged across many cells, CAM draws far more power than plain SRAM of the same capacity.
Where It Appears
The most familiar on-chip CAM is the tag store of a set-associative cache and the translation lookaside buffer (TLB), which must check many possible entries against an address at once. Outside processors, TCAM sits at the heart of high-speed routers and firewalls, classifying packets against thousands of rules in a single lookup.
Because of its power and area cost, CAM is reserved for cases where parallel search genuinely pays: small, fast, hot tables rather than bulk storage.