假设您有一个带有管道的MIPS处理器,但没有预防危险或转发,这是否是NOP的正确位置?

发布于 2025-01-24 04:41:32 字数 578 浏览 2 评论 0 原文

我想检查我的工作和对管道的理解,不幸的是,火星不适合此功能,因此很难验证我的假设。

我将说明放在电子表格中,以帮助我了解发生了什么,我想确保这是正确的。我使用蓝色指示周期中的每个阶段,与书不同,我没有表示每个阶段发生的一半(即上半场,下半场是ID)

根据Patterson和Hennessey的这本书,ID阶段在WB开始时就发生了。

,这应该意味着最后一个SW命令应按预期工作,因为先前(有效指令)的WB发生在该周期的开始时 - ID在尾部。

I would like to check my work and understanding of pipelines, unfortunately MARS doesn't accommodate this feature so it is hard to verify my hypothesis.

I placed the instructions in a spreadsheet to help me understand what is going on and I would like to ensure that this is correct. I used the color blue to indicate each stage in the cycle, unlike the book, I didn't denote which half of the cycle each stage occurs (I.E WB is in the first half and ID in the second half)

Instruction pipeline

Based on the book by Patterson and Hennessey, the ID stage occurs towards the end while WB is at the start.

order of commands

So that should mean that the last SW command should work as intended because the WB of the prior (valid instruction) occurs at the start of that cycle - while ID is at the tail.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半﹌身腐败 2025-01-31 04:41:32

是的,看起来正确。

后续指令的ID阶段可以与上述指令的WB阶段重叠,并且仍然获得适当的价值。

这是因为,对于WB中的一个,新数据已完全准备在周期的开始时进入寄存器 - 没有什么可计算的。完整的答案已在上一循环结束时完全计算出来,因此不需要更改书面记录的值。  计算输出之前,在先前周期中遵循实质逻辑的输入。

(与Alu操作进行比较,在 要解决以包括在同一周期中发生的新书面的WB值,否则设计人员将在寄存器文件中放置内部旁路/向前。 无论哪种方式,ID阶段都将在同一周期而不是先前的陈旧值中获得书面寄存器(WB)的最新值。

他们所说的是,WB发生在周期的上半年,ID发生在下半年。 但是,它实际上是在内部与各种处理器实现的 - 想法是,我们可以依靠在同一周期中编写的读取值。  周期分为一半,但这是另一种实现的可能性。)

(我相信他们没有说明他们是否建议使用时钟的另一个过渡(例如向下边缘)将 :

(在时钟周期中读取寄存器
返回上半年结束时写的价值
当这种写入发生时,周期。)

图4.52上的标题,以及

可以通过设计来解决最后的潜在危害
注册文件硬件:读取寄存器时会发生什么
写在同一时钟周期中?我们假设写道在
时钟周期的前半部分,读取为下半部
阅读提供所写的内容。与许多人一样
寄存器文件的实现,我们没有数据危害
案例。

从图4.52。 这些相同的文本发生在本书的RISC V版本中(尽管相对于图号4.50而不是4.52)。


我们还要注意,引入转发(又称绕过)以减轻危害(而不是程序员插入 nop s)时,需要从ex-> ex以及mem-&gt中转发。例如 第一个是Alu背靠背的原始危害,第二个是用于使用负载的原始危害(背对背)以及通过1个指令分开的Alu危害!

Yes, that looks correct.

The ID stage of a succeeding instruction can overlap with the WB stage of a preceding instruction, and still get the proper value.

This is because, for one in WB, the new data is fully ready to go into the registers at the very start of the cycle — there is nothing to compute; the complete answers have been fully computed by the end of the prior cycle, so no bits need change in the values being recorded by the write back.  (Compare with ALU operation where substantial logic follows input from the prior cycle, before outputs can be computed.)

In the ID stage, the values are looked up in the register file, and either the cycle timing will be sufficiently long to allow the values to settle to include newly written WB values that happen in the same cycle, or else the designers will put an internal bypass/forward inside the register file.  Either way, the ID stage will obtain the latest value of a register that is written (WB) in the same cycle rather than a prior stale value.

The way they have put it is that WB happens in the first half of the cycle and ID happens in the second half.  However it is actually implemented internally to various processors — the idea is that we can count on reading values written in the same cycle.  (I believe they leave it unsaid as to whether they are suggesting to use the other transition of the clock (e.g. the downward edge) to physically divide the cycle in half or not, but that is another implementation possibility.)

From the same text book:

(A read of a register during a clock cycle
returns the value written at the end of the first half of
the cycle, when such a write occurs.)

Caption on Figure 4.52, and,

The last potential hazard can be resolved by the design of the
register file hardware: What happens when a register is read and
written in the same clock cycle? We assume that the write is in the
first half of the clock cycle and the read is in the second half, so the
read delivers what is written. As is the case for many
implementations of register files, we have no data hazard in this
case.

From main text just above the Figure 4.52.  These same texts occurs in the RISC V version of the book (though relative to Figure number 4.50 instead of 4.52).


Let's also note that when forwarding (aka bypassing) is introduced to mitigate hazards (instead of programmer inserting nops), there will need to be forwarding from EX->EX as well as MEM->EX.  The first is for back to back RAW hazards on the ALU, where the second is for both load-use RAW hazards (back to back) as well as ALU hazards that are separated by 1 instruction!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文