
I do not understand set-assocative cache mapping even after understanding direct mapping and fully associative mapping. Can you please help me?
​
I am taking a simple example to understand this concept.
- Memory address is of 16 bits.
- Block size is 16 words.
- Number of Main Memory blocks is 4K
- Number of Cache Memory lines is 64
Here is the exclusive part that I do not understand:
> In figure 10.8, we have chosen four cache lines per set. Hence, for the above example there are 16 sets of cache lines.
I think they could simply do number of sets=(number of cache blocks)/(n of n-way) and say it is a 4-way with 16 sets of cache lines.
> Let us number them from 0 to 15. dividing the 4096 memory blocks equally among these 16 sets, we find that 256 memory blocks can be mapped into one set of cache lines.
Things get rusty for me from just above. One set can get 256 memory blocks...makes sense but keep reading.
> Figure 10.8 shows that those memory blocks that are mapped into set 0, namely, 0,16,32,48,64,80,...,4080. In this sense, the mapping resembles direct mapping. But the 256 memory blocks that are mapped into set 0 can be placed into any of the four cache lines within the set 0, namely CL0, CL1, CL2, or CL3 indicated in the figure. In this way it resembles the associative mapping.
Nothing makese sense in this. How did we arrive at the number 0,16,32......What is the mapping formula being used here?
Figure 10.8 shows those