Formula:
Cache size = N words
No. of bits to address cache size = log2N
Block size = B words
Block offset = log2B
No. of blocks in the cache = N/B
No. of bits to represent blocks = log2 (\(\frac{N}{B}\))
No. of sets in cache = (\(\frac{N}{B}\)) / 16
Bits to represent sets = log2 (\(\frac{N}{B}\)) / 16)
For direct mapper cache,
Tag (10)
|
Cache line
(log2 (\(\frac{N}{B}\)))
|
Block offset
(log2B)
|
For set associative cache,
Tag (Let, X)
|
Set No.
log2 (\(\frac{N}{B}\)) / 16)
|
Block offset
(log2B)
|
Here, direct mapped cache is compared with set associative cache, but in both the cases block offset is same so neglect it.
Calculation:
10 + log2 (\(\frac{N}{B}\)) = x + log2 (\(\frac{N}{B}\)) / 16)
10 + log2 (\(\frac{N}{B}\)) = x + log2 (\(\frac{N}{B}\)) – log2 16
10 = x – 4
X = 14
Tag bits for 16-bit set associative cache are 14.