You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
Pipelining is a technique that allows multiple instructions to be in different stages of execution simultaneously, significantly increasing the throughput of a processor. It is one of the most important A-Level topics in computer architecture.
Without pipelining, the processor completes one full FDE cycle before starting the next:
Instruction 1: [Fetch] [Decode] [Execute]
Instruction 2: [Fetch] [Decode] [Execute]
Instruction 3: [Fetch] [Decode] [Execute]
With pipelining, the stages overlap:
Clock cycle: 1 2 3 4 5
Instruction 1: [Fetch] [Decode] [Execute]
Instruction 2: [Fetch] [Decode] [Execute]
Instruction 3: [Fetch] [Decode] [Execute]
After the pipeline is full (cycle 3 onwards), one instruction completes every clock cycle, even though each individual instruction still takes three cycles.
| Without Pipelining | With Pipelining (3-stage) |
|---|---|
| 3 instructions in 9 cycles | 3 instructions in 5 cycles |
| Throughput: 1 instruction every 3 cycles | Throughput: 1 instruction every cycle (once the pipeline is full) |
For an n-stage pipeline executing k instructions:
The deeper the pipeline (more stages), the greater the potential speedup — but also the greater the penalty when things go wrong.
Real processors have many more than three stages. A typical modern pipeline might include:
Some processors (e.g. Intel Pentium 4 NetBurst) had pipelines of 20 or even 31 stages.
Pipelining does not always run smoothly. Hazards are situations that prevent the next instruction from executing in the next clock cycle, causing stalls (bubbles) in the pipeline.
A data hazard occurs when an instruction depends on the result of a previous instruction that has not yet completed.
ADD R1, R2, R3 ; R1 = R2 + R3
SUB R4, R1, R5 ; R4 = R1 - R5 ← needs the new value of R1, which may not be written back yet
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.