Stalling or bubble in MIPS

北慕城南 提交于 2019-12-14 03:47:01

问题


How many stalls do I need to execute the following instructions properly. I am a little confused with what I did, so I am here to see experts answers.

lw $1,0($2);

beq $1,$2,Label;

Note that the check whether the branch will occur or not will be done in decoding stage. But the source register rs of beq which is $1 in this case will be updated after writeback stage of lw instruction. So do we need to forward new data from Memory in memory stage to Decoding stage of beq instruction.

Here is the data path diagram:


回答1:


The value that is fetched from the memory, is written to the register file in the write-back stage of the pipeline. Writes to the register file happen in the first half of the clock cycle, while reads from the register file happen in the second half of the clock cycle.

The value that is written to the register file can thus be read in the same clock cycle as it is written to the register file. Thus forwarding is not effective here.

As for the number of stalls needed, you need to insert two bubbles into the pipeline, as the lw instruction should be in the write back stage when the beq instruction is in the decode stage.

I hope this answers your question.



来源:https://stackoverflow.com/questions/14092182/stalling-or-bubble-in-mips

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!