# What determines a hit/miss with cache memory?

I was taught that when a reference is mapped to a cache block, X, for the first time, the word is stored in the cache block, bearing a tag and index that helps identify it for future reads. Then, when a later reference is deemed to have the same tag and index for cache block X, the value inside the cache block is returned as the read value. Is it the same process for multi-word caches?

I was given a direct-mapped cache: Four 4-word blocks, 32 bits per word, and these word address references...

Ref   Tag   Index   Hit/Miss
134   8     1       Miss
212   13    1       Miss
135   8     1       Hit
213   13    1       Hit


...were what I determine to be the hit/miss for the references because the tags and the index match, even if the value is wrong. But the answer key tells me the hit/miss for the references are:

Ref   Tag   Index   Hit/Miss
134   8     1       Miss
212   13    1       Miss
135   8     1       Miss
213   13    1       Miss


...so there's more involved when it comes to multi-word caches? ...or the answer key is wrong. Can anyone clarify?

• It's a direct mapped cache, so the block that stores words 134 and 135 needs to be stored in the same place as the block that stores words 212 and 213. – Wandering Logic Dec 7 '13 at 0:25
• Well, I figured that they all go to the same block, but there's only room for two. So, are you saying they all miss, or do 2 later accesses of 135 and 213 hit? – user2738698 Dec 7 '13 at 0:39
• They all miss. They all go to the same block, and there's only room for one. – Wandering Logic Dec 7 '13 at 14:04
• Explain yourself, hits only occur when tags and index match, and they match, thus, they should be hits. – user2738698 Dec 7 '13 at 20:12
• index isn't something that gets compared, it's the location of the block. Only the tag gets compared/matched. When the ref to 212 occurs the block at index 1 is replaced by the data from words 212, 213, 214 and 215 and the tag of the block at index 1 is changed from 8 to 13. So when you do the access to 135 you look in the block at index 1 and you see that the tag is 13, not 8. Go look up the term, "direct mapped". – Wandering Logic Dec 7 '13 at 21:33