- Asked 2/22
- 2074 Asoj · 8 marks
Associative mapping and replacement algorithms
Short answer
Fully associative mapping allows a block to be placed in any cache line; the tag is compared with all lines in parallel. It avoids thrashing but requires a replacement algorithm when the cache is full because there is no fixed location for the incoming block.
Explain associative mapping technique. Give reasons why a replacement algorithm is required in the associative mapping technique.
Associative mapping
A main-memory block can be placed in any cache line. The address is split into Tag | Word; the tag is the full block number.
Address (16 bits)
+----------------------+--------+
| Tag 14b | Word 2b|
+----------+-----------+--------+
|
compare with ALL tags in parallel
+------+-----------+------+
| line0| tag0 | data |--= ?
| line1| tag1 | data |--= ?
| ... | ... | ... |--= ?
+------+-----------+------+--> hit / miss
Working: the tag is compared with the tags of all lines at the same time (associative or content-addressable memory). A match is a hit. On a miss the block is loaded into any free line; if the cache is full, a replacement algorithm (LRU, FIFO, LFU, random) chooses the line to remove.
Example: with 16 lines, blocks 0, 16, 32 and 5 can all stay in the cache together, because any line can hold any block.
- Merits: most flexible, best hit ratio, no thrashing.
- Demerits: needs one comparator per line (costly, slow, more power), long tag, and a replacement algorithm.
Why a replacement algorithm is required
- In associative mapping any block can go to any line, so when a miss occurs and all lines are full, the hardware must choose which existing block to remove. There is no fixed line for the new block as in direct mapping.
- A good choice keeps blocks that will be used soon. Common algorithms:
- LRU: replace the block unused for the longest time (best, uses locality).
- FIFO: replace the oldest block loaded.
- LFU: replace the block with the fewest references.
- Random: replace any line.
- The algorithm must be implemented in hardware to keep the cache fast. A poor choice reduces the hit ratio.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Why direct mapping needs no replacement · Computer Organization and Architecture, chapter 6 · asked 2×
- Replacement algorithm in associative mapping · Computer Organization and Architecture, chapter 6
- Associative mapping technique · Computer Organization and Architecture, chapter 6
- Mapping function and replacement algorithm · Computer Organization and Architecture, chapter 6
- Set associative mapping · Computer Organization and Architecture, chapter 6
- Associative cache mapping with example · Computer Organization and Architecture, chapter 6
- Associative vs set associative mapping · Computer Organization and Architecture, chapter 6
- Associative cache mapping · Embedded System, chapter 4 · asked 2×
- Reasons for replacement; strategy from AEC table · Engineering Economics, chapter 5 · asked 2×
- Cache write policy and replacement algorithm · Embedded System, chapter 4
All Computer Organization and Architecture chapter 6 questions →