SlideShare a Scribd company logo
1 of 15
Download to read offline
Digital Logic and Computer
Architecture
UNIT-5
MEMORY ORGANIZATION
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 1
Topics to be Discussed
➢Cache Memory-Introduction
➢Cache Mapping Techniques
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 2
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 3
Memory
Hierarchy
Cache Memory
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 4
 Cache Memory is placed between the CPU and Main Memory.
 10 to 100 times faster than Main Memory
 Cache Memory uses the Principle of Locality of Reference
Cache Memory-Hit and Miss
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 5
Principle of Locality of Reference
➢Cache Memory uses the Principle of Locality of Reference
➢Temporal locality of reference
The tendency of a computer Program to access the
same set of memory locations for a particular time period.
➢Spatial Locality of Reference
The tendency of the computer program to access
instructions whose addresses are near one another.
➢Average Execution Time α Average Memory Access Time
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 6
Hit Ratio & Average Memory Access Time
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 7
 Hit Ratio=
Total No. of Hits
Total No. of Memory Accesses by CPU
 Total No. of Memory Accesses= No. of Hits+ No. of
Misses
 Average Memory access time =
Tavg = h * Tc + (1-h)*(Tm + Tc)
 h- Probability of a Hit
 Tm-Main Memory Access Time
 Tc- Cache Memory Access Time
