Calculating direct-mapped cache tag storage
Cache Memory

Answer & solution
Official answer: A
Step through it (7 steps)
Approach: Split an address into tag, cache-line index and byte offset; then multiply tag width by the number of lines.
A 16-byte block requires log₂16=4 offset bits. The cache contains 16 KiB/16 bytes=214/24=210 lines, so direct mapping requires 10 index bits to select a line.
From the 20 address bits, the remaining tag width is 20−10−4=6 bits. Every line needs its own stored tag to distinguish the main-memory blocks that map to that line. Therefore total tag storage is 210×6=6144 bits, option A.
This is a bit count, not a byte count. The 16 KiB cache size describes data capacity; valid bits, dirty bits and other control metadata are not part of the requested tag values. Ignoring the block offset or using the number of bytes instead of lines would produce the wrong tag width or multiplier.



![Question 71, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
for(j=0;j<1024;j++) ARR[i][j]=0.0;
What is the total tag storage in the cache directory?
(A) 32 Kibits
(B) 34 Kibits
(C) 64 Kibits
(D) 68 Kibits](../../../assets/questions/CS-2008-Q71-1.webp)
![Question 71, GATE 2008: A machine has a 64-KiB, two-way set-associative data cache with 16-byte blocks, managed using 32-bit virtual addresses; pages are 4 KiB. A row-major double ARR[1024][1024] starts at the beginning of virtual page 0xFF000. A double occupies 8 bytes. The cache is initially empty, there is no prefetching, and only ARR causes data-memory references. The code is:
for(i=0;i<1024;i++)
for(j=0;j<1024;j++) ARR[i][j]=0.0;
What is the total tag storage in the cache directory?
(A) 32 Kibits
(B) 34 Kibits
(C) 64 Kibits
(D) 68 Kibits](../../../assets/questions/CS-2008-Q71-2.webp)

