Resolve in MEM Branches resolve in MEM Compare
Resolve in MEM
Branches resolve in MEM (Compare in Exec, Branch in Mem), with forwarding enabled and no delay slots Assume stall on branch lw $t 1, 8($t 2) 1 2 3 4 5 F D E M W F D E M F F F add $t 4, $t 5, $t 6 beq $t 1, $t 4, tgt add $t 1, $t 3, $t 2 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Comments Cycle 5, forward $t 1 and $t 4 W add $t 5, $t 1, $t 4 add $t 3, $t 2, $t 4 tgt: lw $t 1, 8($t 2) Branch Taken case F D E M W Branch resolves in cycle 6 (PC updates end of cycle) Fetch new branch PC in cycle 7
Branches resolve in MEM (Compare in Exec, Branch in Mem), with forwarding enabled and no delay slots Assume predict always no branch lw $t 1, 8($t 2) 1 2 3 4 5 F D E M W F D E M F D E F D add $t 4, $t 5, $t 6 beq $t 1, $t 4, tgt add $t 1, $t 3, $t 2 add $t 5, $t 1, $t 4 add $t 3, $t 2, $t 4 tgt: lw $t 1, 8($t 2) Branch Taken case 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Comments Cycle 5, forward $t 1 and $t 4 W Assume no branch. Execute speculatively. F F D E M W Branch resolves in cycle 6 (PC updates end of cycle) Fetch new branch PC in cycle 7
Branches resolve in MEM (Compare in Exec, Branch in Mem), with forwarding enabled and no delay slots Assume stall on branch lw $t 1, 8($t 2) add $t 4, $t 5, $t 6 1 2 3 4 5 F D E M W F F F D E M W F D E M beq $t 1, $t 4, tgt add $t 1, $t 3, $t 2 add $t 5, $t 1, $t 4 add $t 3, $t 2, $t 4 tgt: lw $t 1, 8($t 2) Branch Not Taken case 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Comments Cycle 5, forward $t 1 and $t 4 Branch resolves in cycle 6 (PC updates end of cycle) No branch. Carry on. W
Branches resolve in MEM (Compare in Exec, Branch in Mem), with forwarding enabled and no delay slots Assume predict always no branch lw $t 1, 8($t 2) add $t 4, $t 5, $t 6 1 2 3 4 5 F D E M W F D E M W F D E M beq $t 1, $t 4, tgt add $t 1, $t 3, $t 2 add $t 5, $t 1, $t 4 add $t 3, $t 2, $t 4 tgt: lw $t 1, 8($t 2) Branch Not Taken case 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Comments Cycle 5, forward $t 1 and $t 4 Assume no branch. Execute speculatively. Branch resolves in cycle 6 (PC updates end of cycle) Branch not taken!! I guessed correctly!! Carry on! W Just keep executing…
Resolve in EXE
Branches resolve in Exec (Compare in Exec, Branch in Exec), with forwarding enabled and no delay slots Assume predict always no branch lw $t 1, 8($t 2) 1 2 3 4 5 F D E M W F D E M F D add $t 4, $t 5, $t 6 beq $t 1, $t 4, tgt add $t 1, $t 3, $t 2 add $t 5, $t 1, $t 4 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Comments Cycle 5, forward $t 1 and $t 4 W Assume no branch. Execute speculatively. F add $t 3, $t 2, $t 4 tgt: lw $t 1, 8($t 2) Branch Taken case F D E M W Branch resolves in cycle 5 (PC updates end of cycle) Fetch new branch PC in cycle 6
Branches resolve in Exec (Compare in Exec, Branch in Exec), with forwarding enabled and no delay slots Assume predict always no branch lw $t 1, 8($t 2) add $t 4, $t 5, $t 6 1 2 3 4 5 F D E M W F D E M W F D E M beq $t 1, $t 4, tgt add $t 1, $t 3, $t 2 add $t 5, $t 1, $t 4 add $t 3, $t 2, $t 4 tgt: lw $t 1, 8($t 2) Branch Not Taken case 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Comments Cycle 5, forward $t 1 and $t 4 Assume no branch. Execute speculatively. W
Branches resolve in Exec (Compare in Exec, Branch in Exec), with forwarding enabled and no delay slots Assume predict always branch lw $t 1, 8($t 2) 1 2 3 4 5 F D E M W F D E M add $t 4, $t 5, $t 6 beq $t 1, $t 4, tgt add $t 1, $t 3, $t 2 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Comments Cycle 5, forward $t 1 and $t 4 W Assume no branch. Execute speculatively. F add $t 5, $t 1, $t 4 add $t 3, $t 2, $t 4 tgt: lw $t 1, 8($t 2) F D E M W Branch fetch in cycle 3, decode in cycle 4, predict always branch and update end of cycle 4, speculatively fetch branch target in cycle 5 Branch Taken case How and when do we know where to branch? Require Branch Target address calculation in ID stage Can you do Branch Target address calculation in Fetch?
Branches resolve in Exec (Compare in Exec, Branch in Exec), with forwarding enabled and no delay slots Assume predict always branch lw $t 1, 8($t 2) add $t 4, $t 5, $t 6 1 2 3 4 5 F D E M W F D E M W F D E M beq $t 1, $t 4, tgt add $t 1, $t 3, $t 2 F add $t 5, $t 1, $t 4 add $t 3, $t 2, $t 4 tgt: lw $t 1, 8($t 2) Branch Not Taken case F 6 7 8 9 10 11 12 13 14 15 16 17 18 19 Comments Cycle 5, forward $t 1 and $t 4 Assume no branch. Execute speculatively. W
- Slides: 10