ZacharyyK
ZacharyyK

Reputation: 15

What do the offset bits represent in an address when determining if a Cache hit or miss?

I'm confused what the offset bits represent. Do they play any role in determining if we have a cache hit or miss?

For example, if we have 4 sets, 2 bytes per block, and 1 block per set, then we need to use a 4 bit address mapping. The first bit is the tag, the next two are our set number, and the last bit is our offset. We are using a direct-mapped cache system.

My professor's notes state that if we first look for 0000 we miss. Makes sense it's a compulsory miss. But then when we look for 0001 it's a hit. Is this because the offset bit doesn't play a role?

I initially thought it may be useful in a N-Set Associative Cache, but even then I can't see its role.

I expected both addresses to miss but the second address resulted in a hit.

Upvotes: 0

Views: 661

Answers (1)

user23563477
user23563477

Reputation: 11

So, in your scenario, offset does not matter. BUT, imagine that your sets within your cache allowed for the storage of multiple blocks. In that case, the offset would indicate which block within that address the Tag would be stored in.

A set could allow for two blocks to be stored - In this case an offset of "0" would go in that first space, and an offset of "1" would go in that second space. So you would have a "miss" but could still store in that cache set, without erasing what is currently stored in there.

Hope that makes sense!

Upvotes: 1

Related Questions