Answer: 14
To find the length of the TAG field for the 16-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
- Let the capacity of the cache be N words and the block size be B words.
- The number of cache blocks is C=BN.
- The number of index bits is log2(C)=log2(BN).
- The number of block offset bits is log2(B).
Given that TAGdirect=10 bits, the total physical address size A is:
A=10+log2(BN)+log2(B)=10+log2(N)
2. 16-Way Set-Associative Cache
In a 16-way set-associative cache, the physical address is divided as:
Physical Address=TAGset+Indexset+Block Offset
- The number of sets in the cache is S=16C=16BN.
- The number of index bits is:
Indexset=log2(S)=log2(16BN)=log2(BN)−4
- The block offset remains the same: log2(B) bits.
3. Calculating the New TAG Field
Since the physical address size A remains constant:
A=TAGset+Indexset+Block Offset
A=TAGset+[log2(BN)−4]+log2(B)
A=TAGset+log2(N)−4
Equating the two expressions for the physical address size A:
10+log2(N)=TAGset+log2(N)−4
TAGset=10+4=14 bits
Alternative Shortcut:
When moving from a direct-mapped cache (which is 1-way set-associative) to a 16-way set-associative cache, the number of sets decreases by a factor of 16. This reduces the index field by log2(16)=4 bits. Since the total address length and block offset remain unchanged, these 4 bits are added directly to the TAG field:
TAGset=TAGdirect+4=10+4=14 bits