1

下面的代码在 5 级流水线数据路径上运行。我很难知道我对流水线工作原理的理解是否正确。在下面的尝试中,我尝试通过在适当的位置插入“气泡”来解决没有数据转发单元的数据路径中的数据危险。我的第一个问题是,我下面的流水线逻辑是否正确?

我的第二个问题是假设数据路径中有一个转发单元,来自 MEM->EX 和 WB->EX,这将如何改变第一个问题的逻辑?

add t0, s1, s2
add t1, t0, s3
sub t2, t0, t1
xor t3, t2, a0
lw t4, 0(t7)
slt t5, t4, t3

这是我对问题 1 的尝试:

add t0, s1, s2 //IF add1 instruction
nop            //ID add1 instruction
nop            //EX add1 instruction
add t1, t0, s1  //MEM add1 instruction,  IF add2 instruction
nop             //WB add1 instruction,  ID add2 instruction
nop            //EX add2 instruction
nop            //MEM add2 instruction
nop            //WB add2 instruction
sub t2, t0, t1 //IF sub instruction
nop            //ID sub instruction
nop            //EX sub instruction
nop            //MEM sub instruction
xor t3, t2, a0 //WB sub instruction, IF xor instruction
lw t4, 0(t7)   //ID xor instruction, IF lw instruction
nop            //EX xor instruction, ID lw instruction 
nop            //MEM xor instruction, EX lw instruction 
nop            //WB xor instruction, MEM lw instruction
slt t5, t4, t3 //WB lw instruction, IF slt instruction
4

1 回答 1

-1

查看此处所示的管道图:https ://www.student.cs.uwaterloo.ca/~cs251/S12/a4.pdf并将您的指令映射到类似交错的管道,它将帮助您可视化数据危害.

此外,确切的数据转发实施将取决于您作业中问题的设计,这将影响您需要多少 nop。

于 2012-10-24T19:28:20.390 回答