SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
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)

Weitere ähnliche Inhalte

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
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
 
(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
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
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
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 

Kürzlich hochgeladen (20)

(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
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...
 
(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...
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
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
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 

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)