Cache Mapping - Cache Mapping Techniques - Gate Vidyalay
Cache Mapping - Cache Mapping Techniques - Gate Vidyalay
Cache Memory-
Before you go through this article, make sure that you have gone through the previous article on Cache
Memory.
SPONSORED SEARCHES
cache mapping process mapping
We have discussed-
Cache memory bridges the speed mismatch between the processor and the main memory.
Cache Mapping-
Cache mapping defines how a block from the main memory is mapped to the cache memory in case of
a cache miss.
https://www.gatevidyalay.com/cache-mapping-cache-mapping-techniques/ 1/9
12/5/2020 Cache Mapping | Cache Mapping Techniques | Gate Vidyalay
OR
Cache mapping is a technique by which the contents of main memory are brought into the cache
memory.
NOTES
Main memory is divided into equal size partitions called as blocks or frames.
Cache memory is divided into partitions having same size as that of blocks called as lines.
During cache mapping, block of main memory is simply copied to the cache and the block is not
actually brought from the main memory.
https://www.gatevidyalay.com/cache-mapping-cache-mapping-techniques/ 2/9
12/5/2020 Cache Mapping | Cache Mapping Techniques | Gate Vidyalay
1. Direct Mapping
2. Fully Associative Mapping
3. K-way Set Associative Mapping
1. Direct Mapping-
In direct mapping,
A particular block of main memory can map only to a particular line of the cache.
The line number of cache to which a particular block can map is given by-
Example-
https://www.gatevidyalay.com/cache-mapping-cache-mapping-techniques/ 3/9
12/5/2020 Cache Mapping | Cache Mapping Techniques | Gate Vidyalay
In direct mapping,
https://www.gatevidyalay.com/cache-mapping-cache-mapping-techniques/ 4/9
12/5/2020 Cache Mapping | Cache Mapping Techniques | Gate Vidyalay
A block of main memory can map to any line of the cache that is freely available at that moment.
This makes fully associative mapping more flexible than direct mapping.
Example-
Here,
https://www.gatevidyalay.com/cache-mapping-cache-mapping-techniques/ 5/9
12/5/2020 Cache Mapping | Cache Mapping Techniques | Gate Vidyalay
Cache lines are grouped into sets where each set contains k number of lines.
A particular block of main memory can map to only one particular set of the cache.
However, within that set, the memory block can map any cache line that is freely available.
The set of the cache to which a particular block of the main memory can map is given by-
https://www.gatevidyalay.com/cache-mapping-cache-mapping-techniques/ 6/9
12/5/2020 Cache Mapping | Cache Mapping Techniques | Gate Vidyalay
Example-
Here,
Set associative mapping is a combination of direct mapping and fully associative mapping.
It uses fully associative mapping within each set.
Thus, set associative mapping requires a replacement algorithm.
https://www.gatevidyalay.com/cache-mapping-cache-mapping-techniques/ 7/9
12/5/2020 Cache Mapping | Cache Mapping Techniques | Gate Vidyalay
Special Cases-
If k = Total number of lines in the cache, then k-way set associative mapping becomes fully associative
mapping.
Get more notes and other study material of Computer Organization and Architecture.
Summary
https://www.gatevidyalay.com/cache-mapping-cache-mapping-techniques/ 8/9
12/5/2020 Cache Mapping | Cache Mapping Techniques | Gate Vidyalay
Publisher Logo
https://www.gatevidyalay.com/cache-mapping-cache-mapping-techniques/ 9/9