Back to the 2025 paper

Module 3: Pipelining

20257m

Explain the basic concepts of pipelining, including speedup and throughput. Discuss pipeline hazards.

Worked SolutionAI Assisted

Pipelining - Basic Concepts

Pipelining is an implementation technique where multiple instructions are overlapped in execution, like an assembly line. An kk-stage pipeline divides instruction execution into kk stages (classic RISC: IF-ID-EX-MEM-WB) operating concurrently.

Basic Operation

Each stage has combinational logic + pipeline register/latch. Clock period Tp=max⁡(Tstage)+TlatchT_p = \max(T_{stage}) + T_{latch}. While stage ii processes instruction nn, stage i−1i-1 processes n+1n+1.

For k=4k=4, nn instructions: non-pipelined time =n⋅k⋅Tp= n\cdot k\cdot T_p, pipelined time =(k+n−1)Tp= (k+n-1)T_p.

Speedup

S=Tnon−pipeTpipe=n⋅kk+n−1→n≫kk S = \frac{T_{non-pipe}}{T_{pipe}} = \frac{n\cdot k}{k+n-1} \xrightarrow{n\gg k} k
Ideal speedup = number of stages. With stage imbalance and latch overhead: S=k⋅TseqTpS = \frac{k\cdot T_{seq}}{T_p}.

Example k=5k=5, n=100n=100: S=500/104≈4.8S = 500/104 \approx 4.8.

Efficiency η=S/k\eta = S/k, Throughput =n/(k+n−1)Tp→n→∞1/Tp= n/(k+n-1)T_p \xrightarrow{n\to\infty} 1/T_p instructions/sec = fclkf_{clk} (one per cycle).

Throughput

Rate of instruction completion. Non-pipelined: 1/(kTs)1/(kT_s), Pipelined (steady): 1/Tp1/T_p. Improvement factor same as speedup. Supercalar/superpipelined increase further.

Pipeline Hazards - prevent next instruction from executing in next cycle

1. Structural Hazards: Hardware resource conflict (e.g. single memory for IF+MEM, single ALU). Solution: Separate I/D caches (Harvard), duplicate units, stalling (bubble).

2. Data Hazards: Dependency on previous result still in pipe.

  • RAW (true) ADD R1,R2,R3 followed by SUB R4,R1,R5 (R1 not written back)
  • WAR, WAW in out-of-order pipes.
    Solution: Forwarding/bypassing (EX→EX), compiler code scheduling, pipeline interlock + stall, register renaming.

3. Control Hazards: Branch/jump changes PC, next fetched instructions wrong.

  • Unconditional: 1-cycle bubble
  • Conditional: taken/not-taken decision at EX/MEM → flush.
    Solutions: Stall/flush, branch prediction (static: not-taken/backward-taken; dynamic: 2-bit saturating counter, BTB), delayed branch (branch delay slot, predication), speculative execution.

Additional classification Data hazards = load-use: LW R1,0(R2); ADD R3,R1,R4 requires 1 stall even with forwarding (mem latency).

Performance impact: CPIpipe=CPIideal+stallstructural+stalldata+stallcontrolCPI_{pipe}= CPI_{ideal} + stall_{structural}+stall_{data}+stall_{control} ; CPIideal=1CPI_{ideal}=1.

Ideal pipeline CPI=1, real 1.2-1.51.2\text{-}1.5 due to hazards; longer pipe → higher hazard penalty.

Diagram should show 5 stages overlapped in time (Gantt chart) and hazard bubble insertion.

Similar questions

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.