Back to the 2016 paper

Module 3: Pipelining

201614m

What is meant by pipelining? Why do we require instruction pipelining? Explain its working procedure. Discuss the pipeline performance measures.

Worked SolutionAI Assisted

Pipelining

1. Definition

Pipelining is an implementation technique where multiple instructions are overlapped in execution, analogous to an assembly line. Each instruction is split into kk sequential stages; different stages of successive instructions execute concurrently using separate hardware resources.

Ideally kk-stage pipeline can execute kk instructions simultaneously and achieve speedup ≈k\approx k.

2. Why Require Instruction Pipelining?

  • Performance without increasing clock rate: Single-cycle CPU has long critical path (IF+ID+EX+MEM+WB). Pipelining breaks it into shorter stages -> higher clock frequency and throughput.
  • Exploit Instruction-Level Parallelism (ILP): Sequential model wastes hardware when one unit is active, others idle. Pipelining keeps all units busy.
  • CPI approaches 1: Without pipeline CPI = 1 (single-cycle) but long TclkT_{clk} or CPI >1 (multi-cycle). With pipeline, throughput = 1 instruction/cycle in steady state.
  • Cost-effective speedup: No need for multiple CPUs; just pipeline registers.

3. Working Procedure (5-stage Classic RISC Pipeline)

Stages:

  1. IF - Instruction Fetch: IR <- M[PC]; PC <- PC+4
  2. ID - Instruction Decode/Register Fetch: decode opcode, read Rs,RtRs,Rt, generate immediates.
  3. EX - Execute/ALU: ALU operation or effective address ALUout <- Rs op Rt or Rs + imm
  4. MEM - Memory Access: MDR <- M[ALUout] for LOAD or M[ALUout] <- Rt for STORE
  5. WB - Write Back: Rd <- ALUout or Rd <- MDR

Pipeline registers between stages: IF/ID, ID/EX, EX/MEM, MEM/WB isolate stages.

Timing diagram (no hazards, 5 instructions):

Cycle:  1    2    3    4    5    6    7    8
I1:    IF | ID | EX | MEM| WB |
I2:         IF | ID | EX | MEM| WB |
I3:              IF | ID | EX | MEM| WB |
I4:                   IF | ID | EX | MEM| WB |
I5:                        IF | ID | EX | MEM| WB |

After 5 cycles (fill), one instruction completes per cycle.

Non-pipelined: 5 cycles per instruction sequentially -> 25 cycles for 5 instr. Pipelined: 9 cycles.

Hazards (practical issues)

  • Structural: two instr need same resource (e.g., single memory for IF and MEM) - solve by separate I/D caches.
  • Data hazard: I2 needs result of I1 (RAW) - forward/bypass or stall (bubble).
  • Control hazard: branch target unknown until ID/EX - flush pipeline, branch prediction.

4. Pipeline Performance Measures

Let kk = stages, tpt_p = time per stage, tlatcht_{latch} = latch overhead, nn = number of instructions.

  • Clock period: Tclk,pipelined=max⁡(ti)+tlatchT_{clk,pipelined}= \max(t_i) + t_{latch} vs Tclk,non−piped=∑tiT_{clk,non-piped}= \sum t_i

  • Time for n instructions:
    Tnon−pipe=n⋅k⋅tpT_{non-pipe}= n \cdot k \cdot t_p
    Tpipe=k⋅tp+(n−1)⋅tp=(k+n−1)tpT_{pipe}= k\cdot t_p + (n-1)\cdot t_p = (k+n-1)t_p (ideal)

  • Speedup: S=Tnon−pipeTpipe=nkk+n−1S = \frac{T_{non-pipe}}{T_{pipe}} = \frac{n k}{k+n-1}. For n≫kn \gg k, S→kS \to k (ideal).
    With overhead: S=ktptp+tlatch⋅nn+k−1S = \frac{k t_p}{t_p + t_{latch}} \cdot \frac{n}{n+k-1}

  • Efficiency: η=Sk=nk+n−1\eta = \frac{S}{k} = \frac{n}{k+n-1} . For large nn, η→1\eta \to 1.

  • Throughput: W=nTpipe=1tpW = \frac{n}{T_{pipe}} = \frac{1}{t_p} instr/sec in steady state (vs 1ktp\frac{1}{k t_p} non-piped). n/(k+n−1)tpn/(k+n-1)t_p.

  • CPI: Ideal CPI = 1, effective CPI = 1+stalls/instr1 + stalls/instr (due to hazards).

  • Example: k=5k=5, tp=2nst_p=2ns, n=100n=100: Tnon=1000nsT_{non}=1000ns, Tpipe=(5+99)∗2=208nsT_{pipe}= (5+99)*2=208ns, S=4.8S=4.8, η=96%\eta=96\%.

Pipeline improves throughput, not single-instruction latency (latency stays ktpk t_p). Maximum speedup limited by stage imbalance, latches, and hazards.

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.