The scoreboard is a hardware mechanism used in dynamic instruction scheduling to manage dependencies and resource conflicts, enabling out-of-order execution while maintaining correctness. It was first implemented in the CDC 6600 supercomputer and remains a foundational concept in modern CPU design.
Key Concept
The scoreboard acts as a centralized tracking system that monitors:
- Data dependencies (e.g., read-after-write, write-after-write).
- Resource availability (e.g., functional units, registers).
It dynamically determines when instructions can proceed through the pipeline, issuing them as soon as their operands and resources are ready.
How It Works
-
Instruction Issue:
- Instructions are fetched and decoded.
- The scoreboard checks for structural hazards (e.g., busy functional units) and data hazards (e.g., unavailable operands).
-
Dependency Tracking:
- For each instruction, the scoreboard records:
- Destination register (where the result will be written).
- Source registers (operands needed for execution).
- It compares these against registers being written by other in-flight instructions.
-
Stalling or Issuing:
- If dependencies or resource conflicts exist, the instruction is stalled (delayed).
- Once dependencies resolve and resources free up, the instruction proceeds.
Example Scenario
Consider the following instructions in a pipeline:
I1: ADD R1, R2, R3 ; R1 = R2 + R3 (takes multiple cycles)
I2: SUB R4, R1, R5 ; R4 = R1 - R5 (depends on R1)
Without a Scoreboard:
- I2 would stall in the decode stage until I1 completes, creating a pipeline bubble.
With a Scoreboard:
-
Cycle 1:
- I1 is fetched and decoded. The scoreboard notes that
R1 will be written by I1.
- I1 proceeds to the execute stage.
-
Cycle 2:
- I2 is fetched and decoded. The scoreboard checks if
R1 (a source for I2) is available.
- Since I1 is still executing,
R1 is not ready. The scoreboard stalls I2.
-
Cycle 5:
- I1 completes and writes
R1.
- The scoreboard updates
R1 as available.
-
Cycle 6:
- I2 is now allowed to proceed to the execute stage.
Advantages
- Out-of-order execution: Instructions independent of each other can proceed in parallel.
- Efficiency: Reduces pipeline stalls compared to static scheduling.
- Flexibility: Adapts to runtime dependencies dynamically.
Limitations
- Centralized control: The scoreboard can become a bottleneck in complex pipelines.
- No register renaming: Unlike Tomasulo’s algorithm, it does not handle write-after-write hazards by renaming registers.
Summary
The scoreboard is a hardware table that tracks instruction dependencies and resource availability. By dynamically allowing instructions to proceed only when their operands and resources are ready, it maximizes instruction-level parallelism while avoiding hazards. This approach balances complexity and efficiency, making it a cornerstone of early superscalar processors.