Skip to main content...
S1 · Computer Organization & the RISC-V ISA
30 min

Day 48: Memory hierarchy: SRAM vs DRAM, and the cache idea

Memory is slow and CPUs are fast. The cache is the small, fast buffer that bridges the gap — and the reason your programs feel instant.

The memory hierarchy

Fast memory is small and expensive; big memory is slow. The memory hierarchy stacks them: registers (fastest), then SRAM caches (fast, 6 transistors/bit, no refresh), then DRAM main memory (dense, 1 transistor + capacitor/bit, needs refresh), then storage. The trick that makes it work is locality: programs reuse recent data (temporal) and nearby data (spatial), so a small fast cache captures most accesses.

A cache holds recently/nearby-used blocks of memory close to the CPU. A hit is served fast; a miss falls through to slower memory and brings the block up. Because of locality, hit rates are high (often >90%), so average access time stays close to the fast level despite most *bytes* living in slow memory. ChipX's optional I-cache (Stage 2 stretch) is a direct-mapped instance of this idea.

Desk, drawer, warehouse

Registers are the papers in your hand; the cache is your desk; DRAM is the filing cabinet; storage is the offsite warehouse. You keep what you're using on the desk because walking to the warehouse for every page would be unbearable — and it works precisely because you tend to reuse the same few pages (locality).

Key terms

SRAM
Static RAM — fast, 6T bitcell, holds state without refresh; used for caches.
DRAM
Dynamic RAM — dense 1T1C bitcell needing periodic refresh; used for main memory.
Temporal / spatial locality
Reuse of recently accessed data / access to nearby addresses; the basis for caching.
Cache hit / miss
Data found in (hit) or absent from (miss) the cache; misses fetch from slower memory.
Memory hierarchy
The speed/size tiers from registers down to storage that together approximate fast-and-big.

Before moving on, you should be able to

Why does a small SRAM cache dramatically speed up a system whose data mostly lives in slow DRAM?

We use cookies

We use cookies to enhance your browsing experience, serve personalized content, and analyze our traffic. By clicking "Accept All", you consent to our use of cookies. Learn more

    Day 48: Memory hierarchy: SRAM vs DRAM, and the cache idea | RBTechIconX