Electronic – How to calculate index and tag fields lengths for a cpu cache

cachecomputer-architecturecomputerscpumemory

I study computer engeering notes for a cache memory and I try to understand what determines the length of the index and the tag fields. The first examples is for 64 bits and the second example is for 128 bits and I wonder if the tag field length is just chose arbitrarily or what is the reason for being 28 in the first case and 29 in the second case. In the first case the block size is 8 bytes and in the second case the block size is 16 bytes.

enter image description here
enter image description here

Why is the tag field length only 28 bits in the second case?

Source: http://www.ict.kth.se/courses/IS1500/2012/forel/2012-ce_f8ht.pdf

Best Answer

You seem to have a 32-bit address space.

To address one of 8 bytes you need a 3-bit address, so 29 bits remain to address the block.

To address one of 16 bytes you need a 4-bit address, so 28 bits remain to address the block.