Set-Associative Cache

Set-Associative caches are a family of cache placement policies (how do we organize things inside of a cache?) that think of a cache as an ordered array of sets, each one containing an unordered sequence of entries (or cache lines). As such, they generalize over both direct mapped caches (n sets, 1 entry/set) and fully associative caches (1 set, n entries/set), while encompassing tradeoffs between the two types (k sets, n/k entries/set).

Set 0
V
Tag
Data (Block)
0
-
???
0
-
???
0
-
???
0
-
???
A direct mapped cache with 4 entries
Set 0
V
Tag
Data (Block)
0
-
???
Set 1
V
Tag
Data (Block)
0
-
???
A fully associative cache with 2 entries

This is notably different from the independent notation of cache replacement policies, which ask the question: "when we need to, how do we choose which cache entry to replace with a new one?". For the purposes of this visualization, our cache replacement policy will be to evict the least recently used (LRU) cache line, but other possible options for eviction can be found here.

Cache Configuration

Total Cache Size: 32 Bytes

Main Memory (64 Words)

Click a byte to simulate an access

Step-through Operation

Address Decoding (8-bit Address)

Click a byte in memory to start a cache access simulation.

Cache Structure