|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cache: set-associative |
|
|
|
|
|
|
|
Hybrid between
direct-mapped and fully-associative cache: set-associative |
|
|
|
Again assume 128 slots,
32 bytes per slot |
|
|
|
Group slots into sets of
8 each (16 sets) |
|
|
|
Use lg 16 = 4 bits to
specify set |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
How to find data address
B31-0? |
|
|
|
|
|
|
Use bits B8-5 to find the set |
|
|
|
|
|
|
There are 8 slots with
addresses |
|
|
|
|
|
|
B8-5000 |
|
|
|
|
|
|
B8-5001 |
|
|
|
|
B8-5010 |
|
|
|
|
|
. . . |
|
|
|
|
|
B8-5111 |
|
|
|
|
Search all 8 slots to
see if the tag B31-9
matches the tag of the slot |
|
|
|
|
If so, get the data byte
at offset B4-0 in the
slot |
|
|
|
|
If not, find a slot to
use (possibly by eviction), and store 32 bytes in the slot |
|
|
|
This example is 8-way
set-associative cache |
|
|
|
|
|
In general, we can have
N-way set-associative cache |
|
|
|
|
Compromise: have to
search fewer number of slots, simpler comparison hardware |
|
|
|
But still have the
flexibility of N cache lines per slot (fewer collisions) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|