2081 1

CSC213 · 2081 · 10 marks

What is pipelining? Explain pipelining using 4-segment instruction cycle. What are its advantages?

What is pipelining? Explain pipelining using 4-segment instruction cycle. What are its advantages?[10]

Computer ArchitectureChapter 6: PipeliningInstruction Level Pipelining

Quick answer

Pipelining is a technique used in computer architecture to improve CPU performance by overlapping the execution of multiple instructions. Instead of waiting for one instruction to complete all its phases before starting the next, the CPU divides instruction execution into a series of stages (segments), and different instructions occupy different stages simultaneously.

Pipelining: 4-Segment Instruction Cycle and Advantages

1. What is Pipelining?

It works like an assembly line in a factory: while one instruction is being executed, the next instruction is being decoded, and the one after that is being fetched, all at the same time.

Pipelining is easy in RISC architecture because instructions are simple and take a single cycle to execute.


2. Pipelining Using a 4-Segment Instruction Cycle

The instruction cycle is divided into 4 segments (stages):

SegmentStageOperation
S1Fetch (FI)Fetch the instruction from memory using PC
S2Decode (DI)Decode the opcode and determine instruction type
S3Execute (EI)Perform the operation (ALU, memory access, etc.)
S4Write Back (WB)Store the result back to register/memory

2.1 Micro-operations at Each Stage

Stage S1: Fetch

T0: AR <- PC
T1: IR <- M[AR], PC <- PC + 1

Stage S2: Decode

T2: Decode IR(12-14), AR <- IR(0-11), I <- IR(15)
    Determine instruction type (memory-reference, register, or I/O)

Stage S3: Execute

T3: Execute the instruction based on decoded opcode
    (ALU operation, memory read/write, I/O operation)

Stage S4: Write Back

T4: Write result to destination register or memory location
    SC <- 0 (reset sequence counter for next instruction)

2.2 Pipeline Timing Diagram

Without pipelining (sequential execution), each instruction takes 4 clock cycles. With pipelining, instructions overlap:

Clock Cycle:   1    2    3    4    5    6    7
               |    |    |    |    |    |    |
Instruction 1: FI   DI   EI   WB
Instruction 2:      FI   DI   EI   WB
Instruction 3:           FI   DI   EI   WB
Instruction 4:                FI   DI   EI   WB
  • Without pipeline: 4 instructions x 4 cycles = 16 clock cycles
  • With pipeline: 4 + (4-1) = 7 clock cycles

2.3 General Formula for Pipeline Execution Time

For a k-segment pipeline executing n tasks with clock cycle time t_p:

$$\text{Total Time} = [k + (n-1)] \times t_p$$

For our 4-segment pipeline (k = 4):

$$\text{Total Time} = [4 + (n-1)] \times t_p$$

Example: Execute 6 instructions (n = 6) with k = 4 segments:

$$\text{Total Time} = [4 + (6-1)] \times t_p = 9 \times t_p$$

Without pipelining: $$\text{Total Time} = n \times k \times t_p = 6 \times 4 \times t_p = 24 \times t_p$$

Speedup = 24 / 9 = 2.67x


2.4 Instruction Queue (FIFO Execution)

The instruction pipeline execution works like a queue using average execution (FIFO technique). When an instruction first arrives, it is placed in the queue and executed in the system, and the result is passed on to the next instruction in the queue.

This means:

  • Instructions enter the pipeline in order (FIFO)
  • Each instruction moves through S1 -> S2 -> S3 -> S4 sequentially
  • Multiple instructions are in different stages at the same time

3. Advantages of Pipelining

#AdvantageExplanation
1Increased ThroughputMore instructions are completed per unit time since multiple instructions execute simultaneously
2Better CPU UtilizationAll pipeline stages are kept busy, reducing idle time of CPU components
3Faster ExecutionOverall execution time for a large number of instructions is significantly reduced
4Cost EffectiveHigher performance is achieved without increasing the clock speed or adding more hardware
5Supports RISC ArchitectureSimple, uniform instructions in RISC make pipelining very efficient and easy to implement
6ScalabilityMore pipeline stages (deeper pipeline) can be added to further improve performance

4. Summary

FeatureWithout PipelineWith Pipeline
Execution styleSequentialOverlapped
Time for n instructionsn x k x t_p[k + (n-1)] x t_p
CPU utilizationLowHigh
ThroughputLowHigh

Pipelining is one of the most fundamental techniques in modern processor design. By dividing the instruction cycle into 4 segments (Fetch, Decode, Execute, Write Back) and overlapping their execution using a FIFO queue mechanism, the CPU achieves significantly higher performance without requiring faster hardware.

Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.