More Notes About Pipeline Forwarding

Load Instructions

What do loads do in the MIPS pipeline?

Instruction
Fetch (IF)
___ Instruction
Decode (ID)
___ Execute
(EX)
___ Memory
(MEM)
___ Write Back
(WB)

Loads produce "new" values at the MEM stage. The MEM/WB -> EX forwarding only handles instructions which have distance 2 e.g. a load followed by an independent instruction and then an instruction dependent on the load. If there is a dependent instruction following a load, the pipeline must stall for one cycle. The effect is to force the dependent instruction to wait until the forwarded value is ready. See the figure on page 491 of the textbook.

Loads followed by a dependent store are a special case. If the destination of load is the register the store instruction is writing to memory, then an extra forwarding path MEM/WB -> MEM will eliminate the hazard. See page 488 of the textbook for more details.

Branch and Jump Instructions

Note that what you have to do for homework 6 is different to the textbook. The PC is updated in the EX stage rather than the MEM stage. This means the branch delay is two instructions rather than three instructions. What this means is that to answer questions about pipelines, you will have to read the pipeline specifications carefully.

Since the decision to take or not take the branch is not resolved until the EX stage, the pipeline has to stall two cycles. The delayed branch strategy always executes the instructions following the branch, so NOPs must be inserted by the compiler or the programmer if there are no available instructions to be executed.

For jump register instructions, the branch target is already known by the end of the ID stage but we treat these instructions the same way as other branches. This makes implementation easier.

It is possible to move the branch direction resolution to the ID stage. To gain one less cycle in branch latency, the target address must also be calculated in the same stage.


CSE 378 Spring 2002 - Section 8
First Previous Page 1 Next Last