Open changhengliou opened 3 years ago
Stall is a must when there is a dependency for lw
and its next instruction
if (ID/EX.MemRead && // if at execution stage, the instruction is memory read; the only instruction is memRead is lw
((ID/EX.RegisterRt == IF/ID.RegisterRs) ||
(ID/EX.RegisterRt == IF/ID.RegisterRt))
)
stall frontend and insert `NOP` in execution stage
We know branch is happened or not at the execution stage, which means intuitively, we have to stall 3 cycles.
36 sub $10, $4, $8
40 beq $1, $3, 72
44 and $12, $2, $5
72 lw $4, 50($7)
R type pipeline
Hazard: 1:25:30
Structure hazard
Data hazard
Solution:
nop
, ex:sll $0, $0, 0
destination register == source register
Add-Add dependency
Add-Load dependency
Not working, because
lw
at execution stage is register address instead of register value. The only way to handle this is stall it.