- 2073 Shrawan · 5 marks
Set associative mapping
Short answer
Set associative mapping divides cache into sets, each with k lines. A block maps to a fixed set (direct mapping) but can occupy any line within the set (associative mapping); tags of the k lines are compared in parallel. This reduces conflict misses compared to direct mapping while using only k comparators.
Describe how set associative mapping combines the features of direct and associative mapping techniques.
Set associative mapping divides the cache into sets, each with k lines (k-way). It combines direct mapping (a block maps to one fixed set, found by index) with associative mapping (inside the set the block may go to any of the k lines).
How it combines the two
| Feature | From direct mapping | From associative mapping |
|---|---|---|
| Choosing the place | Set number = block mod number of sets (like the line index) | - |
| Placement inside the place | - | Any line of the set, tags of the k lines are compared in parallel |
| Search cost | Only k comparators, not one per line | Associative search within the set |
| Replacement | - | Needed only inside the set (LRU, FIFO) |
Address (16 bits)
+-----------+---------+--------+
| Tag 11b | Set 3b | Word 2b|
+-----------+----+----+--------+
|
+---------v---------+
| Set i: way0 way1 | 2-way: compare 2 tags
+---------+---------+
v
hit / miss
Example (2-way): 16 lines in 8 sets of 2. Blocks 0, 8 and 16 all map to set 0, but two of them can be present together; the third needs a replacement (LRU/FIFO) within that set.
- Merits: fewer conflict misses than direct mapping, cheaper than fully associative (only k comparators).
- Demerits: more complex than direct mapping, and a replacement algorithm is needed inside each set.
Special cases: k = 1 gives direct mapping, and k = number of lines (one set) gives fully associative mapping. A 2-way or 4-way cache gives most of the hit ratio of associative mapping at a cost near direct mapping.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Associative vs set associative mapping · Computer Organization and Architecture, chapter 6
- Write policy; direct vs associative mapping · Computer Organization and Architecture, chapter 6
- Cache mapping techniques · Computer Organization and Architecture, chapter 6 · asked 7×
- Cache management; direct vs associative address structure · Computer Organization and Architecture, chapter 6
- Associative mapping and replacement algorithms · Computer Organization and Architecture, chapter 6 · asked 2×
- Associative cache mapping with example · Computer Organization and Architecture, chapter 6
- Cache memory mapping techniques · Embedded System, chapter 4 · asked 3×
- Associative cache mapping · Embedded System, chapter 4 · asked 2×
- Direct, iterative methods; Gauss-Seidel numerical · Computational Techniques in Civil Engineering, chapter 2
All Computer Organization and Architecture chapter 6 questions →