Course contentsShow
← Embedded Systems & Computer Architecture
Lesson 122 of 9362. Instruction Set Architecture and CPU MicroarchitectureFree lesson

Identifying Structural Hazards in Resource Contention

Detect hardware resource conflicts that occur when two instructions require the same functional unit simultaneously during a single cycle.

Identifying Structural Hazards in Resource Contention

In this lesson, you will learn how to identify structural hazards that occur when multiple instructions fight over the same piece of hardware at the same time.

What is a Structural Hazard?

Up until now, we have assumed our processor has infinite hardware—that every unit (like the ALU or Memory) is available whenever an instruction needs it. In a real pipelined processor, however, hardware is finite. A structural hazard occurs when the hardware design cannot support all possible combinations of instructions that the pipeline is trying to execute simultaneously. Simply put, it is a "resource collision."

A Concrete Illustration

Imagine a simple five-stage pipeline (Fetch, Decode, Execute, Memory, Write-back). In an ideal world, each stage handles one piece of the instruction process. But what happens if your processor design only has one memory port?

Look at this sequence of events in a single clock cycle:

  1. Instruction A is in the Memory stage, trying to read data from RAM.
  2. Instruction B is in the Fetch stage, trying to pull the next instruction from RAM.
Cycle 10:
Stage:   [ Fetch ] [ Decode ] [ Execute ] [ Memory ] [ Write-back ]
Unit:    [  RAM  ] [  ---   ] [   ALU   ] [  RAM   ] [  Register  ]
Task:      Fetch B                         Access A

Because both Instruction A and Instruction B need to access the RAM at the exact same time, the hardware experiences a structural hazard. The CPU cannot satisfy both requests. One instruction must proceed, and the other must "stall" (wait), effectively creating a bubble in our pipeline and wasting a clock cycle.

How to Spot Them

To identify these hazards, look for shared hardware resources. Common culprits include:

  • Memory Ports: Having a single port for both instructions and data.
  • ALU Constraints: If an operation takes multiple cycles but the hardware doesn't allow another instruction to enter the pipeline.
  • Register File Ports: Having fewer write ports than instructions that need to commit results simultaneously.

When you see two instructions requiring the same physical resource during the same clock cycle, you have found a structural hazard.

Key Takeaway: A structural hazard is a hardware-level traffic jam that occurs when the physical design lacks the resources to execute multiple simultaneous instructions.