I am confused on how the data is accessed on a 2-way associative cache.
For example, C = ABS
C = 32KB
A = 2
B = 32bits
S = 256
offset = lg(B) = 5
index = lg(S) = 8
tag = 32 - offset - index = 19
Say I have I have the following addresses
tag | index | offset
1000 0000 0000 0000 000|0 0000 000|1 0000
1000 0000 0000 0000 000|0 0000 000|0 0000
1000 0000 0000 0000 000|0 0000 000|1 1010
and my cache looks like
index valid dirty tag data valid dirty tag data
0: 1 0 0x80... some data1 1 0 0x80... some data2
1: . .
2: . .
3: . .
How do I determine which of the two cache array I should take the data from (data1 vs data2) when the index and tag bits are the same?
Likewise, how do I determine which of the data in the two array I should kick out when I need to update the cache with the same index and tag bits?
I am thinking it has to do with the offset bits, but I am not too sure how to use the offset bits or what exactly do they represent or maps to in the cache array.