Sitemap
Jagan m

Jagan m

Pipeline Architecture

4 min readApr 1, 2025

Introduction:
Pipeline Architecture in computer architecture refers to the method of
breaking down the execution of instructions into discrete stages, where
different parts of the system can work on different stages of multiple
instructions simultaneously. This concept allows for greater throughput
and more efficient use of the CPU, essentially improving its
performance.

Press enter or click to view image in full size

Key Concepts of Pipeline Architecture:
1. Pipeline Stages: In a pipeline, an instruction is divided into
several stages, with each stage performing a specific function. A
common pipeline might consist of five stages:
o IF (Instruction Fetch): The instruction is fetched from
memory.
o ID (Instruction Decode): The instruction is decoded to

3
understand what operation it requires and which operands
are needed.
o EX (Execution): The operation is performed, often involving
the Arithmetic Logic Unit (ALU) for computation.
o MEM (Memory Access): If the instruction requires memory
(e.g., load/store), the memory is accessed.
o WB (Write Back): The result is written back to the register
file or memory.

2. Pipelining Efficiency: Each stage of the pipeline can work on a
different instruction at the same time. For example, while one
instruction is being decoded, another can be fetched, and
another can be executed, creating a continuous flow of
instructions. This overlap leads to higher instruction throughput
and improves overall processor performance.
3. Throughput vs. Latency:
o Throughput refers to how many instructions the processor
can handle per unit of time.

o Latency refers to how long it takes to complete a single
instruction.

Pipelining increases throughput but does not necessarily reduce the

3
latency of a single instruction (since each instruction still has to go
through all the stages).
4. Pipeline Hazards: There are situations where the pipeline can be
stalled or produce incorrect results. These are called hazards,
and they can be categorized into:
o Data Hazards: These occur when instructions that are close
together in the pipeline need the same data, causing
conflicts. For example:
 Read-after-write hazard (RAW): The next instruction
needs data that hasn't been written back yet.
 Write-after-read hazard (WAR): An instruction writes
to a register that is being read by another.
 Write-after-write hazard (WAW): Two instructions
write to the same register.

Get Jagan m’s stories in your inbox

Join Medium for free to get updates from this writer.

o Control Hazards: These arise due to branch instructions
(conditional jumps), as it’s unclear where to fetch the next
instruction until the branch decision is made.
o Structural Hazards: These occur when hardware resources
are insufficient for the simultaneous execution of multiple
instructions. For example, if there’s only one memory unit
but multiple instructions require it at the same time, a
conflict arises.

5. Techniques to Handle Hazards:
o Stalling: The pipeline can be stalled (paused) until the
hazard is resolved, which prevents incorrect results.
o Forwarding (Data forwarding): Data is passed directly from
one pipeline stage to another to avoid waiting for data to
be written back.
o Branch Prediction: This technique is used to guess the
outcome of branches before the actual condition is
evaluated to keep the pipeline full.
o Pipeline Interlocks: Hardware mechanisms to detect and
handle hazards automatically.

6. Pipeline Depth:
o The number of stages in a pipeline is referred to as its
depth. A deeper pipeline means more stages, potentially

3
increasing the processor’s performance (since it can
execute more instructions in parallel), but it also increases
the complexity of handling hazards and delays.
o Modern processors can have pipelines with tens of stages,
such as in superscalar architectures.

7. Superscalar Pipelines: These are pipelines that can handle
multiple instructions at each stage. Instead of processing one
instruction per cycle, a superscalar processor might fetch,
decode, and execute several instructions in parallel. This requires
more complex hardware but allows for greater performance
improvements.
8. Pipeline Speedup:
o Ideally, pipelining can offer a speedup factor of nearly the
number of stages in the pipeline. However, due to hazards
and inefficiencies, the actual speedup is often less than the
ideal.

Press enter or click to view image in full size

o Law describes the potential speedup of a system
due to parallelism (like pipelining). It highlights that the
maximum speedup achievable by pipelining is limited by the
fraction of the program that cannot be pipelined.
Example: 5-Stage Pipeline in a MIPS
Processor
A common example of a pipeline is the MIPS processor, which divides
instruction processing into five stages:
1. IF (Instruction Fetch): Fetch the instruction from memory.
2. ID (Instruction Decode): Decode the instruction and read
registers.
3. EX (Execution): Execute the instruction using the ALU
(Arithmetic Logic Unit).
4. MEM (Memory Access): Access memory if needed (e.g., for
load/store operations).
5. WB (Write Back): Write the result back to the register.
Each of these stages can operate on a different instruction

3
simultaneously. For instance, while instruction 1 is in the execution
stage, instruction 2 could be in the decode stage, and instruction 3
could be in the fetch stage.

Press enter or click to view image in full size

Conclusion:
Pipeline architecture is a fundamental technique in modern CPUs,
enabling high throughput and efficient processing by overlapping the
execution of multiple instructions. However, it requires careful
management of hazards and dependencies, and techniques like
forwarding, stalling, and branch prediction are essential for maximizing
the benefits of pipelining.

--

--