110 likes | 208 Views
+. +. IF stage. ID stage. 2. PC. 4. 1. NPC. taken target. Imm. Actual T/NT. A op 0 ?. taken?. decode. is a branch. Always predict NT. 1. Recovery: Redirect fetch unit to T path if actually T. 2. IF stage. ID stage. PC. +. +. 4. NPC. taken target. Imm. target.
E N D
+ + IF stage ID stage 2 PC 4 1 NPC taken target Imm Actual T/NT A op 0? taken? decode is a branch Always predict NT. 1 Recovery: Redirect fetch unit to T path if actually T. 2
IF stage ID stage PC + + 4 NPC taken target Imm target read port BTB t/nt Predicted T/NT T/NTpred. mispredicted? hit == Actual T/NT A op 0? write port decode is a branch PC
IF stage ID stage PC + + 4 NPC taken target Imm target read port BTB t/nt Predicted T/NT T/NTpred. mispredicted? hit == Actual T/NT A op 0? write port decode is a branch PC 1 Predict NT if: BTB miss OR (BTB hit & prev. outcome = NT) 1
IF stage ID stage PC + + 4 NPC taken target Imm target read port BTB t/nt Predicted T/NT T/NTpred. mispredicted? hit == Actual T/NT A op 0? write port decode is a branch PC 2 Predict T if: (BTB hit & prev. outcome = T) 2
IF stage ID stage PC + + 4 NPC taken target Imm target read port BTB t/nt Predicted T/NT T/NTpred. mispredicted? hit == Actual T/NT A op 0? write port decode is a branch PC 3 Recovery: Redirect fetch unit to NT path if: (Predicted T & Actually NT) 3
IF stage ID stage PC + + 4 NPC taken target Imm target read port BTB t/nt Predicted T/NT T/NTpred. mispredicted? hit == Actual T/NT A op 0? write port decode is a branch PC 4 Recovery: Redirect fetch unit to T path if: (Predicted NT & Actually T) 4
IF stage ID stage PC + + 4 NPC taken target Imm target read port BTB t/nt Predicted T/NT T/NTpred. mispredicted? hit == Actual T/NT A op 0? write port decode is a branch PC 5 • Update BTB: • If branch missed in BTB, add it to BTB. • Whether branch missed or hit in BTB, always update prev. outcome field. 5
+ + Training BTB IF stage ID stage PC 4 NPC Taken Target Imm read port BTB T / NT direction A op 0? is a branch decode write port PC
+ + Using BTB IF stage ID stage PC 4 NPC Taken Target Imm target read port BTB t/nt A op 0? Actual T/NT hit T/NTpred. == Predicted T/NT mispredicted? is a branch decode write port PC