Skip to main content
1 of 2
pveentjer
  • 339
  • 2
  • 7

An n-way set associative cache is a cache that is chopped up in sections called sets. And each set can hold n-blocks.

So for a given cache-address, you can break it up in 3 parts.

  • the offset within the block
  • the index that identifies the set
  • the tag that identifies the block in the set.

So when a request comes in, the index is calculated to identify the set. Then the tags of all blocks in the set are checked. And when a block with a matching tag is found, the right bytes are returned based on the offset.

A direct mapped cached is effectively a 1 way set associative cache.

So associativity doesn't mean the number of blocks the cache can hold, but the number of blocks a set within the cache can hold.

The big advantage of a n-way set associative cache compared to a direct mapped cache, is the latter can only have a single block for a range of addresses and the former can hold multiple blocks for a range of addresses.

pveentjer
  • 339
  • 2
  • 7