MIPS管道转发(双重数据危险)

MIPS管道转发(双重数据危险),mips,pipeline,computer-architecture,Mips,Pipeline,Computer Architecture,在Patterson&Hennessy的书中: 但这难道不能被视为EX hazard: 为什么在MEM阶段进行转发?怎么做?有1个暂停(对于第二次添加,我需要下一次EX中的EX结果)?使用的文档 在考虑“双重数据危险”(原始规则)之前,我将重写EX和MEM危险条件(为简单起见,删除!=0部分): 防爆 if (EX/MEM.RegWrite and (EX/MEM.RegisterRd == ID/EX.RegisterRs) # =EX_h_Rs ) ForwardA = 1

在Patterson&Hennessy的书中:

但这难道不能被视为EX hazard:

为什么在MEM阶段进行转发?怎么做?有1个暂停(对于第二次添加,我需要下一次EX中的EX结果)?

使用的文档

在考虑“双重数据危险”(原始规则)之前,我将重写EX和MEM危险条件(为简单起见,删除!=0部分):

防爆

 if (EX/MEM.RegWrite and (EX/MEM.RegisterRd == ID/EX.RegisterRs)  # =EX_h_Rs 
   ) ForwardA = 10
 if (EX/MEM.RegWrite and (EX/MEM.RegisterRd == ID/EX.RegisterRt)  # =EX_h_Rt
   ) ForwardB = 10
我将调用条件EX_h_Rs和EX_h_Rt来缩短公式

MEM危害(原始状态)

====

我们的示例同时包含两种类型的危险,介于(第1种和第3种)和(第2种和第3种)之间:

add $1, $1, $2 
add $1, $1, $3 
add $1, $1, $4
或(问题周期在顶部和底部标有
**

根据我的链接,在考虑了双EX+MEM危害:(不含!=0和重新排序的布尔项)之后,更新了MEM危害规则

让我们修改MEM hazard的转发条件,以处理“双重”数据危害

或者使用EX_h的短记录_*

 if (MEM/WB.RegWrite and (MEM/WB.RegisterRd = ID/EX.RegisterRs) and 
  not ( EX_h_Rs ) 
  ) 
   ForwardA = 01
 if (MEM/WB.RegWrite and (MEM/WB.RegisterRd = ID/EX.RegisterRt) and 
  not ( EX_h_Rt ) 
 ) 
   ForwardB = 01
这意味着:

尝试从MEM/WB转发到EX;如果没有从EX/MEM管道寄存器正向到同一输入操作数

还是一样

甚至不要尝试从MEM/WB转发到EX;如果已经从EX/MEM转发了最近的结果

我将试图说明:

add C+A -> A     A'
                 v?  (forwarding to 3rd instruction) 
           A -> A''
                v?
          add C+A -> A          
因此,对于第三条指令,原始规则将说明来自第一条指令的
A'
和来自第二条指令的
A'
都应该被转发(但mux不能在同一时刻从两个源馈送)。修改MEM hazard condition(MEM危害条件)表示,如果最近有
A'
的活动转发,则不应尝试转发
A'


所以,;您的图纸是正确的,将有两个前视图;;但如果已经有有效的EX hazard forwarding,则不应尝试MEM hazard forwarding。

这显然是本书第四版中的一个错误(括号是不平衡的)。奇怪的是,这本书的最新版本(第四版修订版)增加了一个遗漏的结尾“)”,但是。。。最终导致不正确的情况仍然

我认为这是条件的正确版本:

if (MEM/WB.RegWrite
and (MEM/WB.RegisterRd ≠ 0)
and not(EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 0)
       and (EX/MEM.RegisterRd = ID/EX.RegisterRs))
and (MEM/WB.RegisterRd = ID/EX.RegisterRs)) Forward = 01

if (MEM/WB.RegWrite
and (MEM/WB.RegisterRd ≠ 0)
and not(EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 0)
       and (EX/MEM.RegisterRd = ID/EX.RegisterRt))
and (MEM/WB.RegisterRd = ID/EX.RegisterRt)) Forward = 01

PS,我的最后一个链接,谈到了书中的打字错误:“请注意,教科书第369页中关于MEM hazard的正向条件是错误的!”我认为这可能与你的形象有关。这显然是书中的一个错误(括号是不平衡的)。奇怪的是,这本书的最新版本(第四版修订版)增加了一个遗漏的结尾
 if (MEM/WB.RegWrite and (MEM/WB.RegisterRd = ID/EX.RegisterRs) and 
  not ( EX_h_Rs ) 
  ) 
   ForwardA = 01
 if (MEM/WB.RegWrite and (MEM/WB.RegisterRd = ID/EX.RegisterRt) and 
  not ( EX_h_Rt ) 
 ) 
   ForwardB = 01
add C+A -> A     A'
                 v?  (forwarding to 3rd instruction) 
           A -> A''
                v?
          add C+A -> A          
if (MEM/WB.RegWrite
and (MEM/WB.RegisterRd ≠ 0)
and not(EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 0)
       and (EX/MEM.RegisterRd = ID/EX.RegisterRs))
and (MEM/WB.RegisterRd = ID/EX.RegisterRs)) Forward = 01

if (MEM/WB.RegWrite
and (MEM/WB.RegisterRd ≠ 0)
and not(EX/MEM.RegWrite and (EX/MEM.RegisterRd ≠ 0)
       and (EX/MEM.RegisterRd = ID/EX.RegisterRt))
and (MEM/WB.RegisterRd = ID/EX.RegisterRt)) Forward = 01