Similar questions 2 more →
Pipelining & Hazards


Shared context
Five stages IF, ID, EX, MEM, WB; reads occur in second half of cycle, writes in first half. I1: sub r2,r3,r4; I2: sub r4,r2,r3; I3: sw r2,100(r1); I4: sub r3,r4,r2.
Answer & solution
Answer: Yes, with normal ALU forwarding and a forwarding path for the store data; no load-use stall is present. (no official key was published)
1. I1 computes its r2 result at the end of EX in cycle 3. I2 needs that value at EX in cycle 4, so forwarding from I1’s EX/MEM register to I2’s ALU input resolves the nearest RAW hazard.
2. I3 may have read a stale r2 during ID4, but its store value can be corrected by forwarding the I1 result from MEM/WB during I3’s EX5 into the store-data path. That corrected value is carried to MEM6 for the write. An equivalent appropriately staged store-data bypass also works.
3. I2 computes r4 at the end of EX4. I4 needs it during EX6; the value can be forwarded from I2’s MEM/WB register to I4’s ALU input. I4’s r2 operand is already correct from the same-cycle WB5/ID5 timing.
4. All producer results are available before their consumer execution or memory-use stages, so no bubble is required with these bypasses. None of the instructions is a load producing a value too late for an immediately following EX stage.
5. The qualification matters: an implementation forwarding only ALU inputs but not correcting the store-data path would not resolve I3’s stale store value. The yes answer assumes forwarding includes the needed store-data path, not an unspecified restricted implementation.