看板 Grad-ProbAsk 關於我們 聯絡資訊
是否是因為 beq在id stage中,直接將兩個從register file 讀出來的內容直接作比較。 圖可參考白算盤三版p.420 且forwarding Unit只支援從Mem To ALU與WB To ALU這兩個Forwarding path. 因此無法使用Forwarding Unit 來解決此Data Hazard。 我的想法是這樣。有問題,還請大大指正。 至於中央那個解答。我就不太清楚了。 ※ 引述《lwtistunning (考驗)》之銘言: : ADDI r1,r0,#101 : ADDI r2,r0,A : Loop:LD r3,0(r2) : ADDI r3,r3,#1 : SD r3,0(r2) : ADDI r2,r2,#4 : SUBI r1,r1,#1 : BNE r1,r0,Loop : Assume that the branch is resolved during the instruction decode stage, : and full register forwarding are implemented. : Assume that all memory reference hit in the cache and TLBs. : the pipeline does not implement any branch prediction mechanism. : How many stall cycle are in one loop iteration including stalls caused : by the branch instruction? : 我想問的是 SUBI r1,r1,#1 : BNE r1,r0,Loop 這兩指令中 明顯有data hazard存在 : 題目說有支援forwarding,那不就應該靠forwarding就能解決這邊的data hazard了嗎? : 解答卻是說,需要在這兩道指令中再加一個stall才可。 : 有人能教我一下為什麼這邊還要stall一個clock呢? : (解答這樣說;Since branch decision is resolved during ID stage,a clock stall is : needed between SUBI and BEQ.) : 因為我在做其它考古題時,也有遇到類似情形,但如果有支援forwarding下 : 都是不用再加一個stall的。 : 例如中央97的一題 or $3,$2,$1 : beq $2,$3,loop 顯然也有data hazard存在 : 但解答是說用forwarding即可解。 : 難道是有提到branch decision is resolved during ID stage. : 那麼即使在有支援forwarding下,還是要stall一個clock?? : 麻煩各位指導一下,還是我觀念有錯? 謝謝!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.146.34.46
lwtistunning:感謝 10/31 22:16