Beruflich Dokumente
Kultur Dokumente
Based on slides by David Patterson, University of California, Berkeley, Josep Torrellas and Sarita Adve, University of Illinois at UrbanaChampaign
Outline
Key ideas and simple pipeline (Section A.1) Hazards (Sections A.2 and A.3) Structural hazards Data hazards Control hazards Exceptions (Section A.4) Multicycle operations (Section A.5)
An implementation technique whereby multiple instructions are overlapped in execution Takes advantage of parallelism that exists among the actions needed to execute different instructions The pipeline consists of stages; a pipe stage is called segment Each segment in the pipeline completes a different part of an instruction Different instructions execute simultaneously, each is in a different stage of the pipeline Each instruction step (executed by a pipe stage) takes a machine cycle Throughput: how often an instruction exits the pipeline = # instructions completed/machine cycle Want to balance the time needed to do the work in each stage Ideally, time per instruction = Time per instruction on unpipelined machine Number of pipe stages
CPE 432 Computer Design 3
Pipelining
ALU operations
Two sources: two registers, or register and immediate
3.
Execution /Effective address cycle (EX) Reg-Reg (ALU op): ALU output A op B Reg-Immed (ALU op): ALU output A op Imm memory ref: ALU output A+Imm ; compute address for LD,ST Branch: ALU output NPC+ (Imm << 2) ;address of target cond (A op 0 ) ; op = equal, From NPC = not equal
/* note: no instructions need to do 2 of these operations */ /* note: Imm has word count for branches; need to shift by 2 to get bytes to add to PC */
10
4. Memory Access/Branch Completion Cycle (MEM)/* only for LD,ST,BR Memory access: LMD Mem[ALU output] ;for loads, Load data in LMD Mem[ALU output] B ; for stores
11
4. Memory Access/Branch Completion Cycle (MEM)/* only for LD,ST,BR Branch if (cond) PC ALU output else PC NPC
12
13
Cycle 3
ALU
Cycle 4 Cycle 5
DMem Reg
Cycle 6
Cycle 7
ALU
I n s t r. O r d e r
Ifetch
ALU
Ifetch
Reg
DMem
Reg
ALU
Ifetch
Reg
DMem
Reg
IF1
ID1 IF2
EX1 ID2
MEM1 EX2
WB1 MEM2
WB2
15
Figure A.2 The pipeline can be thought of as a series of data paths shifted in time.
Figure A.18 The data path is pipelined by adding a set of registers, one between each pair of pipe stages
Ensure instructions in different stages of the pipeline do not interfere with one another. At the end of a clock cycle all results from a stage are stored into a register that is used as input to the next stage on the next clock cycle. Carry intermediate results from one stage to another where the source and destination stages may not be directly adjacent.
22
MUXES set depending on instruction type which is set by ID/EX.IR. top MUX: branch or not (ID/EX.NPC or ID/EX.A) bottom MUX: reg-reg ALU or other ( ID/EX.B or other)