Skip to main content

Cache management; direct vs associative address structure

Short answer

Cache management assigns memory blocks to cache lines, checks tags for hits, handles misses, and enforces write policy. Direct mapping uses tag, line, and word fields; the line field selects one line for a single comparison. Associative mapping uses only tag and word; all tags are compared simultaneously, requiring longer tags and more hardware.

Why is cache management necessary in the mapping process? Differentiate between direct mapping address structure and associative mapping address structure.

Need for cache management

The cache is much smaller than main memory, so only some blocks can be stored. A mapping process is needed to decide where a block goes and how to find it again. Cache management does this job: it checks tags for a hit or miss, loads blocks on a miss, chooses a victim (replacement algorithm), keeps cache and memory consistent (write policy), and maintains valid and dirty bits. Without it the CPU could not know whether the cache holds the wanted word, nor keep the data correct.

Address structure

Example: 16-bit address, block of 4 words, cache of 16 lines.

PointDirect mappingAssociative mapping
FieldsTag, Line, WordTag, Word
Example sizes10, 4, 2 bits14, 2 bits
Meaning of tagHigher-order bits that identify one of the blocks sharing the lineThe complete block number
Line fieldSelects the single line to checkNone, all lines are searched
Tag lengthShorterLonger, so the tag memory is larger
SearchOne comparisonComparison with every tag
Direct:       | Tag 10b | Line 4b | Word 2b |
Associative:  | Tag 14b          | Word 2b |

✓ Answer checked by Claude Opus 5.5 (high effort)

All Computer Organization and Architecture chapter 6 questions →