lw instruction does not have data until end of CC4 and the and instruction wants data at beginning of CC4, which is NOT possible.
Hence, this combination must result in a stall by the hazard detection unit.
| The hazard detection unit operates during the ID stage so that it can insert the stall between the load and its use. |
|
if ( (ID/EX.MemRead == 1) and (ID/EX.Rw ≠ 0) and
( (ID/EX.Rw == IF/ID.Rs) or (ID/EX.Rw == IF/ID.Rt) ) )
Stall
Once a hazard is detected, freeze the PC and the IF/ID registers.
No new instruction is fetched and instruction after load is stalled by one cycle by inserting a bubble into the ID/EX register.
| The load instruction in ID/EX register is allowed to proceed. It then forwards data to next instruction after delaying it. |
|
|
Shit I’ve survived: Mad Cow Disease ✓ HIV Aids ✓ Sars ✓ Bird Flu ✓ Swine Flu ✓ Ebola ✓ Coronavirus (pending) |