作者qwer123073 (NullSpace)
看板Grad-ProbAsk
標題[理工] 計組pipeline問題
時間Sun Jan 22 00:03:46 2017
想問各位高手一些pipeline的問題
問題一:
For the code sequence below,assume the two bne instructions
are as taken,but actually they are not taken.How many cycles
does it take to complete the execution of the code by using
the two CPUs below,respectively?For each CPU,please also
identify which cycle(s) will become bubble(i.e., stall cycle)
when executes the code(Note:the first instruction:"lw $t0,$s1,$s2
"starts from cycle 1).
1. lw $t0,$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
(1)The pipelined CPU for which assume the forwarding mechanism has
been designed and the branch outcome is determined at MEM stage.
(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.
以下為答案:
(1)
Total number of cycles = 5-1+8+1+1+3+3=20
Stall cycles : c4,c7
(2)
Total number of cycles = 5-1+8+1+2+1+1+1=18
Stall cycles : c4,c7,c8,c12
以下是我的想法
(1)
IF ID EX ME WB --lw $t0,$s1,$t2
IF ID ID EX ME WB --add $s0,$t0,$t1
IF IF ID EX ME WB --lw $s1,0($t0)
IF ID ID EX ME WB --bne $s0,$s1,10
IF IF ID EX ME WB --add $s2,$s0,$s1
以上因為有2個load-use hazards
所以共stall 2 cycles
題目中提到
bne猜會跳但是其實沒跳
我想問
5-1+8+1+1+3+3
後面兩個3是怎麼算的
(2)
IF ID EX ME WB --lw $t0,$s1,$t2
IF ID ID EX ME WB --add $s0,$t0,$t1
IF IF ID EX ME WB --lw $s1,0($t0)
IF ID ID ID EX ME WB --bne $s0,$s1,10
IF IF IF ID EX ME WB --add $s2,$s0,$s1
跟第一題一樣
我知道load-use共stall (1+2) cycles
但是不知道後面bne的部分要怎麼看
還請大家指點
問題二:
想問stall和nop的使用時機
什麼時候用stall
什麼時候用nop
謝謝大家
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 36.239.41.152
※ 文章網址: https://www.ptt.cc/bbs/Grad-ProbAsk/M.1485014629.A.1DF.html
推 GLBM: 第一種clock cycle:load+beq停一個但beq會幹掉三個 01/22 00:13
→ GLBM: 第二種clock cycle:load+beq停兩個 beq會幹掉一個 01/22 00:13
推 GLBM: 第二種多一個clock cycle 因為beq在ID就要決定要不要跳,所 01/22 00:17
→ GLBM: 以第6行和第7行中間要停一個,所以是(5-1)+8+1+2+1這樣 01/22 00:17
推 GLBM: (5-1)+8初始+1(load use)+2(load+bne)+1(第6.7行中間+2(兩 01/22 00:22
→ GLBM: 個bne幹掉的) 01/22 00:22
→ qwer123073: 課本說一般假設不taken,如果taken了就幹掉三個,那如 01/22 00:36
→ qwer123073: 果題目說假設taken,但是實際上not taken,該怎麼處理 01/22 00:38
推 joy7658x348: [理工] 101交大計組 01/22 01:42
→ joy7658x348: A.E6E.html 01/22 01:42
推 joy7658x348: 抱歉…我用手機不知道怎縮…這題之前有討論到~打交 01/22 01:44
→ joy7658x348: 大101有 可以研究看看 01/22 01:44
→ aa06697: 你說的nop是指插入nop吧? 那stall跟nop效果一樣 一個軟 01/22 09:52
→ aa06697: 體做 一個硬體做而已 01/22 09:52
→ ken52011219: 2 cycle 01/22 10:19
推 yupog2003: 假設taken實際上不taken => 要等到MEM才知道要branch到 01/22 10:27
→ yupog2003: 哪裡去,所以等3個cycle,阿結果發現根本不taken,等於 01/22 10:27
→ yupog2003: 這3個cycle白浪費了,阿但是還是浪費了3個cycle 01/22 10:28
→ qwer123073: 了解了,感謝各位~ 01/23 01:40