Lecutre-8 Cache Memory
Lecutre-8 Cache Memory
Chapter - 4
Computer Organization and Architecture Designing -
William Stallings
Cache Memory
sazzad@diucse
Memory Hierarchy
• Registers
– In CPU
• Internal or Main memory
– May include one or more levels of cache
– “RAM”
• External memory
– Backing store
sazzad@diucse
Performance
• Access time
– Time between presenting the address and getting the valid data
• Memory Cycle time
– Time may be required for the memory to “recover” before next access
– Cycle time is access + recovery
• Transfer Rate
– Rate at which data can be moved
sazzad@diucse
Hierarchy List
• Registers
• L1 Cache
• L2 Cache
• Main memory
• Disk cache
• Disk
• Optical
• Tape
sazzad@diucse
Cache and Main Memory
sazzad@diucse
Cache/Main Memory Structure
sazzad@diucse
Cache operation – overview
sazzad@diucse
Cache Read Operation - Flowchart
sazzad@diucse
Cache Addressing
sazzad@diucse
Mapping Function
sazzad@diucse
Direct Mapping
sazzad@diucse
Direct Mapping Address Structure
• 24 bit address
• 2 bit word identifier (4 byte block)
• 22 bit block identifier
– 8 bit tag (=22-14)
– 14 bit slot or line
• No two blocks in the same line have the same Tag field
• Check contents of cache by finding line and checking Tag
sazzad@diucse
Direct Mapping from Cache to Main Memory
sazzad@diucse
Direct Mapping Summary
sazzad@diucse
Direct Mapping pros & cons
• Simple
• Inexpensive
• Fixed location for given block
– If a program accesses 2 blocks that map to the same line repeatedly, cache misses are very
high
sazzad@diucse
Associative Mapping
sazzad@diucse
Associative Mapping Address Structure
Tag Word
22 bits 2 bits
sazzad@diucse
Associative Mapping from Cache to Main Memory
sazzad@diucse
Associative Mapping Summary
sazzad@diucse
Set Associative Mapping
sazzad@diucse
Set Associative Mapping Address Structure
Word
Tag 9 bit Set 13 bit 2 bit
sazzad@diucse
Mapping From Main Memory to Cache: v Associative
sazzad@diucse
Mapping From Main Memory to Cache: k-way Associative
sazzad@diucse
Set Associative Mapping Summary
sazzad@diucse
That’s All
Thank You
sazzad@diucse