I am starting to learn how cpu cache works at a fundamental level. I am confused on one point though. What happens when the cpu gets a hit based off of two addresses that happen to have the same tag and set?
Let's say we have a 64 byte cache with 16 byte blocks. The addresses are 12-bit and it is using direct mapping. The tag will have 5 bit, the set will have to bits, and the offset will have 5 more bits. If we have two addresses 0x070 (0000 0111 0000 inn binary ) and 0x068 (0000 0110 1000), we see that the tag (the first five bits) are the same, the set is the same, only the offset differs.
As I understand it, when it is a "hit", the computer only takes into account the tag and set. So if both addresses where run one after the other, the cache would have a "hit". Why does this work? Don't both addresses contain different information and therefore cause an error if the cpu treats them as the same thing? Or does the cpu then check to see if the values are the same and then proceed?
Please let me know if I am missing something or have made a mistake.