Computer Science — Types of Associativity in a Cache

For a cache design, there are typically three ways that they are designed. They are built by fully associative, direct mapping, and set associative.

Jake Cutter
Technology Hits
3 min readJun 21, 2022

--

Photo by Procreator UX Design Studio on Unsplash

Before we delve into the plethora of details over cache associativity consider giving a follow if you enjoy or learn something from the article. The cache is the location of hard drive data that is later called back through reading and writing commands. The processor collects data from the cache when executing commands. This is often the result of the principle of locality which can be characterized as temporal and spatial.

Locality:

The principle of locality is based on what addresses are often used or the frequency of reading and writing. This is done through spatial and temporal localities. Spatial locality is when you access data, it is likely that you will access the addresses around the current data. Temporal locality is if data is accesses recently or frequently the data address is stored.

Direct Mapping:

In direct mapping, the cache sends the address from the table directly to the cache block. This is the most cost-effective, and easily programmed section. The direct mapping sends the table value to the data block. The block is then translated into virtual memory. The last three bits are the location in the cache that the block will send to.

Patterson, D. A., & Hennessy, J. L. (2017). Computer Organization. Cambridge; Elsevier Inc.

The number of blocks that will be used in the cache is considered as a power of 2^n.

Set Associative:

In set associativity, the cache sends the address from the table into sets of values into the cache block. The cache block is then translated into virtual memory.

Self Work

Fully Associative:

In Full Associative, this is the most power-consuming and expensive association. The address is sent into the cache block similarly to the other associativities. In other words, all of the entries are searched at once.

Patterson, D. A., & Hennessy, J. L. (2017). Computer Organization. Cambridge; Elsevier Inc.

Page Translation:

Patterson, D. A., & Hennessy, J. L. (2017). Computer Organization. Cambridge; Elsevier Inc.

The virtual memory is transferred via page translation. Page translation by a virtual address with a tag, index, and data block. The index is the bits directly after the offset. This means that the translation from a word to a byte is 2 bytes per word. The tag is the remaining bits outside of the index and offset. Finally, the data block is the actual data you are trying to store at the address. The address is the location on the device.

Citations:

Cao, Qing. Professor. University of Tennessee. Knoxville, Tennessee. 2021

Patterson, D. A., & Hennessy, J. L. (2017). Computer Organization. Cambridge; Elsevier Inc.

--

--