4.1.13 · D3Memory Technologies

Worked examples — Content-addressable memory (CAM)

3,965 words18 min readBack to topic

We only need three facts from the parent, and we restate them so nothing is assumed:

Figure — Content-addressable memory (CAM)

Throughout, a row that matches = its match line is HIGH. The priority encoder then squeezes all the HIGH lines into one output address: the lowest row index wins (unless we say otherwise, e.g. longest-prefix routing). See Priority Encoder for that tie-breaker box, and Boolean Algebra & De Morgan's Laws for why "NOT any-mismatch = all-agree".


The scenario matrix

Every CAM search falls into one of these case-classes. The last column names the example that nails it.

# Case class What is special about it Example
A Exact single match (BCAM) Exactly one row equals the key Ex 1
B Total miss No row matches at all Ex 2
C Multiple matches, tie-break Two identical rows, encoder must choose Ex 3
D All-zero key (ordinary) vs all-masked stored (matches everything) The two "degenerate" inputs behave oppositely Ex 4
E Single-bit-off near miss Row differs by exactly one bit — still a full miss Ex 5
F TCAM don't-care in stored word Stored matches both 0 and 1 Ex 6
G TCAM masked search key (global mask) We search ignoring some bit positions Ex 7
H Longest-prefix routing (real-world) Many prefixes match; most specific wins Ex 8
I Limiting behaviour (timing/power) What "" really means as grow Ex 9
J Exam twist (encoder + power reasoning) Combine match-count with priority + energy Ex 10

Cell A — Exact single match


Cell B — Total miss


Cell C — Multiple matches, tie-break


Cell D — The two degenerate inputs, side by side


Cell E — Single-bit near miss


Cell F — TCAM don't-care in the stored word

Figure — Content-addressable memory (CAM)

Cell G — TCAM masked search key (global search mask)


Cell H — Longest-prefix routing (the real-world one)

Figure — Content-addressable memory (CAM)

Cell I — Limiting behaviour (what "" really means)


Cell J — Exam twist (encoder + power reasoning)


Recall Quick self-test on the matrix

Which case class is "a search key of all zeros"? ::: An ordinary key (Cell D, Part 1) — it matches only rows storing 0000, it does NOT match everything. Only masked storage matches everything. If three rows match, which address is returned? ::: The priority encoder's chosen one — lowest index by default, longest prefix in routing TCAMs. Does doubling the row count double the search time? ::: No — search stays cycles (parallel). It roughly doubles the energy per search. Can a stored 1X0X match 1010? ::: No — bit2 is an enforced 0 but the key has 1 there; a hard-bit mismatch kills it. In our convention, which end is bit0? ::: The leftmost bit. What does "wired-OR" compute on the match line? ::: The OR of all bit-mismatches — any single mismatching cell can drain the shared precharged line to LOW.