How does CPU cache mapping works?


I know there are two types: direct and associative. While I got the point of associative I don’t understand direct mapping on cache.

In: Technology

There are multiple types of associative cache like Set Associative Cache and Fully Associative Cache read more at [Cache_placement_policies](

Direct mapping is simpler and require less transistors the associative cache and use less power and might have lower latency but it will have lower cache hit rate.

Fully Associative Cache have high cache hit rate but use the most hardware and power and perhaps latency

Set Associative Cache is a hybrid of the two other. So you can trade of advantages and disadvantages of both other for what is optimal in the design you use.

There are varying different levels of associativity, but on the extremes are direct and fully associated. Direct cache requires the address space of the cache directly map the address of the real device. This is faster and less complex, but the cache is fixed to that direct address space.

Fully associated on the other hand, allows you to map each word of memory to a space in the cache. This is slower and more unwieldy, but allows you (or a cache controller) to cache exactly the memory you need.