how to deal with mismatched tag bits in cache I was reading a textbook which describe general organization of cache as:


Then an exercise is, given m=32, C = 1024, B = 8,E = 4, S = 32, so s = 5, b = 3, therefore t = 32-5-3 = 24
I am a little bit confused here, since E = 4, we only need 2 bits to differentiate it, so t should be 2, if t is 24, isn't that we waste 22 bits?
For every cache set, there are $2^t$ blocks that can potentially be stored in there. However, only $E$ of them are actually stored at any particular time - typically, these would be the &quot;most recently used&quot; ones.
Incidentally, the whole reason for storing the tags themselves inside the cache is to be able to tell which ones are currently cached. The block's tag is not the &quot;index&quot; of a cache line, it's a $t$-bit identifier which is literally compared against every tag in the set in order to check whether this block is available or not.