Question

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 KB32\text{ KB} (1 KB=210 bytes1\text{ KB} = 2^{10}\text{ bytes}), and each cache block is of size 64 bytes64\text{ bytes}.

The size of the tag field is ___________ bits.

Official answer and solution
Official answer
17
From
Official GATE 2021 answer key

Solution

Decompose the 32-bit physical address into Tag, Line/Index, and Block Offset fields for a direct-mapped cache.

Given parameters:

  • Byte-addressable memory of size 2322^{32} bytes   ⟹  \implies Physical Address size is 32 bits.
  • Cache block (line) size =64 bytes=26= 64\text{ bytes} = 2^6 bytes   ⟹  \implies Block offset field =6= 6 bits.
  • Total cache size =32 KB=32×210=215= 32\text{ KB} = 32 \times 2^{10} = 2^{15} bytes.

In a direct-mapped cache, the number of cache blocks (lines) is:

Number of lines=Cache sizeBlock size=21526=29=512\text{Number of lines} = \frac{\text{Cache size}}{\text{Block size}} = \frac{2^{15}}{2^6} = 2^9 = 512

Thus, the Line Index field requires log⁡2(29)=9\log_2(2^9) = 9 bits.

The tag field size is obtained by subtracting the index and offset bits from the total address width:

Tag bits=32−(Index bits+Block offset bits)=32−(9+6)=32−15=17 bits\text{Tag bits} = 32 - (\text{Index bits} + \text{Block offset bits}) = 32 - (9 + 6) = 32 - 15 = 17\text{ bits}
Final answer

17

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

Source

Paper
GATE 2021 Computer Science and Information Technology (CS, Set-1)
Question
32 of 65, printed as CS Q.22
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.