Piping assembly

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:

enter image description here

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.

+6
source share
1 answer

it looks like you will need a third stall to enable register writing to the register file before decoding or to send data from the write back stage to the decoding stage. In any case, this must be done if the register to be written is rs .

It seems that you need too many stalls because the branch is detected at an early stage of decoding, which is good because it saves retrieving unnecessary instructions that will turn red anyway, but you must have proper hazard detection to go with this.

+2
source

All Articles