Operand forwarding
![]() | This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these messages)
No issues specified. Please specify issues, or remove this template. |
Operand forwarding is an optimization in pipelined CPUs to limit performance deficits which occur due to Pipeline stalls. A data hazard can lead to a Pipeline stall when the current operation has to wait for the results of an earlier operation which has not yet finished.
Example
ADD A B C #A=B+C SUB D C A #D=C-A
If these two assembly pseudocode instructions run in a pipeline, after fetching and decoding the second instruction, the pipeline stalls, waiting until the result of the addition is written and read.
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
---|---|---|---|---|---|---|---|
Fetch ADD | Decode ADD | Read Operands ADD | Execute ADD | Write result | |||
Fetch SUB | Decode SUB | Read Operands SUB | Execute SUB | Write result |
1 | 2 | 3 | 4 | 5 | 6 |
---|---|---|---|---|---|
Fetch ADD | Decode ADD | Read Operands ADD | Execute ADD | Write result | |
Fetch SUB | Decode SUB | Read Operands SUB: use result from previous operation | Execute SUB | Write result |
Technical realization
The CPU control unit must implement logic to detect dependencies where operand forwarding makes sense. A multiplexer can then be used to select the proper register[disambiguation needed] or Flip Flop to read the operand from.
External links