COA Notes
Content-addressable memory (CAM), parallel search, applications in TLBs and cache tags.
Introduction
Conventional memory is addressed by location — you provide an address and get back data. Associative memory (also called Content-Addressable Memory or CAM) works differently: you provide a piece of data (or a pattern), and the memory tells you if and WHERE that data is stored — all in parallel, in a single cycle. This parallel search capability makes associative memory essential for cache tag lookup, TLB translation, and network routing, despite its higher cost.
How Associative Memory Works
In conventional RAM: "What's stored at address 5?" → Returns data at location 5 In associative memory: "Is the value 0x3FA7 stored anywhere?" → Returns the match location (or all matching locations)
Internal Structure
Each cell in associative memory contains:
- Storage (flip-flop to hold the bit)
- Comparison logic (XOR gate to compare with search input)
All cells compare simultaneously — this is what enables single-cycle parallel search.
| Search Key | [1][0][1][1][0][1] |
| Entry 0: [1][0][1][1][0][1] | Match! ✓ |
| Entry 1: [0][1][0][1][1][0] | No match ✗ |
| Entry 2: [1][0][1][0][0][1] | No match ✗ |
| Entry 3: [1][0][1][1][0][1] | Match! ✓ |
Match Logic
For each entry, a match line goes high only if ALL bits match:
If any bit differs, the match line for that entry is pulled low.
Masking
A mask register allows partial matching — masked bit positions are ignored during comparison:
Only the unmasked positions are compared. This enables searching by partial keys.
Associative Memory vs Conventional RAM
| Feature | Conventional RAM | Associative Memory (CAM) |
|---|---|---|
| Access method | By address | By content (search key) |
| Search time | O(n) for linear search | O(1) — constant time |
| Hardware per bit | 1 transistor (DRAM) or 6 (SRAM) | 9-12 transistors |
| Cost | Low | High (2-3× SRAM) |
| Power | Low | High (all cells active during search) |
| Typical size | GB | KB (very small) |
| Use case | Data storage | Fast lookup/search |
Applications
TLB (Translation Lookaside Buffer)
The TLB is the quintessential use of associative memory:
- Search key: Virtual Page Number
- Stored data: Physical Frame Number + permissions
- Fully associative (any translation can be in any entry)
- ~32-512 entries, searched every memory access
Cache Tag Arrays
- Cache tags compared against address tag in parallel
- Fully associative caches use CAM for all tag comparisons
- Set-associative caches use small CAMs within each set
Network Routers
- Routing tables searched by destination address
- Ternary CAM (TCAM) supports wildcards for prefix matching
- Enables wire-speed packet classification
Pattern Matching
- Intrusion detection systems
- DNA sequence databases
- AI associative recall
Ternary CAM (TCAM)
Standard CAM matches on 0 and 1. TCAM adds a third state: don't care (X). Each cell can be set to 0, 1, or X. During comparison, X positions always match regardless of the search key.
This is particularly useful for:
- Network routing (IP prefix matching: 192.168.X.X)
- Firewall rules with wildcards
- Access control lists
Hardware Cost and Power
The main drawback of associative memory is cost and power:
- Each cell needs comparison circuitry (~12 transistors vs 6 for SRAM)
- Every search activates ALL cells simultaneously (high dynamic power)
- This limits practical size to a few thousand entries
Power-saving techniques:
- Search only when needed (clock-gated)
- Segmented search (check portions sequentially)
- Hybrid designs (hashed index + small associative check)
Key Takeaways
- Associative memory searches by content, not by address — parallel comparison in one cycle
- Each cell has storage plus comparison logic, making it 2× more expensive than SRAM
- The TLB is the most critical application — enables fast virtual-to-physical address translation
- CAM provides O(1) search time regardless of the number of entries
- TCAM extends CAM with don't-care bits for pattern matching with wildcards
- High cost and power limit associative memory to small, performance-critical uses (TLBs, cache tags, routers)
- Despite being expensive, the performance benefit of parallel search makes CAM indispensable in modern CPUs
Exam Focus
Revise definitions, diagrams, examples, and short-answer points for Associative Memory.
Interview Use
Prepare one clear explanation, one practical example, and one common mistake for this Computer Organization & Architecture topic.
Search Terms
computer-organization, computer organization & architecture, computer, organization, memory, associative, associative memory
Related Computer Organization & Architecture Topics