SlideShare a Scribd company logo
Content:
▪ What is Cache?
▪ Cache Operation.
▪ Cache Design.
▪ Direct Mapping
▪ Associative Mapping.
▪ Replacement Algorithm.
▪ Write Policy.
▪ Write Through.
▪ Write Back.
Cache.
Small amount of fast memory
Sits between normal main memory and CPU
May be located on CPU chip or module
Back
Cache Operation
Back
Cache Design:
Size
Mapping Function
Replacement Algorithm
Write Policy
Block Size
Number of Caches
Direct Mapping:
Each location in RAM has one specific place in cache where
the data will be held
Address is in two parts.
1)Least Significant w bits identify unique word
2)Most Significant s bits specify one memory block .
▪ DM is Inexpensive and simple.
▪ Fixed location for given block:
▪ If a program accesses 2 blocks that map to the same line
repeatedly, cache misses are very high
Direct Mapping Address Structure.
17 bits 9 bits 6 bits
▪ 32 bit address
▪ 6 bits word identifier (4 byte block)
▪ 26 bit block identifier
▪ 17 bit tag (=26-17)
▪ 9 bit slot or line
Replacement Algorithm
Direct Mapping
▪ No choice
▪ Each block only maps to one line
▪ Replace that line
Associative Mapping:
A main memory block can load into any line of
cache
Memory address is interpreted as tag and word
Tag uniquely identifies block of memory
Tag 22 bit
Word
2 bit
A Diagram Link
Set Associative Mapping.
▪ Cache is divided into a number of sets
▪ Each set contains a number of lines
▪ A given block maps to any line in a given set
▪ e.g. Block B can be in any line of set i
▪ 2 lines per set
▪ 2 way associative mapping
▪ A given block can be in one of 2 lines in only one set
Example of Set Associative.
▪ 13 bit set number
▪ 000000, 00A000, 00B000, 00C000 … map to same
set
Tag 9 bit Set 13 bit
Word
2 bit
Replacement Algorithms
Associative & Set Associate Mapping.
▪ Hardware implemented algorithm (speed)
▪ Least Recently Used (LRU)
▪ In 2 way set associative
▪ Which of the 2 block is LRU?
Replacement Algorithms
Associative & Set Associate Mapping.
 First in first out (FIFO)
 replace block that has been in cache longest
 Least frequently used
 Replace block which has had fewest hits
 Random
Write Policy:
▪ Must not overwrite a cache block unless main
memory is up to date
▪ Multiple CPUs may have individual caches
▪ I/O may address main memory directly
Write Through:
▪ All writes go to main memory as well as cache
▪ Multiple CPUs can monitor main memory
traffic to keep local (to CPU) cache up to date
▪ Lots of traffic
▪ Slows down writes
Write Back:
▪ Updates initially made in cache only
▪ Update bit for cache slot is set when update
occurs
▪ If block is to be replaced, write to main
memory only if update bit is set
▪ I/O must access main memory through cache
What is Cache and how it works
What is Cache and how it works

More Related Content

What's hot

Cache memory
Cache  memoryCache  memory
Cache memory
Prasenjit Dey
 
cache memory
 cache memory cache memory
04 cache memory
04 cache memory04 cache memory
04 cache memory
Inshad Arshad
 
Cache Memory
Cache MemoryCache Memory
Cache Memory
Subid Biswas
 
Feng’s classification
Feng’s classificationFeng’s classification
Feng’s classification
Narayan Kandel
 
Virtual memory
Virtual memoryVirtual memory
Virtual memoryAnuj Modi
 
cache memory
cache memorycache memory
Cache memory
Cache memoryCache memory
Cache memory
Ahsan Ashfaq
 
Memory organization
Memory organizationMemory organization
Memory organization
AL- AMIN
 
Cache memoy designed by Mohd Tariq
Cache memoy designed by Mohd TariqCache memoy designed by Mohd Tariq
Cache memoy designed by Mohd Tariq
Mohd Tariq
 
