Presentation is loading. Please wait.

Presentation is loading. Please wait.

Exp. 6 Solving Data Hazards. Where to find ALU Result Instruction memory Data memory 1010 PC ALU Registers Rd Rt 0101 IF/IDID/EXEX/MEMMEM/WB.

Similar presentations


Presentation on theme: "Exp. 6 Solving Data Hazards. Where to find ALU Result Instruction memory Data memory 1010 PC ALU Registers Rd Rt 0101 IF/IDID/EXEX/MEMMEM/WB."— Presentation transcript:

1 Exp. 6 Solving Data Hazards

2

3 Where to find ALU Result Instruction memory Data memory 1010 PC ALU Registers Rd Rt 0101 IF/IDID/EXEX/MEMMEM/WB

4 Forwarding

5 Detecting EX/MEM data hazards DM Reg IM DM Reg IM sub$2, $1, $3 and$12, $2, $5 The first ALU source: if (EX/MEM.RegWrite = 1 and EX/MEM.Rd = ID/EX.Rs) and EX/MEM.Rd != 0 ) The second ALU source: if (EX/MEM.RegWrite = 1 and EX/MEM.Rd = ID/EX.Rt) and EX/MEM.Rd != 0 )

6 Detecting MEM/WB data hazards DM Reg IM DM Reg IM DM Reg IM add$1, $2, $3 add$1, $1, $4 sub$5, $5, $1 if (MEM/WB.RegWrite = 1 and MEM/WB.Rd = ID/EX.Rs and (EX/MEM.Rd ≠ ID/EX.Rs) if (MEM/WB.RegWrite = 1 and MEM/WB.Rd = ID/EX.Rt and (EX/MEM.Rd ≠ ID/EX.Rt )

7 Forwarding Unit Inputs: ID/EX.RegisterRs EX/MEM.RegisterRd MEM/WB.RegisterRd ID/EX.RegisterRt EX/MEM.RegWrite MEM/WB.RegWrite Outputs ???

8 Loads

9 Stall

10 Detecting Stalls

11 Implementing Stalls

12 Stores

13 Stores Cont. Forward When: -EX/MEM.MemWrite = 1 ( store operation ) -EX/MEM.Rt = MEM/WB.Rd -MEM/WB.RegWrite = 1

14 Branches addi R1,R1,-1 bne R1, R0, loop Need to Stall If ( EXE/MEM.Rd = IF/ID.Rs or ( EXE/MEM.Rd = IF/ID.Rt ) and ( Operation is Branch ) and ( EXE/MEM.RegWrite = 1 )

15 lui Instruction lui R3, imm add R2, R3, R4


Download ppt "Exp. 6 Solving Data Hazards. Where to find ALU Result Instruction memory Data memory 1010 PC ALU Registers Rd Rt 0101 IF/IDID/EXEX/MEMMEM/WB."

Similar presentations


Ads by Google