Home › Practice › RTL Design › Forwarding: take the newest value
Forwarding: take the newest value
EasyRTLcombinationalarchitecture
An instruction needs a register that the instruction just ahead of it has computed, but has not yet written back. Waiting would waste cycles, so the processor passes the new value along a shortcut.
Concept first. In a pipeline an instruction may need a register value that an earlier instruction has computed but not yet written to the register file (a data hazard). Forwarding, also called bypassing, routes the value straight from a later stage (Memory or Writeback) into the ALU input. Two stages can hold a newer value for the same register at once. The instruction in the Memory stage is younger than the one in Writeback, so its value is the most recent and wins. In this processor, register 0 always reads zero, so nothing is ever forwarded to it. The unit outputs a 2-bit select for a multiplexer: 00 means use the normal register file value, 01 means take it from Writeback, 10 means take it from Memory.
What to build.
- Inputs:
rs[2:0](the register the instruction wants to read),rd_mem[2:0]andregw_mem(destination of the instruction in Memory, and whether it writes a register),rd_wb[2:0]andregw_wb(the same for Writeback). Output:fwd[1:0]. fwd = 2'b10whenregw_memis 1,rd_memis not 0, andrd_memequalsrs.- Otherwise
fwd = 2'b01when the same three conditions hold for the Writeback stage. - Otherwise
fwd = 2'b00. No clock.
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.