Multiprocessor Architecture (Advanced computer architecture)
Multiprocessor Architecture  (Advanced computer architecture)Multiprocessor Architecture  (Advanced computer architecture)
Multiprocessor Architecture (Advanced computer architecture)
vani261
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)
Sandesh Jonchhe
 
Cache memory
Cache memoryCache memory
Cache memory
Ansari Maviya
 
Computer organization & architecture chapter-1
Computer organization & architecture chapter-1Computer organization & architecture chapter-1
Computer organization & architecture chapter-1
Shah Rukh Rayaz
 
Cache replacement policies,cache miss,writingtechniques
Cache replacement policies,cache miss,writingtechniquesCache replacement policies,cache miss,writingtechniques
Cache replacement policies,cache miss,writingtechniques
SnehalataAgasti
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
Kamal Acharya
 
04 cache memory.ppt 1
04 cache memory.ppt 104 cache memory.ppt 1
04 cache memory.ppt 1
Anwal Mirza
 
Cache memory
Cache memoryCache memory
Cache memory
chauhankapil
 

What's hot (20)

Cache memory
Cache  memoryCache  memory
Cache memory
 
cache memory
 cache memory cache memory
cache memory
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
Cache Memory
Cache MemoryCache Memory
Cache Memory
 
Feng’s classification
Feng’s classificationFeng’s classification
Feng’s classification
 
Virtual memory
Virtual memoryVirtual memory
Virtual memory
 
cache memory
cache memorycache memory
cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
Memory organization
Memory organizationMemory organization
Memory organization
 
Cache memoy designed by Mohd Tariq
Cache memoy designed by Mohd TariqCache memoy designed by Mohd Tariq
Cache memoy designed by Mohd Tariq
 
Cache memory
Cache memoryCache memory
Cache memory
 
Multiprocessor Architecture (Advanced computer architecture)
Multiprocessor Architecture  (Advanced computer architecture)Multiprocessor Architecture  (Advanced computer architecture)
Multiprocessor Architecture (Advanced computer architecture)
 
Memory organization (Computer architecture)
Memory organization (Computer architecture)Memory organization (Computer architecture)
Memory organization (Computer architecture)
 
Cache memory
Cache memoryCache memory
Cache memory
 
Computer organization & architecture chapter-1
Computer organization & architecture chapter-1Computer organization & architecture chapter-1
Computer organization & architecture chapter-1
 
Cache replacement policies,cache miss,writingtechniques
Cache replacement policies,cache miss,writingtechniquesCache replacement policies,cache miss,writingtechniques
Cache replacement policies,cache miss,writingtechniques
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
04 cache memory.ppt 1
04 cache memory.ppt 104 cache memory.ppt 1
04 cache memory.ppt 1
 
Cache memory
Cache memoryCache memory
Cache memory
 

Similar to What is Cache and how it works

Cache Memory for Computer Architecture.ppt
Cache Memory for Computer Architecture.pptCache Memory for Computer Architecture.ppt
Cache Memory for Computer Architecture.ppt
rularofclash69
 
cache memory
 cache memory cache memory
cache memory
NAHID HASAN
 
Cache memory
Cache memoryCache memory
Cache memory
Anand Goyal
 
unit 4.faosdfjasl;dfkjas lskadfj asdlfk jasdf;laksjdf ;laskdjf a;slkdjf
unit 4.faosdfjasl;dfkjas lskadfj asdlfk jasdf;laksjdf ;laskdjf a;slkdjfunit 4.faosdfjasl;dfkjas lskadfj asdlfk jasdf;laksjdf ;laskdjf a;slkdjf
unit 4.faosdfjasl;dfkjas lskadfj asdlfk jasdf;laksjdf ;laskdjf a;slkdjf
impro1837
 
coa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptxcoa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptx
Ruhul Amin
 
COA
COACOA
04 cache memory
04 cache memory04 cache memory
04 cache memory
dilip kumar
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
Faisal Hayat
 
