MIPS 单周期数据路径:执行了多少有用的减法和加法?
MIPS single cycle datapath: How many useful subtractions and additions are performed?
我有以下仅执行一次的 MIPS 代码,我需要计算总共执行的 有用 加法和减法的次数。
L: sub $s0,$s1,$s2
slt $s3,$s0,$s4
lw $t0,0($sp)
add $t1,$t0,$s1
beq $t1,$t3,L
我认为总共有11个操作:
the subtraction
PC+4
the subtraction for slt
PC+4
R[rs]+SignExtImm for lw
PC+4
the addition
PC+4
the subtraction in ALU for beq
PC+4
PC+4+BranchAddr
但是,11不是多项选择中的可能选项。
我自己统计了。他们同意,除了 beq
您重复计算了 PC+4
。 AFAICT,该指令 PC+4
或 PC+(offset << 2)
但 不是 两者。
所以,这使计数从 11 减少到 10。这是肯定的。
但是,我不确定 beq
使用减法进行比较。 IMO,更有可能是 XOR 运算 [电路更少,速度更快,equality/inequality 测试的标准逻辑],因此计数减少到 9。
YMMV ...
我有以下仅执行一次的 MIPS 代码,我需要计算总共执行的 有用 加法和减法的次数。
L: sub $s0,$s1,$s2
slt $s3,$s0,$s4
lw $t0,0($sp)
add $t1,$t0,$s1
beq $t1,$t3,L
我认为总共有11个操作:
the subtraction
PC+4
the subtraction for slt
PC+4
R[rs]+SignExtImm for lw
PC+4
the addition
PC+4
the subtraction in ALU for beq
PC+4
PC+4+BranchAddr
但是,11不是多项选择中的可能选项。
我自己统计了。他们同意,除了 beq
您重复计算了 PC+4
。 AFAICT,该指令 PC+4
或 PC+(offset << 2)
但 不是 两者。
所以,这使计数从 11 减少到 10。这是肯定的。
但是,我不确定 beq
使用减法进行比较。 IMO,更有可能是 XOR 运算 [电路更少,速度更快,equality/inequality 测试的标准逻辑],因此计数减少到 9。
YMMV ...