作者GraffitiK (GraffitiK)
看板Grad-ProbAsk
標題[理工] [計組]-Pipeline
時間Fri Mar 5 14:26:35 2010
請問兩題:
1.(93台大電機)
Identify all of the data dependencies in the following code. Show which
dependencies are data hazards and how they can be resolved via forwarding?
(1) add $2, $5, $4
(2) add $4, $2, $5
(3) sw $5, 110($2)
(4) add $3, $2, $4
書上的解答是:
(1)(2)之間$2會產生data hazard
(1)(3)之間$2會產生data hazard
(2)(4)之間$4會產生data hazard
(1)(4)之間$2會產生data hazard
我想問的是,(1)(4)之間不是可以前半週期寫入、後半週期讀取,這樣還算有data
hazard嗎?
2.(98成大資工)
Consider a pipelined processor. Given a "single" MIPS code to illustrate
RAW, WAR and WAW hazards. Note that the MIPS code can only consist of no
more than four R-type instructions.
我不太懂要怎麼寫... MIPS不是只會出現RAW嗎? 那要怎麼用MIPS指令說明WAR和
WAW hazards?
謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.121.155.245
推 stevenwin:hazard本來三個都有,只是RAW比較常出現 03/05 14:28
推 assassin88:(1)(4)之間應該是dependance而已。 03/05 14:28
→ assassin88:成大那題的意思是,以RAW code描述其他種類的hazard。 03/05 14:30
→ assassin88:白話一點就是叫你用你線在學的add、sub那種去寫。 03/05 14:30
→ stevenwin:add $s1,$s2,$s add $s2,$s1,$t1 add $s2,$t2,$t3 03/05 14:30
→ stevenwin:add $s1,$s2,$s3 03/05 14:31
推 assassin88:我猜你想打得應該是(2)(4)~ 03/05 14:37
→ GraffitiK:所以(1)(4)的$2只有dependence無data hazard, 那第二題 03/05 14:59
→ GraffitiK:是指使用add sub這種指令去寫, 但是假設不是使用MIPS的 03/05 15:00
→ GraffitiK:5 stage pipeline是嗎? 因為MIPS的5個stage應該是不可能 03/05 15:01
→ GraffitiK:有WAR和WAW吧 03/05 15:01
推 assassin88:MIPS code to illustrate 寫法為stevenwin那種~自己改 03/05 15:07