Professional Documents
Culture Documents
Cache Mapping Cache Mapping: Goals
Cache Mapping Cache Mapping: Goals
Goals
Cache Mapping
COMP375 Computer Architecture
and
dO
Organization
i ti
COMP375
Cache Challenges
Cache Mapping
Tag Fields
A cache line contains two fields
Data from RAM
The address of the block currently in the
cache.
Line Example
These boxes
represent RAM
addresses
COMP375
0110010100
0110010101
0110010110
0110010111
0110011000
0110011001
0110011010
0110011011
0110011100
0110011101
0110011110
0110011111
Cache Lines
The cache memory is divided into blocks
g from 16
or lines. Currentlyy lines can range
to 64 bytes.
Data is copied to and from the cache one
line at a time.
The lower log2(line size) bits of an address
specify
if a particular
i l b
byte iin a liline.
Line address
Offset
Cache Mapping
Mapping
Direct Mapping
Cache Constants
COMP375
Line
Offset
Cache Mapping
Example Address
9 bits
Line
6 bits
Offset
t=
6
ffs
e
=1
2
,o
in
e
=1
2
in
e
ta
g=
6
,l
,l
g=
8
ta
g=
4
,o
ffs
e
t=
6
,o
=1
4
,o
in
e
=1
6
,l
in
e
ta
g=
4
ta
COMP375
ffs
e
ffs
e
t=
4
,l
1.
2.
3.
4.
t=
4
Direct Mapping
24 bit addresses
64K bytes of cache
16 byte cache lines
Associative Mapping
Cache Mapping
Example Address
5 bits
Offset
et
=8
011111010111011100011011001 11000
Tag
offset
Compare all tag fields for the value
011111010111011100011011001. If a match
is found, return byte 11000 (2410) of the line
ta
g=
16
,o
ff s
ff s
et
=5
g=
18
,o
ff s
g=
19
,o
g=
ta
COMP375
ta
,o
ffs
et
=4
20
1.
2.
3.
4.
ta
Associative Mapping
24 bit addresses
128K bytes of cache
64 byte cache lines
et
=6
Cache Mapping
19 bits
Tag
=4
0,
s
g=
1
ta
g=
1
of
fs
et
et
=4
10
,
et
et
2,
s
et
6,
s
g=
1
4,
o
8,
o
ff s
ff s
et
=4
ff s
=
12
,o
=
,s
et
ta
g=
8
tag=8,
g
set = 12, offset=4
tag=16, set = 4, offset=4
tag=12, set = 8, offset=4
tag=10, set = 10, offset=4
ta
1.
2.
3.
4.
et
=4
ta
COMP375
6 bits
Offset
Example Address
7 bits
Set
Cache Mapping
Replacement policy
When a cache miss occurs, data is copied
into some location in cache.
With Set Associative or Fully Associative
mapping, the system must decide where
to put the data and what values will be
replaced.
Cache performance is greatly affected by
properly choosing data that is unlikely to
be referenced again.
COMP375
Replacement Options
LRU replacement
Pseudo LRU
Cache Mapping
Comparison of Mapping
Fully Associative
Comparison of Mapping
Direct
A
Associative
i i mapping
i works
k the
h b
best, b
but iis
complex to implement. Each tag line
requires circuitry to compare the desired
address with the tag field.
cache, such as the
Some special purpose cache
virtual memory Translation Lookaside
Buffer (TLB) is an associative cache.
Comparison of Mapping
Set Associative
Set associative is a compromise between
the other two. The bigger the way the
better the performance, but the more
complex and expensive.
Intel Pentium uses 4 way set associative
caching for level 1 data and 8 way set
associative for level 2.
COMP375