Memory Hierarchy
For a direct-mapped cache with 32-bit addresses, 32 KB capacity and 64-byte lines, how many tag bits are there?
- A15 bits
- B19 bits
- C17 bits
Show answer and explanation
Answer: C. 17 bits
A 64-byte line = 2⁶, so the offset is 6 bits. The number of lines is 32 KB ÷ 64 B = 32,768 ÷ 64 = 512 = 2⁹, and in a direct-mapped cache each line is its own set, so the index is 9 bits. The rest is the tag: 32 − 9 − 6 = 17 bits. 19 bits would apply to a 4-way set-associative cache, where the index shrinks by 2 bits, not to a direct-mapped one.
- A. 15 bits results from mistaking the index for 11 bits.
- B. 19 bits applies if it were 4-way, with a quarter as many sets.
- C. Correct. 32 − 9 (index) − 6 (offset) = 17 bits.