為什麼這篇mips slt指令鄉民發文收入到精華區:因為在mips slt指令這個討論話題中,有許多相關的文章在討論,這篇最有參考價值!作者numin (numin)看板Grad-ProbAsk標題[理工] [計組] control h...
Given the following MIPS instruction code segment, please answer each question
below.
L1: addi $t0 ,$t0,4
lw2 $s1 ,0($t0)
sw $s1 ,32($t0)
lw1 $t1 ,64($t0)
slt $s0 ,$t1,$zero
bne $s0 ,$zero,L1
Assume a forwarding unit is available to only forward data from ME and/or WB
to EX. Please reorder/rewrite the code to maximize its performance.Note that
you should consider maximizing the performance based on the assumption that
the loop might be iterated a few times.You may insert no-ops in the code
segment to resolve inevitable hazards if any.
解答:
L1: addi $t0,$t0,4
lw1 $t1,64($t0)
lw2 $s1,0($t0)
slt $s0,$t1,$zero
nop
nop
bne $s0,$zero,L1
sw $s1,32($t0)
疑問:想請問大家在解類似這種reorder code時,尤其有control hazard時,
是都如何思考,下手去做的。雖然課本上有三種from before,from target,
from fall through方法,可是碰到這種題目真的不是很清楚該如何去作答。
不曉得有沒有能說明一下您在碰到這種題目的做法,讓我參考看看...
我只會先解control hazard,然後在用課本三種方法隨便亂試...或是交換指令
然後找到data hazard,就畫成pipeline stage了...看要不要插入nop
問題:請問為什麼不是插一個nop,而是兩個。我只會畫圖,以下是我畫的圖
,不曉得又是哪裡出錯了...(看完上篇d大解說,現在懂了。可是都打了就...
請問大家都是怎麼做這類題型吧。)
addi IF ID EX ME-| WB
lw2 IF ID EX | ME-| WB
lw1 IF ID |- EX | ME WB
slt IF ID |-EX ME WB-|
nop X X X X | X
nop X X X | X X
bne IF ID-| EX ME WB
sw IF ID EX ME WB
(addi和lw用有hazard:forwarding解,slt和bne有hazard)
※ 編輯: numin 來自: 123.193.221.223 (09/20 22:19)