加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

“内存操作数的对齐”如何帮助MIPS进行流水线操作?

发布时间:2020-12-14 04:56:28 所属栏目:百科 来源:网络整理
导读:“内存操作数的对齐”如何帮助MIPS进行流水线操作? 这本书说: Fourth,as discussed in Chapter 2,operands must be aligned in memory. Hence, we need not worry about a single data transfer instruction requiring two data memory accesses; the requ
“内存操作数的对齐”如何帮助MIPS进行流水线操作?

这本书说:

Fourth,as discussed in Chapter 2,operands must be aligned in memory. Hence,
we need not worry about a single data transfer instruction requiring two data
memory accesses; the requested data can be transferred between processor and
memory in a single pipeline stage.

我想我明白一条数据传输指令不需要两个或多个数据存储器.
但是,我不确定它与内存操作数的对齐有什么关系.

提前致谢!

解决方法

lw指令要求存储器地址是字对齐的.

因此,要访问未对齐的字,需要访问所需字相交的两个字边界并屏蔽必要的字节.

例如,假设您希望加载存储在地址0x2的单词. 0x2不是字对齐的,因此您需要加载存储在0x2的半字和存储在0x4的半字.

为此,有人可能写道:

lh  $t0 2($zero)
lh  $t1 4($zero)
sll $t1 $t1 16
or  $t2 $t0 $t1

如果要加载例如存储在地址0x3的单词,这只会变得更复杂:

# load first byte
lb  $t0 3($zero)

# load second word,mask out first 3 bytes
lw  $t1 4($zero)
lui $t2 0x0000FFFF
ori $t2 $t2 0xFFFFFFFF
or  $t1 $t1 $t2

# combine
sll $t1 $t1 8
or  $t2 $t0 $t1

因此,可以看出,字对齐的要求无助于MIPS流水线化,而是对未对齐字的访问需要过多的存储器访问 – 这是ISA的限制.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读