SlideShare a Scribd company logo
Cache Mapping Examples
Direct Mapping
Direct Mapping  Each block of main memory maps to only one cache line – i.e. if a block is in
cache, it will always be found in the same place
Line number is calculated using the following function
i = j modulo m
where
i = cache line number
j = main memory block number
m = number of lines in the cache
Direct Mapping
What cache line number will the following addresses be stored to, and what will the
minimum address and the maximum address of each block they are in be if we have a
cache with 4K lines of 16 words to a block in a 256 MB memory space (28-bit address)?
a.) 9ABCDEF16 1001 1010 1011 1100 1101 1110 1111 - Line 3294
b.) 123456716 0001 0010 0011 0100 0101 0110 0111 - Line 1110
a.) 9ABCDEF16 9ABCDE0 - 9ABCDEF
b.) 123456716 1234560 - 123456F
Tag s-r
12 12 4
Line or slot r Word w
P1
Direct Mapping
Assume that a portion of the tags in the cache in our example looks like the table
below. Which of the following addresses are contained in the cache?
a.) 438EE816 b.) F18EFF16 c.) 6B8EF316 d.) AD8EF316
P2
P3
P3
P3
P4
P4
Fully Associative Mapping
• A main memory block can load into any line of cache
• Memory address is interpreted as:
– Least significant w bits = word position within block
– Most significant s bits = tag used to identify which block is stored in a
particular line of cache
• Every line's tag must be examined for a match
• Cache searching gets expensive and slower
Tag – s bits
(22 in example)
Word – w bits
(2 in ex.)
P1
Fully Associative Mapping Example
Assume that a portion of the tags in the cache in our example looks
like the table below. Which of the following addresses are contained
in the cache?
a.) 438EE816 b.) F18EFF16 c.) 6B8EF316 d.) AD8EF316
P2
P3
Set - Associative Mapping
Set Associative Mapping Traits
• Address length is s + w bits
• Cache is divided into a number of sets, v = 2d
• K blocks/lines can be contained within each set
• K lines in a cache is called a k-way set associative mapping
• Number of lines in a cache = v•k = k•2d
• Size of tag = (s-d) bits
• Hybrid of Direct and Associative
k = 1, this is basically direct mapping
v = 1, this is associative mapping
• Each set contains a number of lines, basically the number of lines divided by
the number of sets
• A given block maps to any line within its specified set – e.g. Block B can be in
any line of set i.
• 2 lines per set is the most common organization.
– Called 2 way associative mapping
– A given block can be in one of 2 lines in only one specific set
– Significant improvement over direct mapping
Set Associative Mapping Example
• What cache set number will the block be stored to?
• What will their tag be?
• What will the minimum address and the maximum address of each block they
are in be?
1. 9ABCDEF16
2. 123456716
For each of the following addresses, answer the following questions based on a 2-way
set associative cache with 4K lines, each line containing 16 words, with the main
memory of size 256 Meg memory space (28-bit address):
Tag s-r
13 11 4
Set s Word w
• Address length = (s + w) bits
• Number of addressable units = 2s+w words or bytes
• Block size = line size = 2w words or bytes
• Number of blocks in main memory = 2s+ w/2w = 2s
• Number of lines in set = k
• Number of sets = v = 2d
• Number of lines in cache = kv = k * 2d
• Size of tag = (s – d) bits
Set Associative Mapping Summary
P1
P2
P2
P2
P3
P3
P4
P4
Cmp.pptx

More Related Content

Similar to Cmp.pptx

Cache recap
Cache recapCache recap
Cache recap
Fraboni Ec
 
Cache recap
Cache recapCache recap
Cache recap
James Wong
 
Cache recap
Cache recapCache recap
Cache recap
Hoang Nguyen
 
CACHEMAPPING POLICIE AND MERITS & DEMERITS
CACHEMAPPING POLICIE AND MERITS & DEMERITSCACHEMAPPING POLICIE AND MERITS & DEMERITS
CACHEMAPPING POLICIE AND MERITS & DEMERITS
AnkitPandey440
 
Cache memory
Cache memoryCache memory
Cache memory
Anand Goyal
 
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
 
04 cache memory.ppt 1
04 cache memory.ppt 104 cache memory.ppt 1
04 cache memory.ppt 1
Anwal Mirza
 
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
 
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
 
M.f
M.f M.f
Cache memory
Cache memoryCache memory
Cache memory
Shailesh Tanwar
 
Advanced Computer Architecture chapter 5 problem solutions
Advanced Computer  Architecture  chapter 5 problem solutionsAdvanced Computer  Architecture  chapter 5 problem solutions
Advanced Computer Architecture chapter 5 problem solutions
Joe Christensen
 

Similar to Cmp.pptx (20)

Cache mapping
Cache mappingCache mapping
Cache mapping
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache recap
Cache recapCache recap
Cache recap
 
Cache recap
Cache recapCache recap
Cache recap
 
04 Cache Memory
04  Cache  Memory04  Cache  Memory
04 Cache Memory
 
CACHEMAPPING POLICIE AND MERITS & DEMERITS
CACHEMAPPING POLICIE AND MERITS & DEMERITSCACHEMAPPING POLICIE AND MERITS & DEMERITS
CACHEMAPPING POLICIE AND MERITS & DEMERITS
 
Cache memory
Cache memoryCache memory
Cache memory
 
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
 
04 cache memory.ppt 1
04 cache memory.ppt 104 cache memory.ppt 1
04 cache memory.ppt 1
 
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
 
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
 
