Question

An 8-way set associative cache of size 64 KB (1 KB=1024 bytes1\text{ KB} = 1024\text{ bytes}) is used in a system with 32-bit address. The address is sub-divided into TAG, INDEX, and BLOCK OFFSET.

The number of bits in the TAG is _______.

Official answer and solution
Official answer
19
From
Official GATE 2023 answer key

Solution

Express total cache size in terms of tag, index, and block offset bits in a 32-bit address space.

  1. The 32-bit physical address is partitioned into:

    Address bits (32)=TAG+INDEX+BLOCK OFFSET\text{Address bits (32)} = \text{TAG} + \text{INDEX} + \text{BLOCK OFFSET}
  2. Let block size be B=2bB = 2^b bytes (so BLOCK OFFSET=b\text{BLOCK OFFSET} = b bits) and number of sets be S=2sS = 2^s (so INDEX=s\text{INDEX} = s bits).

  3. Cache capacity with 8-way set associativity is:

    Capacity=S×8×B=64 KB=216 bytes\text{Capacity} = S \times 8 \times B = 64\text{ KB} = 2^{16}\text{ bytes}

    Dividing by the associativity 8 (232^3):

    S×B=21623=213 bytesS \times B = \frac{2^{16}}{2^3} = 2^{13}\text{ bytes}

    Therefore, 2s+b=213  ⟹  s+b=13 bits2^{s + b} = 2^{13} \implies s + b = 13\text{ bits}.

  4. Thus, the sum of INDEX and BLOCK OFFSET bits is always 13, independent of the individual block size!

  5. The number of bits in the TAG is:

    TAG=32−(s+b)=32−13=19 bits\text{TAG} = 32 - (s + b) = 32 - 13 = 19\text{ bits}
Final answer

19

Common trap

Thinking the question is missing block size; the product of sets and block size is fixed by total cache capacity divided by set associativity.

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

Source

Paper
GATE 2023 Computer Science and Information Technology (CS)
Question
64 of 65
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.