[理工] 計組pipeline問題
想問各位高手一些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
推
01/22 00:13, , 1F
01/22 00:13, 1F
→
01/22 00:13, , 2F
01/22 00:13, 2F
推
01/22 00:17, , 3F
01/22 00:17, 3F
→
01/22 00:17, , 4F
01/22 00:17, 4F
推
01/22 00:22, , 5F
01/22 00:22, 5F
→
01/22 00:22, , 6F
01/22 00:22, 6F
→
01/22 00:36, , 7F
01/22 00:36, 7F
→
01/22 00:38, , 8F
01/22 00:38, 8F
推
01/22 01:42, , 9F
01/22 01:42, 9F
→
01/22 01:42, , 10F
01/22 01:42, 10F
→
01/22 01:42, , 11F
01/22 01:42, 11F
推
01/22 01:44, , 12F
01/22 01:44, 12F
→
01/22 01:44, , 13F
01/22 01:44, 13F
→
01/22 01:45, , 14F
01/22 01:45, 14F
→
01/22 01:45, , 15F
01/22 01:45, 15F
→
01/22 09:52, , 16F
01/22 09:52, 16F
→
01/22 09:52, , 17F
01/22 09:52, 17F
→
01/22 10:19, , 18F
01/22 10:19, 18F
→
01/22 10:19, , 19F
01/22 10:19, 19F
推
01/22 10:27, , 20F
01/22 10:27, 20F
→
01/22 10:27, , 21F
01/22 10:27, 21F
→
01/22 10:28, , 22F
01/22 10:28, 22F
→
01/23 01:40, , 23F
01/23 01:40, 23F