Cache Memory.ppt
Cache Memory.pptCache Memory.ppt
Cache Memory.ppt
AmarDura2
 
04_Cache Memory.ppt
04_Cache Memory.ppt04_Cache Memory.ppt
04_Cache Memory.ppt
BanglaTutorial
 
04_Cache Memory.ppt
04_Cache Memory.ppt04_Cache Memory.ppt
04_Cache Memory.ppt
BanglaTutorial
 
total cache memory is here.please read this for better knowledge
total cache memory is here.please read this for better knowledgetotal cache memory is here.please read this for better knowledge
total cache memory is here.please read this for better knowledge
JoysreeNandy
 
Chache memory ( chapter number 4 ) by William stalling
Chache memory ( chapter number 4 ) by William stallingChache memory ( chapter number 4 ) by William stalling
Chache memory ( chapter number 4 ) by William stalling
ZainabShahzad9
 
Ct213 memory subsystem
Ct213 memory subsystemCt213 memory subsystem
Ct213 memory subsystemSandeep Kamath
 
cache memory introduction, level, function
cache memory introduction, level, functioncache memory introduction, level, function
cache memory introduction, level, function
TeddyIswahyudi1
 
Memory Hierarchy PPT of Computer Organization
Memory Hierarchy PPT of Computer OrganizationMemory Hierarchy PPT of Computer Organization
Memory Hierarchy PPT of Computer Organization
2022002857mbit
 

Similar to What is Cache and how it works (20)

Cache memory
Cache memoryCache memory
Cache memory
 
Cache Memory for Computer Architecture.ppt
Cache Memory for Computer Architecture.pptCache Memory for Computer Architecture.ppt
Cache Memory for Computer Architecture.ppt
 
cache memory
 cache memory cache memory
cache memory
 
Cache memory
Cache memoryCache memory
Cache memory
 
unit 4.faosdfjasl;dfkjas lskadfj asdlfk jasdf;laksjdf ;laskdjf a;slkdjf
unit 4.faosdfjasl;dfkjas lskadfj asdlfk jasdf;laksjdf ;laskdjf a;slkdjfunit 4.faosdfjasl;dfkjas lskadfj asdlfk jasdf;laksjdf ;laskdjf a;slkdjf
unit 4.faosdfjasl;dfkjas lskadfj asdlfk jasdf;laksjdf ;laskdjf a;slkdjf
 
coa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptxcoa-Unit5-ppt1 (1).pptx
coa-Unit5-ppt1 (1).pptx
 
COA
COACOA
COA
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
cache memory
cache memorycache memory
cache memory
 
04 Cache Memory
04  Cache  Memory04  Cache  Memory
04 Cache Memory
 
04 cache memory
04 cache memory04 cache memory
04 cache memory
 
Cache Memory.ppt
Cache Memory.pptCache Memory.ppt
Cache Memory.ppt
 
04_Cache Memory.ppt
04_Cache Memory.ppt04_Cache Memory.ppt
04_Cache Memory.ppt
 
04_Cache Memory.ppt
04_Cache Memory.ppt04_Cache Memory.ppt
04_Cache Memory.ppt
 
total cache memory is here.please read this for better knowledge
total cache memory is here.please read this for better knowledgetotal cache memory is here.please read this for better knowledge
total cache memory is here.please read this for better knowledge
 
Memory Mapping Cache
Memory Mapping CacheMemory Mapping Cache
Memory Mapping Cache
 
Chache memory ( chapter number 4 ) by William stalling
Chache memory ( chapter number 4 ) by William stallingChache memory ( chapter number 4 ) by William stalling
Chache memory ( chapter number 4 ) by William stalling
 
Ct213 memory subsystem
Ct213 memory subsystemCt213 memory subsystem
Ct213 memory subsystem
 
cache memory introduction, level, function
cache memory introduction, level, functioncache memory introduction, level, function
cache memory introduction, level, function
 
