Lec-8 Memory-3 CompArch
Lec-8 Memory-3 CompArch
Memory
Part-3
CSE-2823
Computer Architecture
Dr. Md. Waliur Rahman Miah
Associate Professor, CSE, DUET
1
Today’s Topic
Memory
Part-3
Ref:
Hennessy-Patterson 5e-Ch-5; 4e-Ch-7
Stallings 8e-Ch-4-5-6
20 10
Hit Data
Tag
Index
1021
1022
1023
20 32
• Cache data = 128 KB = 217 bytes = 215 words = 215 blocks [1-word block size]
• Cache entry size = block data bits + tag bits + valid bit
= 32 + (32 – 15 – 2) + 1 = 48 bits
• Therefore, cache size =
= 215 48 bits
= 215 (1.5 32) bits
= 1.5 220 bits
= 1.5 Mbits
– data bits in cache = 128 KB 8 = 1 Mbits
– total cache size/actual cache data = 1.5
• Cache size = 128 KB = 217 bytes = 215 words = 213 blocks [4-word block size]
• Cache entry size = block data bits + tag bits + valid bit
= 128 + (32 – 13 – 2 – 2) + 1 = 144 bits
• Therefore, cache size
= 213 144 bits
= 213 (1.25 128) bits
= 1.25 220 bits
= 1.25 Mbits
– data bits in cache = 128 KB 8 = 1 Mbits
– total cache size/actual cache data = 1.25
• Write-back scheme
– write the data block only into the cache and write-back
the block to main memory only when it is replaced in
cache
– more efficient than write-through, more complex to
implement
Dr. Md. Waliur Rahman Miah Dept of CSE, DUET
Direct Mapped Cache: Taking
Advantage of Spatial Locality
• Taking advantage of spatial locality with larger blocks:
Address
Address showing bit positions
(showing bit positions)
31 16 15 4 32 1 0
16 12 2 Byte
Hit Tag Data
offset
Index Block offset
16 bits 128 bits
V Tag Data
4K
entries
16 32 32 32 32
Mux
32
Cache with 4K 4-word blocks: byte offset (least 2 significant bits) is ignored,
next 2 bits are block offset, and the next 12 bits are used to index into cache
Dr. Md. Waliur Rahman Miah Dept of CSE, DUET
Direct Mapped Cache: Taking Advantage of
Spatial Locality
25%
expected, but, as block size
Miss rate
20%
5%
go up because 0%
4 16 64 256
1. How much faster is a machine with a perfect cache that never misses?
2. What happens if we speed up the machine by reducing its CPI to 1
without changing the clock rate?
3. What happens if we speed up the machine by doubling its clock rate, but
if the absolute time for a miss penalty remains same?
• Conclusion: with higher CPI cache misses “hurt more” than with lower CPI