简体   繁体   English

为什么 ALU 结果将地址写入 memory 用于 R-Type 指令?

[英]Why ALU result writes address into memory for R-Type instructions?

I'm trying to understand single-cycle datapath for MIPS instructions.我正在尝试了解 MIPS 指令的单周期数据路径。 Currently I can trace R-type, I-type and J-type instructions and I'm aware of control signals on different instructions but there are still unclear points in my mind.目前我可以跟踪 R 型、I 型和 J 型指令,并且我知道不同指令上的控制信号,但我的脑海中仍有不清楚的地方。 In this example I assumed there is a R-type instruction let's say add instruction.在这个例子中,我假设有一个 R 类型的指令,比如说add指令。

单周期数据通路

I think add instruction has nothing to do with memory.我认为add指令与 memory 无关。 Certainly it doesn't write result value to memory but it points to "Address" input in data memory.当然,它不会将结果值写入 memory,但它指向数据 memory 中的“地址”输入。 This is where I'm confused.这就是我感到困惑的地方。

It does not "write" addresses to memory, it gives addresses to the Data Memory.它不会将地址“写入”到 memory,而是将地址提供给数据 Memory。

A memory operation requires 3 things: memory 操作需要 3 件事:

  • an address一个地址
  • a value一个值
  • a size一个尺寸

Some memory operations are "loads" — these transfer a value from memory to the CPU, so the load specifies a target register for the value;一些 memory 操作是“加载”——这些操作将一个值从 memory 传输到 CPU,因此加载指定该值的目标寄存器; some memory operations are "stores" — these transfer a value to memory from the CPU, so stores specify a source register for the value.一些 memory 操作是“存储”——这些操作将值从 CPU 传输到 memory,因此存储指定该值的源寄存器。

Regardless of whether load or store, an address must be specified to perform a Data Memory operation.无论是加载还是存储,都必须指定地址才能执行数据 Memory 操作。 On MIPS we have just one addressing mode , which is register + sign extended immediate.在 MIPS 上,我们只有一种寻址模式,即寄存器 + 符号扩展立即数。 In simple MIPS processors, the ALU performs this addition, since it is free/available in that clock cycle for that use.在简单的 MIPS 处理器中,ALU 执行这个加法,因为它在那个时钟周期内是免费的/可用的。

The control signals turn MemRead on for loads and MemWrite on for stores.控制信号为加载打开 MemRead,为存储打开 MemWrite。 Otherwise both of those are off, so the Data Memory is inactive for R-Type instructions, branch instructions, any instruction that doesn't load or store.否则,这两个都关闭,因此数据 Memory 对于 R 型指令、分支指令、任何不加载或存储的指令都是无效的。

For R-Type instructions, the ALU result is routed (around the Data Memory, and eventually) back to the registers as the Write Data.对于 R-Type 指令,ALU 结果被路由(围绕数据 Memory,最终)作为写入数据返回到寄存器。 For load instructions, the Data Memory value becomes the Write Data.对于加载指令,数据 Memory 值变为写入数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM