Presentation on theme: "CMPE 421 Advanced Parallel Computer Architecture Pipeline datapath and Control."— Presentation transcript:
CMPE 421 Advanced Parallel Computer Architecture Pipeline datapath and Control
A Pipeline Datapath Revised: Single Cycle Datapath
An Instruction is divided into five pipelined stages. This means that five instructions will be in execution during any single cycle. For this reason we must separate the datapath into 5 pieces 1.Instruction Fetch 2.Instruction Decode/ Register Fetch 3.ALU Operation 4.Data Memory access 5.Write result into register Instruction Pipelining
Instructions and data move from left to right through these five stages as the complete the executuion However, there are two exceptions to this left to right flow of instructions – The write back stage in which the result is written back into the register file – Selecting the next value of the PC, choosing between the incremented PC and the branch address
LW instruction for pipelined Datapath To maintain proper time order, this stylized datapath breaks the register ﬁle into two logical parts: registers read during register fetch (ID) and registers written during write back (WB). This dual use is represented by drawing the unshaded left half of the register ﬁ le using dashed lines in the ID stage, when it is not being written, and the unshaded right half in dashed lines in the WB stage, when it is not being read. As before, we assume the register ﬁ le is written in the ﬁrst half of the clock cycle and the register ﬁ le is read during the second half.
The pipeline registers, in color, separate each pipeline stage. The pipeline register is used to pass any information needed in the next pipe stage They are labeled by the stages that they separate; for example, the ﬁrst is labeled IF/ID because it separates the instruction fetch and instruction decode stages. The registers must be wide enough to store all the data corresponding to the lines that go through them. For example, the IF/ID register must be 64 bits wide, because it must hold both the 32-bit instruction fetched from memory and the incremented 32-bit PC address. We will expand these regis ters over the course of this chapter, but for now the other three pipeline registers contain 128, 97, and 64 bits, respectively LW instruction for pipelined Datapath
Memory stage Data memory is read using the address in the EX/MEM pipeline registers, and the data is placed in the MEM/WB pipeline register. Next, data is read from the MEM/WB pipeline register and written into the register ﬁ le in the middle of the datapath.
11 A Bug! When the value read from memory is written back to the register file, the inputs to the register file (write register #) are from a different instruction! To fix the bug we need to save the part of the lw instruction (5 bits of it specify which register should get the value from memory).
The corrected pipeline datapath to properly handle the load instrucution The write register number now comes from the MEM/WB pipeline register along with the data. The register number is passed from the ID pipe stage until it reaches the MEM/WB pipeline register, adding ﬁ ve more bits to the last three pipeline registers.
Pipeline Control Just as control was added to single cycle and multi-cycle implementations we must add it to the pipelined processor Unlike single cycle and multi-cycle, no instruction determines how all the control signals should be set Pipelining the datapath leaves the meaning of control lines unchanged Control signals are pipelined too (grouped by stage) The control unit is combinational again
Implementing Pipeline Control Use a Main Control unit to generate signals during RF/ID Stage – Control signals for EX (ExtOp, ALUSrc, …) used 1 cycle later – Control signals for Mem (MemWr, Branch) used 2 cycles later – Control signals for WB (MemtoReg, MemWr) used 3 cycles later
Assumptions for pipelining the control signals Initial design – motivated by single-cycle datapath control – use the same control signals Observe: – No separate write signal for the PC as it is written every cycle – No separate write signals for the pipeline registers (IF/ID, ID/EX, EX/MEM, MEM/WB), as they are written every cycle – No separate read signal for instruction memory as it is read every clock cycle – No separate read signal for register file as it is read every clock cycle Need to set control signals during each pipeline stage Since control signals are associated with components active during a single pipeline stage, can group control lines into five groups according to pipeline stage Will be modified by hazard detection unit!!