Memory Hierarchy
How many sets does a 4-way set-associative cache with 32-bit addresses, 32 KB capacity and 64-byte lines have?
- A128
- B512
- C32
Show answer and explanation
Answer: A. 128
The number of lines is. A 4-way cache holds four lines per set, so there aresets, giving a 7-bit index and a 32 − 7 − 6 = 19-bit tag. 512 is the line count itself, which equals the set count only when direct-mapped. Raising associativity reduces the number of sets, which adds tag bits and comparators. 32 comes from dividing the 128 sets by the four ways a second time.
- A. Correct. 512 lines ÷ 4 ways = 128 sets.
- B. 512 is the line count, the set count for a direct-mapped cache.
- C. 32 is not the set count but the result of a wrong division.