This document discusses different cache mapping techniques including direct mapping, associative mapping, and set-associative mapping. It provides examples of direct mapping where the main memory is divided into pages that map to cache frames. Direct mapping allows only one main memory page to map to each cache frame based on the page number. Associative mapping allows any main memory page to map to any cache frame by using a content addressable memory. Set-associative mapping groups cache frames into sets, and each main memory page can map to one of the frames within a set. The document also gives an example of how cache hit rates can be different between direct mapping, 2-way set associative mapping, and fully associative mapping.
DIRECT MAPPING
0
1
2
3
.
.
.
4094
4095
Main Memory
MainMemory is fragmented into pages
of equal size
Every page contains equal no of
memory location
P = 4096
16 locations
4096 x 16
212 x 24 = 216 Bit address
Page Number Page Offset
12 bits 4 bits
MAR
4.
DIRECT MAPPING
0
1
2
.
.
.
127
Cache Memory
CacheMemory is fragmented into
frames of equal size
F = 128
Every frames contains equal no of
memory location
16 locations
27 x 24 = 211 Bit address
128 x 16
Frame Number Frame Offset
7 bits 4 bits
ASSOCIATIVE /FULLY
ASSOCIATIVE MAPPING
AnyMain Memory page can be loaded to any Cache Memory Frame
Tag (Page Address) W
MAR
Tag Field Cache Frame No (C)
CAM word
C W
CAM is costly (19 bits)
Multiple pages with same tag no cannot be loaded to Cache Memory
MISSES AND ASSOCIATIVITYIN
CACHE
Assume there are three small caches, each consisting of four one-word blocks. One cache is
fully associative, a second is two-way set-associative, and the third is direct-mapped. Find the
number of misses for each cache organization given the following sequence of block
addresses: 0, 8, 0, 6, and 8.
EXAMPLE
11.
DIRECT MAPPED CACHE
sequenceof block addresses: 0, 8, 0, 6, and 8.
MISS Memory [0]
MISS Memory [8]
MISS Memory [0]
MISS Memory [0] Memory [6]
MISS Memory [8]
12.
2 way SetAssociative Mapped Cache
sequence of block addresses: 0, 8, 0, 6, and 8.
MISS Memory [0]
MISS Memory [0] Memory [8]
HIT Memory [0] Memory [8]
MISS Memory [0] Memory [6]
MISS Memory [8] Memory [6]
13.
Fully Associative MappedCache
sequence of block addresses: 0, 8, 0, 6, and 8.
MISS Memory [0]
MISS Memory [0] Memory [8]
HIT Memory [0] Memory [8]
MISS Memory [0] Memory [8] Memory [6]
HIT Memory [0] Memory [8] Memory [6]