Skip to content
Official PYQ · 2017

GATE CS 2017 Set 2 Q53 — Memory Hierarchy: Cache, Main Memory and Secondary Storage

Explain with AI
Consider a machine with a byte addressable main memory of 2322^{32} bytes divided into blocks of size 3232 bytes. Assume that a direct mapped cache having 512512 cache lines is used with this machine. The size of the tag field in bits is _______
View worked solution

Answer: 18

In a direct-mapped cache, the physical address is divided into three fields:

[ Tag ] [ Line Index ] [ Block Offset ]

Let's calculate the size of each field based on the given parameters:

  1. Total Physical Address Bits:
    The main memory is byte-addressable and has a size of 2322^{32} bytes.
    Physical Address Size=log⁡2(232)=32 bits\text{Physical Address Size} = \log_2(2^{32}) = 32\text{ bits}
  2. Block Offset Bits:
    The block size is 3232 bytes.
    Block Offset=log⁡2(32)=5 bits\text{Block Offset} = \log_2(32) = 5\text{ bits}
  3. Line Index Bits:
    The cache has 512512 cache lines.
    Line Index=log⁡2(512)=9 bits\text{Line Index} = \log_2(512) = 9\text{ bits}

Now, we can find the size of the tag field:

Tag Size=Total Physical Address Bits−(Line Index Bits+Block Offset Bits)=32−(9+5)=32−14=18 bits\begin{align*} \text{Tag Size} &= \text{Total Physical Address Bits} - (\text{Line Index Bits} + \text{Block Offset Bits}) \\ &= 32 - (9 + 5) \\ &= 32 - 14 \\ &= 18\text{ bits} \end{align*}

Thus, the size of the tag field is 18 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