Problems
1. If a CPU has 39 Cache Hits and 2 Cache Misses
over a given timeframe, then find the Cache Hit
ratio. (Ans:
2. Calculate the average access time if cache
memory access time is 150ns and memory access
time is 900 ns and we have the hit ratio for cache
memory as h=0.8.
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 8
Problems
1. If a CPU has 39 Cache Hits and 2 Cache Misses
over a given timeframe, then find the Cache Hit
ratio.
(Ans: 0.95)
1. Calculate the average access time if cache
memory access time is 150ns and memory access
time is 900 ns and we have the hit ratio for cache
memory as h=0.8.
(Ans: 0.8*150+0.2*1050=330ns)
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 9
Cache Mapping Techniques
➢Entire Main Memory is divided into equal sized
Blocks.
➢Cache Memory is also divided into same-sized Blocks
➢Cache Mapping Technique defines mapping between
Blocks of Main Memory and Blocks of Cache Memory.
➢Direct Mapping
➢Associative Mapping
➢Set – Associative Mapping
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 10
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 11
Cache Memory
Main Memory
Assumption
Consider a cache consisting of 128 blocks of 16
words each, for total of 2048 (2K) words and assume
that the main memory is addressable by 16 bit
address. Main memory is 64K which will be viewed
as 4K blocks of 16 words each.
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 12
Cache Memory
No. of Blocks=128
No. of Words=128 *16
=2048
=2*1024
=2K
Main Memory (16-bit Address)
No. of Words=216
= 26 * 210
= 64K
=16*4K
No. of Blocks=4K
Direct Mapping
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 13
Cache Memory
No. of Blocks/Lines
=128
Main Memory
No. of Blocks=4K
=4*1024=4096
Block J of the main
memory maps on to
Block J modulo 128 of
the cache (Line)
Line 0-Block 0,128,256…
Line 1-Block 1,129,257…
Line 2-Block 2,130,258…
…..
Line 127-Block 127,255…
No.of Tag Bits=No. of
Possiible Blocks in each
line=log2(4096/128)
Associative Mapping
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 14
Cache Memory
No. of Blocks/Lines
=128
Main Memory
No. of Blocks=4K
=4*1024=4096
➢ More Flexible
➢ Any Main Memory
Block can be placed
into any Cache Block
position (Line).
No.of Tag Bits=
No. of Possiible Blocks in
each Cache Line
=log2(4096) = 12
Set Associative Mapping
(2-way)
DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 15
Cache Memory
No. of Blocks/Lines
=128
Main Memory
No. of Blocks=4K
=4*1024=4096
➢ Combination of Direct and
Associative Mappings
➢ Reduces Contention
Problem of Direct
Mapping
➢ Reduces the H/W cost by
reducing the size of
Associative Search
Line 0 - Set 0
Line 1 Blocks 0,64,128,.. 4032
No.of Set bits= log2(128/2) = 6, No. of Tag Bits=log2(4096/256)

More Related Content

Similar to DLCA-UNIT-5-Memory Organization-Cache.pdf

Lec10 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Memory part2
Lec10 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Memory part2Lec10 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Memory part2
Lec10 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Memory part2Hsien-Hsin Sean Lee, Ph.D.
 
Memory organization.pptx
Memory organization.pptxMemory organization.pptx
Memory organization.pptxRamanRay105
 
Computer Memory Hierarchy Computer Architecture
Computer Memory Hierarchy Computer ArchitectureComputer Memory Hierarchy Computer Architecture
Computer Memory Hierarchy Computer ArchitectureHaris456
 
memeoryorganization PPT for organization of memories
memeoryorganization PPT for organization of memoriesmemeoryorganization PPT for organization of memories
memeoryorganization PPT for organization of memoriesGauravDaware2
 
computer system embedded system volume1.ppt
computer system embedded system volume1.pptcomputer system embedded system volume1.ppt
computer system embedded system volume1.pptmshanajoel6
 
CPU Memory Hierarchy and Caching Techniques
CPU Memory Hierarchy and Caching TechniquesCPU Memory Hierarchy and Caching Techniques
CPU Memory Hierarchy and Caching TechniquesDilum Bandara
 
Chp3 designing bus system, memory & io copy
Chp3 designing bus system, memory & io   copyChp3 designing bus system, memory & io   copy
Chp3 designing bus system, memory & io copymkazree
 
onur-comparch-fall2018-lecture3b-memoryhierarchyandcaches-afterlecture.pptx
onur-comparch-fall2018-lecture3b-memoryhierarchyandcaches-afterlecture.pptxonur-comparch-fall2018-lecture3b-memoryhierarchyandcaches-afterlecture.pptx
onur-comparch-fall2018-lecture3b-memoryhierarchyandcaches-afterlecture.pptxsivasubramanianManic2
 
Chapter 8 : Memory
Chapter 8 : MemoryChapter 8 : Memory
Chapter 8 : MemoryAmin Omi
 
Chapter 8 memory-updated
Chapter 8 memory-updatedChapter 8 memory-updated
Chapter 8 memory-updatedDelowar hossain
 
High-Performance Physics Solver Design for Next Generation Consoles
High-Performance Physics Solver Design for Next Generation ConsolesHigh-Performance Physics Solver Design for Next Generation Consoles
High-Performance Physics Solver Design for Next Generation ConsolesSlide_N
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdfKadu37
 

Similar to DLCA-UNIT-5-Memory Organization-Cache.pdf (20)

Lec10 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Memory part2
Lec10 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Memory part2Lec10 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Memory part2
Lec10 Computer Architecture by Hsien-Hsin Sean Lee Georgia Tech -- Memory part2
 
Memory organization.pptx
Memory organization.pptxMemory organization.pptx
Memory organization.pptx
 
Coa presentation3
Coa presentation3Coa presentation3
Coa presentation3
 
Computer Memory Hierarchy Computer Architecture
Computer Memory Hierarchy Computer ArchitectureComputer Memory Hierarchy Computer Architecture
Computer Memory Hierarchy Computer Architecture
 
Cache Memory
Cache MemoryCache Memory
Cache Memory
 
Lecture 25
Lecture 25Lecture 25
Lecture 25
 
memeoryorganization PPT for organization of memories
memeoryorganization PPT for organization of memoriesmemeoryorganization PPT for organization of memories
memeoryorganization PPT for organization of memories
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
cache memory management
cache memory managementcache memory management
cache memory management
 
computer system embedded system volume1.ppt
computer system embedded system volume1.pptcomputer system embedded system volume1.ppt
computer system embedded system volume1.ppt
 
CPU Memory Hierarchy and Caching Techniques
CPU Memory Hierarchy and Caching TechniquesCPU Memory Hierarchy and Caching Techniques
CPU Memory Hierarchy and Caching Techniques
 
Chp3 designing bus system, memory & io copy
Chp3 designing bus system, memory & io   copyChp3 designing bus system, memory & io   copy
Chp3 designing bus system, memory & io copy
 
onur-comparch-fall2018-lecture3b-memoryhierarchyandcaches-afterlecture.pptx
onur-comparch-fall2018-lecture3b-memoryhierarchyandcaches-afterlecture.pptxonur-comparch-fall2018-lecture3b-memoryhierarchyandcaches-afterlecture.pptx
onur-comparch-fall2018-lecture3b-memoryhierarchyandcaches-afterlecture.pptx
 
Chapter 8 : Memory
Chapter 8 : MemoryChapter 8 : Memory
Chapter 8 : Memory
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
Chapter 8 memory-updated
Chapter 8 memory-updatedChapter 8 memory-updated
Chapter 8 memory-updated
 
High-Performance Physics Solver Design for Next Generation Consoles
High-Performance Physics Solver Design for Next Generation ConsolesHigh-Performance Physics Solver Design for Next Generation Consoles
High-Performance Physics Solver Design for Next Generation Consoles
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdf
 
SO-Memoria.pdf
SO-Memoria.pdfSO-Memoria.pdf
SO-Memoria.pdf
 
Caches microP
Caches microPCaches microP
Caches microP
 

Recently uploaded

Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 

DLCA-UNIT-5-Memory Organization-Cache.pdf

  • 1. Digital Logic and Computer Architecture UNIT-5 MEMORY ORGANIZATION DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 1
  • 2. Topics to be Discussed ➢Cache Memory-Introduction ➢Cache Mapping Techniques DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 2
  • 3. DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 3 Memory Hierarchy
  • 4. Cache Memory DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 4  Cache Memory is placed between the CPU and Main Memory.  10 to 100 times faster than Main Memory  Cache Memory uses the Principle of Locality of Reference
  • 5. Cache Memory-Hit and Miss DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 5
  • 6. Principle of Locality of Reference ➢Cache Memory uses the Principle of Locality of Reference ➢Temporal locality of reference The tendency of a computer Program to access the same set of memory locations for a particular time period. ➢Spatial Locality of Reference The tendency of the computer program to access instructions whose addresses are near one another. ➢Average Execution Time α Average Memory Access Time DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 6
  • 7. Hit Ratio & Average Memory Access Time DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 7  Hit Ratio= Total No. of Hits Total No. of Memory Accesses by CPU  Total No. of Memory Accesses= No. of Hits+ No. of Misses  Average Memory access time = Tavg = h * Tc + (1-h)*(Tm + Tc)  h- Probability of a Hit  Tm-Main Memory Access Time  Tc- Cache Memory Access Time
  • 8. Problems 1. If a CPU has 39 Cache Hits and 2 Cache Misses over a given timeframe, then find the Cache Hit ratio. (Ans: 2. Calculate the average access time if cache memory access time is 150ns and memory access time is 900 ns and we have the hit ratio for cache memory as h=0.8. DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 8
  • 9. Problems 1. If a CPU has 39 Cache Hits and 2 Cache Misses over a given timeframe, then find the Cache Hit ratio. (Ans: 0.95) 1. Calculate the average access time if cache memory access time is 150ns and memory access time is 900 ns and we have the hit ratio for cache memory as h=0.8. (Ans: 0.8*150+0.2*1050=330ns) DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 9
  • 10. Cache Mapping Techniques ➢Entire Main Memory is divided into equal sized Blocks. ➢Cache Memory is also divided into same-sized Blocks ➢Cache Mapping Technique defines mapping between Blocks of Main Memory and Blocks of Cache Memory. ➢Direct Mapping ➢Associative Mapping ➢Set – Associative Mapping DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 10
  • 11. DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 11 Cache Memory Main Memory
  • 12. Assumption Consider a cache consisting of 128 blocks of 16 words each, for total of 2048 (2K) words and assume that the main memory is addressable by 16 bit address. Main memory is 64K which will be viewed as 4K blocks of 16 words each. DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 12 Cache Memory No. of Blocks=128 No. of Words=128 *16 =2048 =2*1024 =2K Main Memory (16-bit Address) No. of Words=216 = 26 * 210 = 64K =16*4K No. of Blocks=4K
  • 13. Direct Mapping DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 13 Cache Memory No. of Blocks/Lines =128 Main Memory No. of Blocks=4K =4*1024=4096 Block J of the main memory maps on to Block J modulo 128 of the cache (Line) Line 0-Block 0,128,256… Line 1-Block 1,129,257… Line 2-Block 2,130,258… ….. Line 127-Block 127,255… No.of Tag Bits=No. of Possiible Blocks in each line=log2(4096/128)
  • 14. Associative Mapping DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 14 Cache Memory No. of Blocks/Lines =128 Main Memory No. of Blocks=4K =4*1024=4096 ➢ More Flexible ➢ Any Main Memory Block can be placed into any Cache Block position (Line). No.of Tag Bits= No. of Possiible Blocks in each Cache Line =log2(4096) = 12
  • 15. Set Associative Mapping (2-way) DR. K. RADHIKA, PROFESSOR, IT DEPARTMENT, CBIT 15 Cache Memory No. of Blocks/Lines =128 Main Memory No. of Blocks=4K =4*1024=4096 ➢ Combination of Direct and Associative Mappings ➢ Reduces Contention Problem of Direct Mapping ➢ Reduces the H/W cost by reducing the size of Associative Search Line 0 - Set 0 Line 1 Blocks 0,64,128,.. 4032 No.of Set bits= log2(128/2) = 6, No. of Tag Bits=log2(4096/256)