M.f
M.f M.f
M.f
 
Cache memory
Cache memoryCache memory
Cache memory
 
Advanced Computer Architecture chapter 5 problem solutions
Advanced Computer  Architecture  chapter 5 problem solutionsAdvanced Computer  Architecture  chapter 5 problem solutions
Advanced Computer Architecture chapter 5 problem solutions
 

Recently uploaded

basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
skuxot
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
ssuser36d3051
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
introduction to solar energy for engineering.pdf
introduction to solar energy for engineering.pdfintroduction to solar energy for engineering.pdf
introduction to solar energy for engineering.pdf
ravindarpurohit26
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
wisnuprabawa3
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
gerogepatton
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
yokeleetan1
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
Ratnakar Mikkili
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
ihlasbinance2003
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
heavyhaig
 

Recently uploaded (20)

basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
一比一原版(UC Berkeley毕业证)加利福尼亚大学|伯克利分校毕业证成绩单专业办理
 
sieving analysis and results interpretation
sieving analysis and results interpretationsieving analysis and results interpretation
sieving analysis and results interpretation
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
introduction to solar energy for engineering.pdf
introduction to solar energy for engineering.pdfintroduction to solar energy for engineering.pdf
introduction to solar energy for engineering.pdf
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
New techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdfNew techniques for characterising damage in rock slopes.pdf
New techniques for characterising damage in rock slopes.pdf
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Swimming pool mechanical components design.pptx
Swimming pool  mechanical components design.pptxSwimming pool  mechanical components design.pptx
Swimming pool mechanical components design.pptx
 
Exception Handling notes in java exception
Exception Handling notes in java exceptionException Handling notes in java exception
Exception Handling notes in java exception
 
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
5214-1693458878915-Unit 6 2023 to 2024 academic year assignment (AutoRecovere...
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
Technical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prismsTechnical Drawings introduction to drawing of prisms
Technical Drawings introduction to drawing of prisms
 

Cmp.pptx

  • 2. Direct Mapping Direct Mapping  Each block of main memory maps to only one cache line – i.e. if a block is in cache, it will always be found in the same place Line number is calculated using the following function i = j modulo m where i = cache line number j = main memory block number m = number of lines in the cache
  • 3. Direct Mapping What cache line number will the following addresses be stored to, and what will the minimum address and the maximum address of each block they are in be if we have a cache with 4K lines of 16 words to a block in a 256 MB memory space (28-bit address)? a.) 9ABCDEF16 1001 1010 1011 1100 1101 1110 1111 - Line 3294 b.) 123456716 0001 0010 0011 0100 0101 0110 0111 - Line 1110 a.) 9ABCDEF16 9ABCDE0 - 9ABCDEF b.) 123456716 1234560 - 123456F Tag s-r 12 12 4 Line or slot r Word w P1
  • 4. Direct Mapping Assume that a portion of the tags in the cache in our example looks like the table below. Which of the following addresses are contained in the cache? a.) 438EE816 b.) F18EFF16 c.) 6B8EF316 d.) AD8EF316 P2
  • 5. P3
  • 6. P3
  • 7. P3
  • 8. P4
  • 9. P4
  • 10. Fully Associative Mapping • A main memory block can load into any line of cache • Memory address is interpreted as: – Least significant w bits = word position within block – Most significant s bits = tag used to identify which block is stored in a particular line of cache • Every line's tag must be examined for a match • Cache searching gets expensive and slower Tag – s bits (22 in example) Word – w bits (2 in ex.)
  • 11. P1 Fully Associative Mapping Example Assume that a portion of the tags in the cache in our example looks like the table below. Which of the following addresses are contained in the cache? a.) 438EE816 b.) F18EFF16 c.) 6B8EF316 d.) AD8EF316
  • 12. P2
  • 13.
  • 14. P3
  • 15. Set - Associative Mapping Set Associative Mapping Traits • Address length is s + w bits • Cache is divided into a number of sets, v = 2d • K blocks/lines can be contained within each set • K lines in a cache is called a k-way set associative mapping • Number of lines in a cache = v•k = k•2d • Size of tag = (s-d) bits
  • 16. • Hybrid of Direct and Associative k = 1, this is basically direct mapping v = 1, this is associative mapping • Each set contains a number of lines, basically the number of lines divided by the number of sets • A given block maps to any line within its specified set – e.g. Block B can be in any line of set i. • 2 lines per set is the most common organization. – Called 2 way associative mapping – A given block can be in one of 2 lines in only one specific set – Significant improvement over direct mapping
  • 17. Set Associative Mapping Example • What cache set number will the block be stored to? • What will their tag be? • What will the minimum address and the maximum address of each block they are in be? 1. 9ABCDEF16 2. 123456716 For each of the following addresses, answer the following questions based on a 2-way set associative cache with 4K lines, each line containing 16 words, with the main memory of size 256 Meg memory space (28-bit address): Tag s-r 13 11 4 Set s Word w
  • 18. • Address length = (s + w) bits • Number of addressable units = 2s+w words or bytes • Block size = line size = 2w words or bytes • Number of blocks in main memory = 2s+ w/2w = 2s • Number of lines in set = k • Number of sets = v = 2d • Number of lines in cache = kv = k * 2d • Size of tag = (s – d) bits Set Associative Mapping Summary
  • 19. P1
  • 20. P2
  • 21. P2
  • 22. P2
  • 23. P3
  • 24. P3
  • 25. P4
  • 26. P4