chapter 4 memory organization lecture
chapter 4 memory organization lecture
Comparing:
Technology Access Time Cost/GB
SRAM 0.5 – 5 ns $4,000
- $10,000
DRAM 50 – 70 ns $100 - $200
Disk 5 – 20 ms $0.50 - $2
Typical Levels in a Hierarchical Memory
Capacity Access latency Cost per GB
100s B ns
Reg’s $Millions
10s KB a few ns
Cache 1
$100s Ks
MBs 10s ns
Cache 2 $10s Ks
100s MB 100s ns Speed
Main $1000s
gap
10s GB 10s ms Secondary $10s
Register Access
file desktop in 2 s Cache
memory
Main
memory
Secondary Memory
•••
valid tag 0 1 • • • B–1
set S-1: •••
valid tag 0 1 • • • B–1
•••
valid tag 0 1 • • • B–1
set S-1: •••
valid tag 0 1 • • • B–1
•••
The word at address A is in the cache if
v tag 0 1 • • •B–1
set S-1: ••• the tag bits in one of the <valid> lines in
v tag 0 1 • • •B–1 set <set index> match <tag>
•••
1. Locate the set based on
v tag 0 1 • • •B–1
set S-1: ••• <set index>
v tag 0 1 • • •B–1 2. Locate the line in the set based on
<tag>
3. Check that the line is valid
4. Locate the data in the line based on
<block offset>
11 15-213, S’08
CACHE MEMORY MAPPING
There are three commonly used methods to
translate main memory addresses to cache
memory addresses.
Direct-Mapped Cache
Associative Mapped Cache
Set-Associative Mapped Cache
Cache
00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C 40 44 48 4C
Memory
Block 2
Block 3
Block 2
Block 3
Block 3
Block 3
CSCE430/830
Set 0 contains Mem[0]. Overwrite with Mem[8]
Memory: Set-Associative $
Example: Accessing A Direct-Mapped Cache
• DM cache contains 4 1-word blocks. Find the # Misses for each
cache given this sequence of memory block accesses: 0, 8, 0, 6, 8
Block 3
Block 3
CSCE430/830
Set 0 contains Mem[8]. Overwrite with Mem[0]
Memory: Set-Associative $
Example: Accessing A Direct-Mapped Cache
• DM cache contains 4 1-word blocks. Find the # Misses for each
cache given this sequence of memory block accesses: 0, 8, 0, 6, 8
Cache
000
001
010
011
111
100
101
110
Memory
CSCE430/830 Memory: Set-Associative $
Example: Direct-Mapped Cache
Simplest kind of cache, easy to build
(only 1 tag compare required per access)
Tag 20 10 Data
Hit
Index
Index Valid Tag Data
0
1
2
.
.
.
1021
1022
1023
20 32
Cache
arbitrary block mapping
location = any
00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C 40 44 48 4C
Memory
FA Memory Access 1:
FA Memory Access 1:
FA Memory Access 2:
FA Memory Access 2:
FA Memory Access 3:
FA Memory Access 3:
FA Memory Access 4:
FA Memory Access 4:
FA Memory Access 5:
FA Memory Access 5:
Cache
00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C 40 44 48 4C
Memory
Set 0…1110
11 0…1111
…
PRO: Set
00
Block 0 Block 1
0…1001
0…1010
CON: Set
11 0…1111
…
Must search set for hit/miss
CSCE430/830 Memory: Set-Associative $
Set Associative Cache Design
Address
• Key idea: 31 30 12 11 10 9 8 3210
– Divide cache into sets
– Allow block anywhere in a set
22 8
• Advantages:
– Better hit rate
• Disadvantage:
– More tag bits Index V Tag Data V Tag Data V Tag Data V Tag Data
– More hardware 0
– Higher access time 1
2
253
254
255
22 32
4-to-1 multiplexor
Hit Data