Background
Laundry Example
RISC Pipelines
Pipelining Hazards
Examples
© 2004
|
|
Pipelining Hazards
Control Hazards
Control hazards can cause a greater performance loss
for DLX pipeline than data hazards. When a branch is executed, it may
or may not change the PC (program counter) to something other than its
current value plus 4. If a branch changes the PC to its target address, it
is a taken branch; if it falls through, it is not taken.
There are many methods to deal with the pipeline
stalls caused by branch delay. We discuss four simple compile-time schemes
in which predictions are static - they are fixed for each branch during the
entire execution, and the predictions are compile-time guesses.
- Stall pipeline - The simplest scheme to
handle branches is to freeze or flush the pipeline, holding or deleting
any instructions after the branch until the branch destination is known.
Advantage: simple both to software and hardware
- Predict taken - An alternative scheme is
to predict the branch as taken. As soon as the branch is decoded and the
target address is computed, we assume the branch to be taken and begin
fetching and executing at the target address.
- Predict not taken - A higher performance,
and only slightly more complex, scheme is to predict the branch as not
taken, simply allowing the hardware to continue as if the branch were not
executed. Care must be taken not to change the machine state until the
branch outcome is definitely known.
- Delayed Branch - The execution cycle with
a branch delay of one is:
- branch instruction
- sequential successor
- branch target if take
←BACK
Structural Hazards
NEXT Data Hazards
→ |