Question

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

Official answer and solution
Official answer
18
From
Official GATE 2017 answer key

Solution

Decompose the physical address into Tag, Cache Line Index, and Block Offset fields.

Given parameters:

  • Byte-addressable main memory size =232= 2^{32} bytes   ⟹  \implies Physical Address =32= 32 bits.
  • Cache block size =32= 32 bytes =25= 2^5 bytes   ⟹  \implies Block Offset =5= 5 bits.
  • Number of cache lines in direct-mapped cache =512=29  ⟹  = 512 = 2^9 \implies Cache Index =9= 9 bits.

In a direct-mapped cache, the physical address is partitioned as:

Physical Address (32 bits)=Tag+Index+Offset\text{Physical Address (32 bits)} = \text{Tag} + \text{Index} + \text{Offset}
Tag=32−(Index+Offset)=32−(9+5)=32−14=18 bits\text{Tag} = 32 - (\text{Index} + \text{Offset}) = 32 - (9 + 5) = 32 - 14 = 18 \text{ bits}

Thus, the size of the tag field is 18 bits.

Final answer

18

Common trap

Confusing line index with word offset or forgetting that cache size in lines gives 292^9 directly.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2017 Computer Science and Information Technology (CS) Session 2
Question
53 of 65, printed as CS Q.53
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.