Question

The width of the physical address on a machine is 40 bits. The width of the tag field in a 512 KB 8-way set associative cache is ________ bits.

Official answer and solution
Official answer
24
From
Official GATE 2016 answer key

Solution

Use the relationship between total cache capacity, associativity, and physical address bits to find the tag width.

Given parameters:

  • Physical address width =40= 40 bits.
  • Cache capacity =512 KB=219= 512\text{ KB} = 2^{19} bytes.
  • Set associativity P=8=23P = 8 = 2^3 ways.

Let B=2bB = 2^b be the block size in bytes. The physical address is partitioned into:

Physical Address (40 bits)=[Tag]+[Set Index]+[Block Offset]\text{Physical Address (40 bits)} = [\text{Tag}] + [\text{Set Index}] + [\text{Block Offset}]

where the block offset field has bb bits.

Calculate the number of sets SS in the cache:

S=Cache SizeAssociativity×Block Size=21923×2b=2162b=216−bS = \frac{\text{Cache Size}}{\text{Associativity} \times \text{Block Size}} = \frac{2^{19}}{2^3 \times 2^b} = \frac{2^{16}}{2^b} = 2^{16 - b}

The number of index bits required to address the sets is:

Index bits=log⁡2(S)=16−b\text{Index bits} = \log_2(S) = 16 - b

Now compute the tag field width:

Tag bits=Address bits−(Index bits+Offset bits)\text{Tag bits} = \text{Address bits} - (\text{Index bits} + \text{Offset bits})
Tag bits=40−((16−b)+b)=40−16=24 bits\text{Tag bits} = 40 - ((16 - b) + b) = 40 - 16 = 24 \text{ bits}

Notice that the block size bb cancels out completely. The tag width is 24 bits.

Final answer

24

Common trap

Assuming the block size must be known, or miscalculating the number of sets by omitting associativity.

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

Source

Paper
GATE 2016 Computer Science and Information Technology (CS) Session 2
Question
42 of 65, printed as CS Q.32
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.