MIPS中出现停滞或气泡 [英] Stalling or bubble in MIPS

查看:240
本文介绍了MIPS中出现停滞或气泡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要多少个档位才能正确执行以下说明.我对自己的所作所为感到有些困惑,因此我在这里看到专家的答案.

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);

lw $1,0($2);

在$ 1,$ 2,Label之前;

beq $1,$2,Label;

请注意,将在解码阶段检查是否会发生分支.但是beq的源寄存器rs在这种情况下为$1,将在lw指令的写回阶段之后进行更新.因此,我们是否需要将新数据从内存阶段的内存转发到beq指令的解码阶段.

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.

这是数据路径图:

推荐答案

从内存中获取的值在管道的回写阶段被写入寄存器文件.对寄存器文件的写入发生在时钟周期的后半部分,而对寄存器文件的读取发生在时钟周期的后半部分.

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.

关于所需的停顿数,您需要在流水线中插入两个气泡,因为lw指令应在解码阶段,而lw指令应在回写阶段.

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.

这篇关于MIPS中出现停滞或气泡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