In a cache memory, if address has 9 bits in Tag field and 12 bits in index…
2022
In a cache memory, if address has 9 bits in Tag field and 12 bits in index field, the size of main memory and cache memory would be respectively
- A.
2 K,4 K
- B.
1024 K,2 K,
- C.
4 K,2048 K
- D.
2048 K,4 K
Attempted by 450 students.
Show answer & explanation
Correct answer: D
Key idea: total address bits = tag + index + block offset.
Assume byte-addressable memory and no block offset given. This implies block offset = 0 (block size = 1 byte).
Main memory size = 2^(tag + index + offset) bytes = 2^(9 + 12 + 0) = 2^21 bytes = 2,097,152 bytes = 2048 K.
Number of cache lines = 2^(index) = 2^12 = 4096 lines. With 1-byte blocks, cache size = 4096 × 1 byte = 4096 bytes = 4 K.
Conclusion: main memory = 2048 K and cache memory = 4 K.
Note: If a non-1-byte block size were intended, the block offset must be specified. The general formulas are main memory size = 2^(tag+index+offset) bytes and cache size = 2^(index) × (block size).
A video solution is available for this question — log in and enroll to watch it.