Skip to content
Official PYQ · 2021

GATE CS 2021 Set 1 Q22 — Memory Hierarchy: Cache, Main Memory and Secondary Storage

Explain with AI
Consider a computer system with a byte-addressable primary memory of size 2322^{32} bytes. Assume the computer system has a direct-mapped cache of size 32 KB\text{32 KB} (1 KB\text{1 KB} = 2102^{10} bytes), and each cache block is of size 6464 bytes.

The size of the tag field is __________ bits.
View worked solution

Answer: 17 : 17

To find the size of the tag field, we analyze the structure of the physical address for a direct-mapped cache.

The physical address is divided into three fields:

Physical Address=Tag+Index (Line Offset)+Block Offset\text{Physical Address} = \text{Tag} + \text{Index (Line Offset)} + \text{Block Offset}

1. Physical Address Size

  • Primary memory size = 2322^{32} bytes
  • Since the memory is byte-addressable, the physical address size is log⁡2(232)=32\log_2(2^{32}) = 32 bits.

2. Block Offset

  • Each cache block size = 64 bytes=2664\text{ bytes} = 2^6 bytes
  • Therefore, the block offset requires log⁡2(26)=6\log_2(2^6) = 6 bits.

3. Index (Line Offset)

  • Cache size = 32 KB=32×210 bytes=21532\text{ KB} = 32 \times 2^{10}\text{ bytes} = 2^{15} bytes
  • Number of cache lines = Cache SizeBlock Size=21526=29\frac{\text{Cache Size}}{\text{Block Size}} = \frac{2^{15}}{2^6} = 2^9 lines
  • Therefore, the index field requires log⁡2(29)=9\log_2(2^9) = 9 bits.

4. Tag Field Size

Tag size=Physical Address size−(Index bits+Block Offset bits)=32−(9+6)=32−15=17 bits\begin{aligned}\text{Tag size} &= \text{Physical Address size} - (\text{Index bits} + \text{Block Offset bits}) \\&= 32 - (9 + 6) \\&= 32 - 15 \\&= 17\text{ bits}\end{aligned}

Alternatively, for a direct-mapped cache, the tag size can be calculated directly as:

Tag size=log⁡2(Primary Memory SizeCache Size)=log⁡2(232215)=17 bits\text{Tag size} = \log_2\left(\frac{\text{Primary Memory Size}}{\text{Cache Size}}\right) = \log_2\left(\frac{2^{32}}{2^{15}}\right) = 17\text{ bits}

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Memory Hierarchy: Cache, Main Memory and Secondary Storage questions