CS 152 Computer Architecture and Engineering
CS252A Graduate Computer Architecture Lecture 4 - Pipelining II

Chris Fletcher
UC Berkeley, Spring 2026

Pipeline Categories

CategoryIdea
Super-pipelinedSlice stages into sub-stages to raise clock frequency
DecoupledSplit integer/address work from FP execution via queues
Out-of-orderIn-order frontend fills an instruction pool; backend issues independent instructions out of order
SuperscalarWiden frontend and backend to fetch and execute several instructions per cycle

Deeper Pipelines: MIPS R4000

Caches too slow for one short cycle → split cache access into stages (8 total):

StageWork
IFInstruction cache fetch, first half
ISInstruction cache fetch, second half (bits ready before the tag check)
RFRegister fetch + I-cache tag check (speculate a direct-mapped I$ hit)
EXALU execution, branch condition
DFData cache fetch, first half
DSData cache fetch, second half (data ready at end of DS)
TCData cache tag check; commit point right after
WBRegister writeback

R4000 Branches and Load-Use Delay

Branch: 3-cycle delay (condition known in EX, cycle 4)

1234567
BEQZIFISRFEXDFDSTC
Inst 1IFISRF
Inst 2IFIS
Inst 3IF
TargetIFISRF

Load-use: 2-cycle delay (data at end of DS, bypassed before TC)

12345678
LD R1IFISRFEXDFDSTCWB
Inst 1IFISRFEXDFDSTC
Inst 2IFISRFEXDFDS
ADDD R2,R1IFISRFEXDF

Speculative bypass from DS to EX in cycle 7, before TC confirms the hit; a TC miss stalls/recovers.

Vector-Vector Add Example

for (i = 0; i < N; i++) A[i] = B[i] + C[i];

loop: fld    f0, 0(x2)       // x2 -> B[i]
      fld    f1, 0(x3)       // x3 -> C[i]
      fadd.d f2, f0, f1      // stalls waiting for f1!
      fsd    f2, 0(x1)       // x1 -> A[i]; stalls waiting for f2!
      addi   x1, x1, 8
      addi   x2, x2, 8
      addi   x3, x3, 8
      bne    x1, x4, loop    // x4 = end pointer

Simple Pipeline Scheduling

loop: fld    f0, 0(x2)
      fld    f1, 0(x3)
      addi   x3, x3, 8
      addi   x2, x2, 8
      fadd.d f2, f0, f1
      addi   x1, x1, 8
      fsd    f2, -8(x1)
      bne    x1, x4, loop

Loop Unrolling

loop: fld    f0,  0(x2)
      fld    f1,  0(x3)
      fld    f10, 8(x2)
      fld    f11, 8(x3)
      addi   x3, x3, 16
      addi   x2, x2, 16
      fadd.d f2,  f0,  f1
      fadd.d f12, f10, f11
      addi   x1, x1, 16
      fsd    f2, -16(x1)
      fsd    f12, -8(x1)
      bne    x1, x4, loop
  • Two iterations per pass, distinct registers
  • Halves loop overhead (addi, bne)
  • Spaces out fld → fadd.d → fsd chains
  • Limits:
    • Number of architectural registers
    • Larger I-cache footprint
    • Pointer-aliasing analysis (A, B, C don't overlap)
    • Can't hide unpredictable cache misses

Check Your Understanding

1. Pipeline delay: on the R4000, why is load-use delay 2 cycles rather than 3 even though TC doesn't finish until cycle 7?
The direct-mapped data cache lets data from DS (cycle 6) bypass speculatively into the consumer's EX in cycle 7, before TC finishes.
2. Code check: scheduling addi x1, x1, 8 before the store changed fsd f2, 0(x1) to fsd f2, -8(x1). Why?
addi already advanced x1 by 8 bytes, so -8(x1) points back at the current A[i].

CDC 6600 (Seymour Cray, 1964)

CDC 6600: A Load/Store Architecture

CDC 6600 Vector Add

InstructionEffect
A0 ← B0 + a0triggers load of X0 (element of a)
A1 ← B0 + b0triggers load of X1 (element of b)
X6 ← X0 + X1FP add
A6 ← B0 + c0triggers store of X6 (element of c)

Issues in Complex Pipeline Control

Frontendfetch/decode Instructionpool dispatch ALU Mem Fadd Fmul Fdiv issue WB
  1. Structural conflicts at execute: unpipelined units busy for many cycles
  2. Structural conflicts at the WB port when fast and slow units finish together
  3. Out-of-order writes (WAW, WAR) when a fast young op overtakes a slow old one
  4. Imprecise exceptions when younger ops finish before older ones fault

CDC 6600 Scoreboard

More Complex In-Order Pipeline

In-Order Superscalar Pipeline

Check Your Understanding

1. Scoreboard rules: which two data hazards block issue from the CDC 6600 scoreboard, and how is WAR handled?
RAW and WAW (plus structural) block issue. WAR ops issue and execute, then stall before writeback until the older reader finishes.
2. Design check: integer ALU, FAdd, and FMul all wait until X3 to reach W. Why don't consecutive integer instructions stall 2 cycles?
The integer result is bypassed from the end of X1 straight into the next instruction's X1 input, without waiting for W.

Decoupled Execution: The Observation

loop: fld    f0, 0(x2)     // control/address
      fld    f1, 0(x3)     // control/address
      fadd.d f2, f0, f1    // data computation
      fsd    f2, 0(x1)     // address + data
      addi   x1, x1, 8     // control/address
      addi   x2, x2, 8     // control/address
      addi   x3, x3, 8     // control/address
      bne    x1, x4, loop  // control/address
None of the control or address instructions depend on the FP data computation.

Simple Decoupled Machine

Integer pipeline (runs ahead) FDXMW µOp Queue Memory load addr Store Address Queue store addr (loads checked against pending stores) Load Data Queue FP pipeline (own pace) RX1X2X3W Store Data Queue pair data + address → memory

The integer side runs several iterations ahead; many writes to f0 can be in flight, ordered by the FIFOs (no WAW/WAR corruption).

Decoupled Machine: Roles

  1. Integer pipeline (F D X M W): runs addi/bne, computes load addresses, checks each against the Store Address Queue, sends loads to memory, pushes FP µops (load writeback, compute, store data read) into the µOp Queue
  2. Memory returns loaded words in order into the Load Data Queue
  3. FP pipeline (R X1 X2 X3 W): pulls µops and load data, computes fadd.d, pushes results into the Store Data Queue to pair with waiting store addresses

Dynamic ALU Scheduling (MC68060)

EA (effective address) → MEM (data cache) → ALU

MC68060 Example: Zero Stalls

Instruction123456
add x1, x1, 24(x2)EA: x2+24MEMALU: x1+M
add x3, x1, x6EA (pass)MEM (pass)ALU: x1+x6
addi x5, x2, 12EA: x2+12
lw x4, 16(x5)EA: x5+16MEM
lw x8, 16(x3)EA: x3+16MEM

Check Your Understanding

1. Queue safety: why must every load address from the integer pipeline be checked against the Store Address Queue?
The integer side runs ahead while older store data may still be queued; a matching address must forward or wait, or the load reads stale memory.
2. Stage assignment: in EA → MEM → ALU, why does addi x5, x2, 12 (followed by lw x4, 16(x5)) execute in EA rather than ALU?
Running in EA produces x5 two cycles earlier, so it bypasses straight into the next lw's EA stage with no stall.