Q. The size of the physical address space of a processor is 2π bytes. The word length is 2π bytes. The capacity of cache memory is 2π bytes. The size of each cache block is 2π words. For a πΎ-way set-associative cache memory, the length (in number of bits) of the tag field is
(A) π β π β log2 πΎ (B) π β π + log2 πΎ
(C) π β π β π β π β log2 πΎ (D) π β π β π β π + log2 πΎ
Ans: π β π + log2 πΎ
Sol:
Physical Address Space = 2P Bytes. Word Length is 2W bytes, which means each word is of size 2W bytes.
Cache memory size = 2N Bytes and Tag Size = 2X Bytes.
Physical address is P β W bits
Number of blocks in cache = 2(N-W-M)
It is a K-way set associative cache memory, each set in cache will have K-blocks.
So, Number of sets = 2(N-W-M)/ K
SET bits will be N-W-M-logk
Offset bits will be M
We know,
TAG bits = Main memory bits β SET bits β offset bits
So, TAG bits(x) = P β W β (N-M-W-logk)- M
Β Β Β = P β W β N + M + W + logk β M
Β Β Β x = P β N + logk