How many stalls do I need to complete correctly. I am a little confused by what I did, so I am here to see expert answers.
lw $1,0($2); beq $1,$2,Label;
Please note that checking whether the branch will occur or not will be performed at the decoding stage. But the original register rs beq, which in this case is $ 1, will be updated after the write back of the lw instruction. So we need to send new data from the memory at the memory stage to the decoding stage of the beq instruction.
The stage is as follows:

IF: team selection; ID: command decoding Example: execution step / ALU MEM: read data from memory WB: save data in the destination register
This is what I have done so far.
When lw is in the exec stage and beq is in the decoding stage, the stall condition becomes true and a bubble is created. Now lw is in the Mem stage, and beq is still in the decoding stage due to the bubble, again the stop condition has stopped, and the second stall has occurred. And now lw is in WB (write back), and beq is in the decoding stage, but still the value from $ 1 will be updated at the end of the WB stage, which ultimately means that beq will still work with the wrong value of $ 1.
source share