







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








Each row in the cache is called a line:
Typically lines store a number of words.
Key question - which memory words can go in which lines?
Any word of memory can occupy any cache line.
When we access memory, search the tags for the required address. If it’s found, we hit the cache. If not, we miss.
For this to be efficient, we must be able to search the tags in parallel. This requires special (= expensive) hardware.
Say we have 32 bit addresses, and each line holds 32 bytes. An address is divided as:
If a valid line has the correct tag, the offset indicates which byte of the line we require.
Initially, every valid bit is 0. The cache fills as memory is accessed.
If we miss and the cache is full, we need to decide which address to evict from the cache:
In practice, LRU is often used – it’s easy to implement and quite good.
Since any cache line can be used for any word, fully associative caches make very ef- ficient use of available cache space.
With a good replacement policy, and pattern of data accesses to data that fits in the cache is likely to see a performance gain.
Parallel searching for the tag requires content accessible memory, aka associative memory. Nontrivial hardware support is required.
The tags are large, and consume consider- able memory.
For large caches, the high hardware cost and complexity become prohibitive.
Consider a cache with 8 lines of 2 bytes each, for a system with 256 bytes of memory:
Direct mapped caches are easy to implement and don’t require special support.
Since the index consumes part of the address, less tag space is required.
The use of the cache may not be extremely efficient, as we cannot place cached data freely.
Consider moving along a pair of arrays in memory. If the base addresses occupy the same cache line, so do elements at the same index in each array.
If we’re unlucky, almost every cache access will be a miss, with each load evicting the other array’s data!
Consider a 2-way set associative cache with 8 lines of 2 bytes each, for a system with 256 bytes of memory: