Answer: 20
To find the number of bits in the TAG field, we break down the physical address into three fields: TAG, Set Index, and Block Offset.
- Physical Address (PA) Size:
Physical Address Space = 4 GB=232 bytes.
Therefore, the Physical Address length is 32 bits.
- Block Offset Bits:
Word length = 32 bits=4 bytes.
Block size = 8 words=8×4 bytes=32 bytes=25 bytes.
Thus, Block Offset = 5 bits.
- Set Index Bits:
Cache Capacity = 16 KB=214 bytes.
Number of blocks in the cache = Block SizeCache Capacity=25214=29=512 blocks.
Since it is a 4-way set-associative cache, the number of sets is:
Number of Sets=4512=128=27
Thus, Set Index = 7 bits.
- Tag Bits:
Tag Bits=Physical Address Size−(Set Index Bits+Block Offset Bits)
Tag Bits=32−(7+5)=20 bits