Memory Hierarchy PPT of Computer Organization
Memory Hierarchy PPT of Computer OrganizationMemory Hierarchy PPT of Computer Organization
Memory Hierarchy PPT of Computer Organization
 

Recently uploaded

How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
Nguyen Thanh Tu Collection
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 

Recently uploaded (20)

How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 

What is Cache and how it works

  • 1. Content: ▪ What is Cache? ▪ Cache Operation. ▪ Cache Design. ▪ Direct Mapping ▪ Associative Mapping. ▪ Replacement Algorithm. ▪ Write Policy. ▪ Write Through. ▪ Write Back.
  • 2. Cache. Small amount of fast memory Sits between normal main memory and CPU May be located on CPU chip or module
  • 5. Cache Design: Size Mapping Function Replacement Algorithm Write Policy Block Size Number of Caches
  • 6. Direct Mapping: Each location in RAM has one specific place in cache where the data will be held Address is in two parts. 1)Least Significant w bits identify unique word 2)Most Significant s bits specify one memory block . ▪ DM is Inexpensive and simple. ▪ Fixed location for given block: ▪ If a program accesses 2 blocks that map to the same line repeatedly, cache misses are very high
  • 7. Direct Mapping Address Structure. 17 bits 9 bits 6 bits ▪ 32 bit address ▪ 6 bits word identifier (4 byte block) ▪ 26 bit block identifier ▪ 17 bit tag (=26-17) ▪ 9 bit slot or line
  • 8. Replacement Algorithm Direct Mapping ▪ No choice ▪ Each block only maps to one line ▪ Replace that line
  • 9. Associative Mapping: A main memory block can load into any line of cache Memory address is interpreted as tag and word Tag uniquely identifies block of memory Tag 22 bit Word 2 bit A Diagram Link
  • 10. Set Associative Mapping. ▪ Cache is divided into a number of sets ▪ Each set contains a number of lines ▪ A given block maps to any line in a given set ▪ e.g. Block B can be in any line of set i ▪ 2 lines per set ▪ 2 way associative mapping ▪ A given block can be in one of 2 lines in only one set
  • 11. Example of Set Associative. ▪ 13 bit set number ▪ 000000, 00A000, 00B000, 00C000 … map to same set Tag 9 bit Set 13 bit Word 2 bit
  • 12. Replacement Algorithms Associative & Set Associate Mapping. ▪ Hardware implemented algorithm (speed) ▪ Least Recently Used (LRU) ▪ In 2 way set associative ▪ Which of the 2 block is LRU?
  • 13. Replacement Algorithms Associative & Set Associate Mapping.  First in first out (FIFO)  replace block that has been in cache longest  Least frequently used  Replace block which has had fewest hits  Random
  • 14. Write Policy: ▪ Must not overwrite a cache block unless main memory is up to date ▪ Multiple CPUs may have individual caches ▪ I/O may address main memory directly
  • 15. Write Through: ▪ All writes go to main memory as well as cache ▪ Multiple CPUs can monitor main memory traffic to keep local (to CPU) cache up to date ▪ Lots of traffic ▪ Slows down writes
  • 16. Write Back: ▪ Updates initially made in cache only ▪ Update bit for cache slot is set when update occurs ▪ If block is to be replaced, write to main memory only if update bit is set ▪ I/O must access main memory through cache

Editor's Notes

  1. Direct has the lowest performance, but is easiest to implement • Direct is often used for instruction cache • Sequential addresses fill a cache line and then go to the next cache line
  2. The cache memory is divided into blocks or lines. Currently lines can range from 16 to 64 bytes • Data is copied to and from the cache one line at a time
  3. DM: Each block of main memory maps to only one cache line i.e. if a block is in cache, it must be in one specific place… Address is in two parts 1)Least Significant w bits identify unique word 2)Most Significant s bits specify one memory block . DM is Inexpensive and simple. Fixed location for given block: If a program accesses 2 blocks that map to the same line repeatedly, cache misses are very high
  4. A main memory block can load into any line of cache.. Memory address is interpreted as tag and word…Cache searching gets expensive