作者phokasion (fre)
看板Grad-ProbAsk
標題Re: [理工] [計組] - 台聯大99
時間Mon Jan 23 16:32:04 2012
※ 引述《skill91002 (有為)》之銘言:
: 題目如下:
: Given a MIPS instruction sequence shown below . Assume this code is executed
: on a pipelined MIPS CPU with a five-stage pipeline, full forwarding, and a
: predict-taken branch predictor. In addition, assume this CPU can finish the
: register write in the first half cycle and the register read in the second
: cycle.
: L3 : add $s6 , $s6 , $s5
: addi $s5 , $s5 , 2
: slti $t0 , $s5 , 10
: bne $t0 , $zero , L3
: sw $s6 , 100($gp)
: (1) Assume the branch is taken , please draw the simple(traditional)
: multiple-clock-cycle pipeline execution diagram of the first 5 executed
: instructions, including all necessary stalls.
: (2) If the branch is not taken, please redraw the simple(traditional)
: multiple-clock-cycle pipeline execution diagram of the first 5 executed
: instructions, including all necessary stalls.
: 請問這兩小題要怎麼寫比較好 ?
: 題目似乎沒有提到有無將 branch 之決定提前到 ID stage
: 第一題我的答案是這樣:
: L3 : add $s6 ,$s6 ,$s5 IF ID EX MEM WB
: addi$s5 ,$s5 , 2 IF ID EX MEM WB
: slti$t0 ,$s5 , 10 IF ID EX MEM WB
: bne $t0 ,$zero , L3 * IF ID EX MEM WB (EX 前饋給ID)
: add $s6 ,$s6 ,$s5 IF ID EX MEM WB
: 想了一想前饋不是只有 EX->EX 或是 MEM->EX ?
: 有 EX->ID 的嗎?
: 感覺寫錯了
: 第二題就不會了
: beq後面被沖刷部份不會描述
: 還請各位大大幫忙
: 謝謝!
想請問一下第二小題
高銘老師的解答是
L3 : add $s6 ,$s6 ,$s5 IF ID EX MEM WB
: addi$s5 ,$s5 , 2 IF ID EX MEM WB
: slti$t0 ,$s5 , 10 IF ID EX MEM WB
: bne $t0 ,$zero , L3 IF ID EX MEM WB
add $s6 ,$s6 ,$s5(沖刷) IF * * * *
sw $s6 , 100($gp) IF ID EXE MEM WB
我看答案覺得是 bne 在ID級的時候 發現條件不成立 所以在下一個CYCLE沖刷掉add指令
但是 $t0 應該是在slti指令的EX級之後才會知道結果
那bne指令 怎麼在ID級的時候判斷條件是否成是呢?
還請麻煩高手幫我解惑了
謝謝~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 220.136.181.214
推 wheels:它答案錯了吧?bne的ID和add的IF要多stall一個clock才對。 01/24 23:24
→ wheels:要像它第一題答案那樣才對。by the way,full forwarding 01/24 23:26
→ wheels:可以forward到ID去。 01/24 23:26