Alright, I thought I understood this concept but now I am confused. I looked up similar problems and their solutions to practice, and that's what threw me off. The question is a homework problem which says:
Below is a list of 32-bit memory address references, given as word addresses.
3, 180, 43, 2, 191, 88, 190, 14, 181, 44, 186, 253
a) For each of these references, identify the binary address, the tag, and the index given a direct-mapped cache with 16 one-word blocks. Also list if each reference is a hit or a miss, assuming the cache is initially empty.
b) For each of these references, identify the binary address, the tag, and the index given a direct-mapped cache with two-word blocks and a total size of 8 blocks. Also list if each reference is a hit or a miss, assuming the cache is initially empty.
(How do I know how many bits the tag and index are supposed to have? Also, it is a miss unless both the tag and the index match, right? Or is it just if the index matches? I'm obviously extremely confused but I really do want to understand!)
My answer for a) :
Memory Binary tag index hit/miss
3 00000011 0000 0011 miss
180 10110100 0010 0000 miss
43 00101011 0010 0011 miss
2 00000010 0000 0010 miss
191 10111111 1011 1111 miss
88 01011000 0101 1000 miss
190 10111110 1011 1110 miss
14 00001110 0000 1110 miss
181 10101101 1010 1101 miss
44 00101100 0010 1100 miss
186 10111010 1011 1010 miss
253 11111101 1111 1101 miss
b)I'm not sure how to figure this out, but when I looked it up, people were saying the index should be left shifted one bit so that's what I got (I'd like to understand why)
3 00000011 0000 001 miss
180 10110100 0010 000 miss
43 00101011 0010 001 miss
2 00000010 0000 001 hit
191 10111111 1011 111 miss
88 01011000 0101 100 miss
190 10111110 1011 111 hit
14 00001110 0000 111 miss
181 10101101 1010 110 miss
44 00101100 0010 110 miss
186 10111010 1011 101 miss
253 11111101 1111 110 miss
As always, thank you so much for your help.