Skip to content
Official PYQ · 2017

GATE CS 2017 Set 1 Q54 — Memory Hierarchy: Cache, Main Memory and Secondary Storage

Explain with AI
A cache memory unit with capacity of NN words and block size of BB words is to be designed. If it is designed as a direct mapped cache, the length of the TAG\textsf{TAG} field is 1010 bits. If the cache unit is now designed as a 1616-way set-associative cache, the length of the TAG\textsf{TAG} field is ____________ bits.
View worked solution

Answer: 14

To find the length of the TAG\text{TAG} field for the 1616-way set-associative cache, we can analyze how the physical address bits are partitioned in both cache designs.

1. Direct-Mapped Cache

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

Physical Address=TAGdirect+Indexdirect+Block Offset\text{Physical Address} = \text{TAG}_{\text{direct}} + \text{Index}_{\text{direct}} + \text{Block Offset}
  • Let the capacity of the cache be NN words and the block size be BB words.
  • The number of cache blocks is C=NBC = \frac{N}{B}.
  • The number of index bits is log⁡2(C)=log⁡2(NB)\log_2(C) = \log_2\left(\frac{N}{B}\right).
  • The number of block offset bits is log⁡2(B)\log_2(B).

Given that TAGdirect=10\text{TAG}_{\text{direct}} = 10 bits, the total physical address size AA is:

A=10+log⁡2(NB)+log⁡2(B)=10+log⁡2(N)A = 10 + \log_2\left(\frac{N}{B}\right) + \log_2(B) = 10 + \log_2(N)

2. 16-Way Set-Associative Cache

In a 1616-way set-associative cache, the physical address is divided as:

Physical Address=TAGset+Indexset+Block Offset\text{Physical Address} = \text{TAG}_{\text{set}} + \text{Index}_{\text{set}} + \text{Block Offset}
  • The number of sets in the cache is S=C16=N16BS = \frac{C}{16} = \frac{N}{16B}.
  • The number of index bits is: Indexset=log⁡2(S)=log⁡2(N16B)=log⁡2(NB)−4\text{Index}_{\text{set}} = \log_2(S) = \log_2\left(\frac{N}{16B}\right) = \log_2\left(\frac{N}{B}\right) - 4
  • The block offset remains the same: log⁡2(B)\log_2(B) bits.

3. Calculating the New TAG Field

Since the physical address size AA remains constant:

A=TAGset+Indexset+Block OffsetA = \text{TAG}_{\text{set}} + \text{Index}_{\text{set}} + \text{Block Offset} A=TAGset+[log⁡2(NB)−4]+log⁡2(B)A = \text{TAG}_{\text{set}} + \left[\log_2\left(\frac{N}{B}\right) - 4\right] + \log_2(B) A=TAGset+log⁡2(N)−4A = \text{TAG}_{\text{set}} + \log_2(N) - 4

Equating the two expressions for the physical address size AA:

10+log⁡2(N)=TAGset+log⁡2(N)−410 + \log_2(N) = \text{TAG}_{\text{set}} + \log_2(N) - 4 TAGset=10+4=14 bits\text{TAG}_{\text{set}} = 10 + 4 = 14 \text{ bits}

Alternative Shortcut:
When moving from a direct-mapped cache (which is 11-way set-associative) to a 1616-way set-associative cache, the number of sets decreases by a factor of 1616. This reduces the index field by log⁡2(16)=4\log_2(16) = 4 bits. Since the total address length and block offset remain unchanged, these 44 bits are added directly to the TAG\text{TAG} field:
TAGset=TAGdirect+4=10+4=14 bits\text{TAG}_{\text{set}} = \text{TAG}_{\text{direct}} + 4 = 10 + 4 = 14 \text{ 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