260 likes | 366 Views
Pipeline Demo CONTROL. WB. WB. M. M. ADD. EX. ADD. ZERO. ALU. RESULT. PC. INSTRUCTION MEMORY. ADDRESS. INSTRUCTION. 1. MUX. 0. 0. MUX. 1. MIPS: 5-Stage Pipeline. PCSrc. EX/MEM. MEM/WB. ID/EX. WB. 0. RegWrite. MemToReg. MUX. CONTROL. Branch. 1. MemRead. MemWrite.
E N D
WB WB M M ADD EX ADD ZERO ALU RESULT PC INSTRUCTION MEMORY ADDRESS INSTRUCTION 1 MUX 0 0 MUX 1 MIPS: 5-Stage Pipeline PCSrc EX/MEM MEM/WB ID/EX WB 0 RegWrite MemToReg MUX CONTROL Branch 1 MemRead MemWrite RegDst ALUOp 4 ALUSrc IF/ID ALUSrc Branch Zero RegWrite << 2 MemRead MemWrite MemToReg REGISTERS READ DATA 1 READ REGISTER 1 / READ DATA 2 READ REGISTER 2 0 DATA MEMORY ADDRESS READ DATA MUX WRITE REGISTER 1 WRITE DATA WRITE DATA ALU CONTROL Sign Extend I[15-0] I[5-0] RegDst I[20-16] ALUOp I[15-11]
ADD PCSrc EX/MEM MEM/WB ID/EX WB WB WB 0 RegWrite MemToReg PC MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID Branch ADD RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[15-0] I[20-16] 0 MUX I[15-11] 1 Stage 1: Instruction Fetch
PCSrc EX/MEM MEM/WB ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ADD Branch ADD RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / PC ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[15-0] I[20-16] 0 MUX I[15-11] 1 Stage 2: Instruction Decode (and Register Fetch)
ADD ZERO ALU RESULT 0 MUX 1 Stage 3: Execute (or ALU Operation) PCSrc MEM/WB EX/MEM ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ALUSrc ADD Branch RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / PC ADDRESS INSTRUCTION READ DATA 2 READ REGISTER 2 0 DATA MEMORY 1 ADDRESS READ DATA MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[15-0] I[5-0] RegDst I[20-16] ALUOp I[15-11]
0 MUX 1 Stage 4: Memory Access (and Branch Resolution) PCSrc EX/MEM MEM/WB ID/EX WB WB WB RegWrite MemToReg CONTROL M M Branch MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ADD Branch ADD Zero RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / PC ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[15-0] I[20-16] 0 MUX I[15-11] 1
1 MUX 0 Stage 5: Write Back PCSrc EX/MEM MEM/WB ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ADD Branch ADD RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / PC ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY ADDRESS READ DATA RESULT MUX WRITE REGISTER 1 WRITE DATA WRITE DATA ALU CONTROL Sign Extend I[15-0] I[20-16] 0 MUX I[15-11] 1
ADD PC Following a Load Instruction – Clock Cycle 1 LW before<1> before<2> before<3> before<4> PCSrc EX/MEM MEM/WB ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID Branch ADD RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[15-0] I[20-16] 0 MUX I[15-11] 1
Following a Load Instruction – Clock Cycle 2 after<1> LW before<1> before<2> before<3> PCSrc EX/MEM MEM/WB ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ADD Branch ADD RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / PC ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[15-0] I[20-16] 0 MUX I[15-11] 1
ADD 0 MUX 1 Following a Load Instruction – Clock Cycle 3 after<2> after<1> LW before<1> before<2> PCSrc MEM/WB EX/MEM ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ALUSrc ADD Branch RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / PC ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[15-0] RegDst I[20-16] ALUOp I[15-11]
Following a Load Instruction – Clock Cycle 4 after<3> after<2> after<1> LW before<1> PCSrc EX/MEM MEM/WB ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ADD Branch ADD Zero RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / PC ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[15-0] I[20-16] 0 MUX I[15-11] 1
1 MUX 0 Following a Load Instruction – Clock Cycle 5 LW after<4> after<3> after<2> after<1> PCSrc EX/MEM MEM/WB ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ADD Branch ADD RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / PC ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY ADDRESS READ DATA RESULT MUX WRITE REGISTER 1 WRITE DATA WRITE DATA ALU CONTROL Sign Extend I[15-0] I[20-16] 0 MUX I[15-11] 1
WB WB M M ADD EX ADD ZERO ALU RESULT PC INSTRUCTION MEMORY ADDRESS INSTRUCTION 1 MUX 0 0 MUX 1 Key Concept 1 – Long Registers to Preserve Each Step’s Results PCSrc EX/MEM MEM/WB ID/EX WB 0 RegWrite MemToReg MUX CONTROL Branch 1 MemRead MemWrite RegDst ALUOp 4 ALUSrc IF/ID ALUSrc Branch Zero RegWrite << 2 MemRead MemWrite MemToReg REGISTERS READ DATA 1 READ REGISTER 1 / READ DATA 2 READ REGISTER 2 0 DATA MEMORY ADDRESS READ DATA MUX WRITE REGISTER 1 WRITE DATA WRITE DATA ALU CONTROL Sign Extend I[15-0] RegDst I[20-16] ALUOp I[15-11]
WB WB M M ADD EX ADD ZERO ALU RESULT PC INSTRUCTION MEMORY ADDRESS INSTRUCTION 1 MUX 0 0 MUX 1 Key Concept 2 – Set Control Signals Once, Use Long Registers to Remember Them from Step to Step PCSrc EX/MEM MEM/WB ID/EX WB 0 RegWrite MemToReg MUX CONTROL Branch 1 MemRead MemWrite RegDst ALUOp 4 ALUSrc IF/ID ALUSrc Branch Zero RegWrite << 2 MemRead MemWrite MemToReg REGISTERS READ DATA 1 READ REGISTER 1 / READ DATA 2 READ REGISTER 2 0 DATA MEMORY ADDRESS READ DATA MUX WRITE REGISTER 1 WRITE DATA WRITE DATA ALU CONTROL Sign Extend I[15-0] RegDst I[20-16] ALUOp I[15-11]
WB WB M M ADD EX ADD ZERO ALU RESULT PC INSTRUCTION MEMORY ADDRESS INSTRUCTION 1 MUX 0 0 MUX 1 Key Concept 3 – Even Remember The Things You Don’t Need Right Away PCSrc EX/MEM MEM/WB ID/EX WB 0 RegWrite MemToReg MUX CONTROL Branch 1 MemRead MemWrite RegDst ALUOp 4 ALUSrc IF/ID ALUSrc Branch Zero RegWrite << 2 MemRead MemWrite MemToReg REGISTERS READ DATA 1 READ REGISTER 1 / READ DATA 2 READ REGISTER 2 0 DATA MEMORY ADDRESS READ DATA MUX WRITE REGISTER 1 WRITE DATA WRITE DATA ALU CONTROL Sign Extend I[15-0] I[20-16] ALUOp I[15-11]
Following a Set of Instructions LW ____,____ SUB ____,____,____ BEQ ____,____,____ ; this branch will not be taken OR ____,____,____ ADD ____,____,____
LW before<1> before<2> before<3> before<4> ADD PC Following a Set of Instructions – Clock Cycle 1 PCSrc EX/MEM MEM/WB ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID Branch ADD RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[15-0] I[20-16] 0 MUX I[15-11] 1
SUB LW before<1> before<2> before<3> ADD PC Following a Set of Instructions – Clock Cycle 2 PCSrc ID/EX EX/MEM MEM/WB WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID Branch ADD RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[15-0] I[20-16] 0 MUX I[15-11] 1
BEQ SUB LW before<1> before<2> ADD ADD PC 0 MUX 1 Following a Set of Instructions – Clock Cycle 3 PCSrc EX/MEM MEM/WB ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ALUSrc Branch RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[15-0] RegDst I[20-16] ALUOp I[15-11]
OR BEQ SUB LW before<1> ADD ADD PC 0 MUX 1 Following a Set of Instructions – Clock Cycle 4 PCSrc EX/MEM ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ALUSrc Branch Zero RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[5-0] I[15-0] RegDst I[20-16] ALUOp I[15-11]
ADD OR BEQ SUB LW ADD ADD PC 1 MUX 0 Following a Set of Instructions – Clock Cycle 5 PCSrc EX/MEM ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ALUSrc Branch Zero RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY ADDRESS READ DATA RESULT MUX WRITE REGISTER 1 WRITE DATA WRITE DATA ALU CONTROL Sign Extend I[5-0] I[15-0] RegDst I[20-16] 0 ALUOp MUX I[15-11] 1
after<1> ADD OR BEQ SUB ADD ADD PC 1 MUX 0 0 MUX 1 Following a Set of Instructions – Clock Cycle 6 PCSrc EX/MEM ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ALUSrc Branch Zero RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY ADDRESS READ DATA RESULT MUX WRITE REGISTER 1 WRITE DATA WRITE DATA ALU CONTROL Sign Extend I[5-0] I[15-0] RegDst I[20-16] ALUOp I[15-11]
after<2> after<1> ADD OR BEQ ADD ADD PC 0 MUX 1 Following a Set of Instructions – Clock Cycle 7 EX/MEM ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ALUSrc Branch Zero RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[5-0] I[15-0] RegDst I[20-16] ALUOp I[15-11]
after<3> after<2> after<1> ADD OR ADD ADD PC 1 MUX 0 Following a Set of Instructions – Clock Cycle 8 EX/MEM ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ALUSrc Branch Zero RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[5-0] I[15-0] RegDst I[20-16] 0 ALUOp MUX I[15-11] 1
after<4> after<3> after<2> after<1> ADD ADD ADD PC 1 MUX 0 Following a Set of Instructions – Clock Cycle 9 EX/MEM ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ALUSrc Branch Zero RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[5-0] I[15-0] RegDst I[20-16] 0 ALUOp MUX I[15-11] 1
PCSrc EX/MEM MEM/WB ID/EX WB WB WB 0 RegWrite MemToReg MUX CONTROL M M Branch 1 MemRead MemWrite EX RegDst ALUOp 4 ALUSrc IF/ID ADD Branch ADD RegWrite << 2 MemRead MemWrite MemToReg REGISTERS INSTRUCTION MEMORY READ DATA 1 READ REGISTER 1 / PC ADDRESS INSTRUCTION ZERO READ DATA 2 READ REGISTER 2 0 ALU DATA MEMORY 1 ADDRESS READ DATA RESULT MUX WRITE REGISTER MUX 1 WRITE DATA 0 WRITE DATA ALU CONTROL Sign Extend I[15-0] I[20-16] 0 MUX I[15-11] 1