For a direct-mapped cache, 4 bits are used for the tag field and 12 bits are…
2025
For a direct-mapped cache, 4 bits are used for the tag field and 12 bits are used to index into a cache block. The size of each cache block is one byte. Assume that there is no other information stored for each cache block.
Which ONE of the following is the CORRECT option for the sizes of the main memory and the cache memory in this system (byte addressable), respectively?
- A.
64 KB and 4 KB
- B.
128 KB and 16 KB
- C.
64 KB and 8 KB
- D.
128 KB and 6 KB
Attempted by 343 students.
Show answer & explanation
Correct answer: A
Key breakdown of address fields: tag bits = 4, index bits = 12, block offset bits = log2(block size) = log2(1) = 0.
Main memory size: total address bits = 4 + 12 + 0 = 16, so main memory = 2^16 bytes = 65,536 bytes = 64 KB.
Cache size (data only):
Number of cache lines = 2^index = 2^12 = 4096.
Each line stores one byte, so cache data size = 4096 × 1 B = 4096 B = 4 KB.
Note on tags and other metadata: the question specifies that no other information is stored per cache block, so we report the data-only cache size. If tag bits were to be stored in the cache, tag storage would be 4096 lines × 4 bits = 16,384 bits = 2048 bytes = 2 KB, and the total including tags would be 4 KB + 2 KB = 6 KB.
Final answer: main memory = 64 KB, cache memory = 4 KB.
A video solution is available for this question — log in and enroll to watch it.