Pipeline Hazards in Pipelining: Definitions and Types

Pipeline Hazards in Pipelining: Definitions and Types

Verified Sources
Nov 4, 2026

In pipelined processors, multiple instructions overlap in time by using different hardware stages (e.g., fetch, decode, execute, memory, writeback). A pipeline improves throughput but introduces hazards—events where the pipeline cannot proceed “as if” each instruction had completed before the next one started. The result is typically a stall (bubble), flush, or re-routing of control flow.

Pipeline hazards are commonly classified into three types:

  1. Structural hazards
  2. Data hazards
  3. Control hazards

A useful mental model is: each pipeline stage expects specific inputs at a cycle boundary; hazards violate that assumption, forcing the control logic to intervene.

Pipeline Hazards (Structural, Data, Control) — Overview

Key terms you’ll use repeatedly

  • stall
  • forwarding
  • flush
  • branch prediction
  • bubble

Structural: resource conflicts
Data: operand/result timing dependencies
Control: branch/jump timing uncertainty

1) Structural Hazards (Resource Conflicts)

A structural hazard occurs when the pipeline needs a hardware component for multiple stages in the same cycle, but the component is not available in the needed number or configuration.

Example pattern (conceptual):

  • Stage for instruction IkI_k needs the ALU
  • Stage for instruction Ik+1I_{k+1} also needs the same ALU in the same cycle
  • If the design offers only one ALU instead of two, one stage must wait → stall.

How to reason about it:

  • Structural hazards are about hardware capability, not about data timing or branch outcomes.
  • If you resolve it by adding hardware (e.g., separate instruction and data memories in a Harvard design), the hazard disappears.

Key pipeline technique

Important: Structural hazards occur mainly in simpler designs; modern “classic” pipeline teaching models often assume enough resources so the main focus is data/control hazards.

2) Data Hazards (Operand Timing Dependencies)

A data hazard occurs when an instruction requires a value that is produced by an earlier instruction but has not yet reached the stage where it can be used.

Data hazards are the most studied because they directly affect the correctness and performance of pipelined execution.

2.1 Read After Write (RAW)

The most common data hazard is RAW (Read After Write).

Conceptual example:

  • Instruction I1I_1 computes register R1R1
  • Instruction I2I_2 needs R1R1 as an ALU input immediately
  • If I2I_2 reaches Execute before I1I_1 has produced/written the value, I2I_2 uses stale data.

This is the typical cause of load-use stalls and the key target for forwarding.

2.2 Forwarding vs Stalling

A forwarding path can reduce stalls by supplying the needed value directly from an intermediate pipeline stage.

When forwarding cannot fully resolve the dependency (e.g., a load value may not be available early enough), the pipeline inserts a stall (bubble).

2.3 Write After Read (WAR) and Write After Write (WAW)

Classic in-order pipelines typically do not produce WAR/WAW hazards in the same way because:

  • Instructions advance in order through stages (no out-of-order completion)
  • Writes occur at a consistent stage timing

However, these hazards become relevant in out-of-order designs with register renaming, where the pipeline may allow reordering of completion/writeback.

For an in-order pipeline, focus primarily on RAW.

3) Control Hazards (Uncertainty in Branch/Jump)

A control hazard happens because the processor does not immediately know:

  • whether a branch is taken or not taken
  • the target address (especially for indirect jumps)
  • therefore which instructions are on the correct path

While the pipeline speculatively fetches the next instructions, some may be wrong once the branch outcome is resolved—these must be handled via stalling and/or flushing.

Common causes

  • Branch condition evaluation happens in a later stage than Fetch/Decode.
  • Target computation may also be delayed.

Mitigation strategies

  1. Branch prediction: continue fetching based on the guess
  2. Flush when the guess is wrong
  3. Delayed branching (historic/simple approach in some designs)

How pipeline hazard handling usually works (end-to-end)

  1. 1
    Step 1

    The hazard detection logic compares source/destination registers (for data hazards) or evaluates branch status timing (for control hazards) against the pipeline’s current stage occupancy.

  2. 2
    Step 2

    If a needed value will be available soon, use forwarding. If not, insert a stall. If control flow was mispredicted, flush.

  3. 3
    Step 3

    Stalls hold instructions in place (or prevent advancement), flush clears wrong-path stages, and forwarding updates operand paths so consumers receive correct values.

  4. 4
    Step 4

    After dependencies are satisfied or the control flow is confirmed, the pipeline continues fetching/executing with minimal interruption.

Pro Tip: RAW is the dominant data hazard

In an in-order pipelined CPU, the critical correctness hazard is almost always RAW (Read After Write). Design forwarding/stall policies around RAW first.

Control hazards can silently corrupt results if mishandled

If you fetch down the wrong path and do not flush (or stall until resolved), you may commit incorrect architectural state.

Visual summary: when each hazard happens

Remedy mapping: hazard type → common pipeline action

A qualitative guide (not a performance benchmark).

Typical pipeline evolution in handling hazards

Split into stages

Early concepts

Pipeline increases throughput but introduces overlap timing issues."

Detect data/control dependencies

Add hazard detection

Compare register dependencies for RAW and check branch resolution timing."

Forwarding + prediction

Improve performance

Forward results early and predict branch direction/targets."

Flush and recover

Make it robust

Correct the pipeline state when mispredictions or unresolved dependencies occur."

Common edge cases and clarifications

Pipeline Hazards Quick Deck

1 / 5
Question · Term

Structural hazard

Click to reveal
Answer · Definition

A conflict for a required hardware resource when multiple pipeline stages need the same component.

Knowledge Check

Question 1 of 4
Q1Single choice

Which hazard occurs when two pipeline stages need the same hardware resource in the same cycle?