CS 152 Computer Architecture and Engineering
CS252A Graduate Computer Architecture Lecture 5 - Memory I

Chris Fletcher
UC Berkeley, Spring 2026

Memory: Large, Fast, Cheap: Pick Two

Semiconductor Memory: SRAM vs. DRAM

6-T SRAM cell WL bit ~bit cross-coupled inverters + 2 access transistors
1-T DRAM cell WL bit VREF 1 transistor + 1 storage capacitor
SRAM ("faucet")DRAM ("leaky bucket")
Cell4–6 transistors1 transistor + 1 capacitor (trench/stacked)
ReadNon-destructiveDestructive (charge sharing): rewrite every read
RefreshNoneEvery few milliseconds
Address pinsSeparate row/columnTime-multiplexed
Optimized forSpeed, then densityDensity, then speed

DRAM Is ~10× Denser

DRAM Array Architecture

DIMM → Rank → Chip → Bank → Array → Cell

Rowdecoder N row bits 2ᴺ word lines × 2ᴹ bit lines Column decoder &sense amplifiers M column bits → D data bits
  • Bank: unit activated independently per access (~4–8 logical banks per chip)
  • Address = $N$ row bits + $M$ column bits
  • Row decoder drives one of $2^N$ word lines: all $2^M$ cells in the row turn on
  • Sense amps amplify, latch the whole row, select $D$ bits

Check Your Understanding

1. Comparison: give two physical reasons a 1-T DRAM cell is slower and needs more control than a 6-T SRAM cell.
Destructive reads (charge sharing drains the cell; sense amps must restore it) and charge leakage forcing refresh every few ms (plus multiplexed address pins).
2. Array calculation: $N = 10$ row bits, $M = 10$ column bits, $D = 1$. Cells per word line? Total bits?
$2^{10} = 1{,}024$ cells per word line; $2^{20} = 1{,}048{,}576$ bits (1 Mebibit).

CPU–Memory Bottleneck

DRAM Operation

  1. Row access (RAS / ACT)
    • Activate one word line (several Kbits); sense amps latch the row and restore the cells
  2. Column access (CAS / READ or WRITE)
    • Select 4–32 bits from the latched row to the pins
    • Burst mode: more column accesses on the open row, no new row access
  3. Precharge (PRE)
    • Equalize bit lines to mid-rail before the next row

Each step ~15–20 ns. DDR: data pins transfer on both clock edges (200 MHz clock → 400 Mb/s per pin), array physics unchanged.

Packaging Memory for Bandwidth

PackageHowBandwidth
DIMMChips share clock/control/address (~7 + ~12 pins); data pins combined, e.g. 16 × 4-bit = 64-bit bus–
On-package DRAM (Apple M1, 2020)Two DRAM chips on the SoC package, 128-bit bus at 4.2 Gb/s/pin$\frac{128 \times 4.2}{8} = 67.2$ GB/s
HBM2 (2.5D, NEC SX-Aurora)Stacked DRAM on a silicon interposer; 6 × 1,024-bit channels at 1.6 Gb/s/pin$\frac{6 \times 1024 \times 1.6}{8} \approx 1.2$ TB/s

Check Your Understanding

1. Quick computation: 30% of instructions are loads/stores ($m = 0.30$). Memory references per cycle for CPI = 1?
$1 + 0.30 = 1.3$ (one fetch plus 0.3 data accesses on average).
2. Mechanism: why is a burst of sequential column reads faster than random reads across rows?
The row is already latched in the sense amps; further CAS accesses to it skip precharge and RAS.

Memory Reference Patterns

timeaddress instruction fetches (loops) stack vector access scalar accesses
  • Real traces (Hatfield & Gerald, 1971) are highly structured
  • Temporal locality: referenced again soon (flat bands: loops, scalars)
  • Spatial locality: neighbors referenced soon (sweeps: sequential code, arrays)

Memory Hierarchy

CPU Small, fast memory(RF, SRAM) Big, slow memory(DRAM)

Inside a Cache

Address tagData block
100copy of 100, 101, …
304copy of 304, 305, …
6848…
416…

Read algorithm

  1. Search the relevant tag(s) for the processor address
  2. Hit: return the copy from SRAM
  3. Miss: read the block from lower memory, return the data, install the block

Where can the block go, and which line does it replace?

Check Your Understanding

1. Locality: accessing A[0], A[1], A[2], A[3] in a loop shows which locality?
Spatial: each access is followed by one at a nearby address.
2. Concept: why are caches microarchitectural rather than architectural?
Software can't name them in the ISA; changing cache size or layout doesn't change program correctness.

Placement Policy

Memory blocks 0–31, cache of 8 blocks. Where can block 12 go?

Fully associative2-way set associativeDirect mapped anywhere set 0set 1set 2set 3 either way of set 12 mod 4 = 0 01234567 only block 12 mod 8 = 4

Cache = HW-Optimized Hash Table

Direct-Mapped Cache

Tag (t bits) Index (k) Offset (b) VTagData block selects 1 of 2ᵏ lines = AND HIT mux data word or byte

Why the Index Uses Low-Order Bits

Example: Address Bit Slicing

16 KB direct-mapped cache, 64-byte blocks, 32-bit byte addresses

Tag [31:14] — 18 bits Index [13:6] — 8 Offset — 6

Same cache, 2-way: 128 sets ⇒ k = 7, t = 19, b = 6

Set-Associative and Fully Associative

Replacement Policy

Pseudo-LRU Binary Tree (4-way)

root L R 10 1010 W3W2W1W0 3 bits; each bit points toward the victim
  • Start: all bits 0, 0, 0 → victim W0
  • Hit to W2: flip bits on its path to point away
    • root → 0 (away from left half)
    • L → 1 (toward W3)
  • Miss: follow pointers: root 0 → R 0 → evict W0

Block Size Tradeoffs

Check Your Understanding

1. Address split: 32 KB, 4-way, 32-byte blocks, 32-bit addresses. Offset, index, tag widths?
b = 5; lines = 1,024, sets = 256 ⇒ k = 8; t = 32 − 8 − 5 = 19.
2. Design: why must a direct-mapped cache index with low-order block-address bits rather than [31 : 32−k]?
Sequential addresses share their high bits, so consecutive blocks would all collide in one line, destroying spatial locality.