看板 Grad-ProbAsk 關於我們 聯絡資訊
[101交大資聯] 張凡上P534 For the code sequence below,assume the two "bne" instructions are predicted as "taken", but actually they are "not taken".How many cycles does it take to complete? Also indentify which cycle(s) will become bubble when execute the code 1. lw $to,$s1,$s2 2. add $s0,$t0,$t1 3. lw $s1,0($t0) 4. bne $s0,$s1,10 5. add $s2,$s0,$s1 6. add $s3,$s1,$s0 7. bne $s2,$s3,10 8. add $s3,$s2,$s3 (2)The pipelined CPU for which assume the forwarding mechanism has been designed and some hardware has been added to determine the branch outcome at ID stage 這題原本是有兩小題 我會第一小題 但第二小題不太會@@ ANS: Total number of cycles=5-1+8+1+2+1+1+1=18 Stall cycles:c4,c7,c8,c12 5-1+8跟c4,c7那邊我會 不過後面就不太懂了... [96成大電機] 張凡上P573 Given MIPS code 16 L1:addi $t0,$t0,4 20 lw $s1,0($t0) 24 sw $s1,32($t0) 28 lw $t1,64($t0) 32 slt $s0,$t1,$zero 36 bne $s0,$zero,L1 (2)Assume a forwarding unit is available to only forward data from MEM and/or WB to EX. Please reorder/rewrite the code to maximize its performance based on the assumption that the loop might be iterated a few times.You may insert NOP in the code to resolve invitable hazards if any. ANS:張凡給的答案是 L1: addi $t0, $t0, 4 lw $t1, 64($t0) lw $s1, 0($t0) slt $s0, $t1, $zero nop nop bne $s0, $zero, L1 sw $s1, 32($t0) 想請問大家,unrolling的解法應該不唯一? 像我這樣寫可以嗎? L1: addi $t0, $t0, 4 lw $t1, 64($t0) lw $s1, 0($t0) slt $s0, $t1, $zero sw $s1, 32($t0) nop bne $s0, $zero, L1 nop 還有slt是不能forwarding的對嗎? 它一定要再WB才會寫回$s0? 所以跟slt有RAW dependency的時候一定要間隔2個指令以上才不會有data hazard? 以上是小弟的一些問題 如果大家了解請幫我釐清一些觀念 >_< 感謝大家 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.170.204.56 ※ 編輯: john2557 來自: 118.170.204.56 (11/12 23:56)
kiki86151:第二題根本不是unrolling==是branch delay重排吧…(3種 11/13 01:14
john2557:sorry,不是unrolling打錯,所以有三種可能,我寫的那樣 11/13 15:19
john2557:也可? 11/13 15:19
kiki86151:感覺不行太不確定 因為bne下面一定要塞一個總是要做的指 11/13 17:57
kiki86151:令塞sw可因為不管有沒有跳都不用flush 而塞nop 也好像ok 11/13 17:57
kiki86151:但感覺就不是題目要求要最好的= =還有很奇怪明明slt是可 11/13 17:57
kiki86151:以用forwarding解決的 但發現題目說forwarding unit只有 11/13 17:58
kiki86151:一個可用..但它被用來解決addi和lw s1那行了 故要插2nop 11/13 17:58