有和没有转发的MIPS管道停顿 [英] MIPS pipeline stalls with and without forwarding

查看:146
本文介绍了有和没有转发的MIPS管道停顿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照以下MIPS指令顺序(整个程序未显示):

In the following sequence of MIPS instructions (entire program not shown):

DADDUI R1, R1, #-8

BNE R1, R2, Loop

我想确认两条指令之间(在5级MIPS流水线的情况下-IF,ID/Reg,EX,MEM,WB)在有无转发的情况下所需的停顿数.

I want to confirm the number of stalls required between the two instructions (in context of 5 stage MIPS pipeline - IF, ID/Reg, EX, MEM, WB) with and without forwarding.

我的理解:

(a)如果没有转发:

在这种情况下,需要2个停顿(在第5周期中,可以使用寄存器的分相访问在ID阶段读取R1以进行第二条指令)

In this case, 2 stalls are required (in cycle 5, R1 can be read in the ID stage for second instruction using split phase access for registers)

(b)如果有转发:

在这种情况下,不需要暂停(周期4中第二条指令的EX级可以从周期3中第一条指令的EX级的ALU结果中转发R1-8;这是假设分支正在检查EX级中的相等性).

In this case, no stalls are required (EX stage on second instruction in cycle 4 can get R1 - 8 forwarded from ALU result for EX stage of first instruction in cycle 3 ; this is assuming branch is checking for equality in EX stage).

有人可以让我知道以上两个答案是否正确.

Can someone please let me know if the above two answers are correct.

谢谢.

推荐答案

您是正确的.如有疑问,请始终制作显示各个管线阶段的时间表.如图所示,在这种情况下,会发生以下情况:

You are correct. In doubt, always make timeline diagrams showing the various pipeline stages. In this case, pictorially, here's what happens:

时间从左移到右.在转发版本中,与表格行交叉的箭头表示发生转发的位置.

Time moves from left to the right. The arrow crossing the table rows in the forwarding version shows where forwarding occurs.

因此,对于情况(a),浪费了2个周期;对于情况(b),不会浪费任何周期,并且不会使管道停滞.

Thus, for case (a), 2 cycles are wasted; for case (b), no cycles are wasted and the pipeline is not stalled.

这篇关于有和没有转发的MIPS管道停顿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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