Essays /

16 Pipelining Essay

Essay preview

COMP 273 Winter 2012

16 - pipelining

Mar. 13, 2012

Pipelining
Pipelining1 is a different method of multicycle implementation than the microinstruction method discussed last lecture. The goal of pipelining is to reduce the number of stages that are idle in the datapath. In a pipeline, instructions move along the datapath, one stage at a time, through all stages. The PC is updated at every clock cycle. Note that the next instruction begins long before the previous instruction is finished. This creates problems (known as “hazards”) which will be described below.

To keep the pipeline moving along at a uniform speed, each pipeline stage is given the same amount of time (one clock cycle). This is made to be long enough that each pipeline stage can complete in this time.

In a maximally efficient pipeline, one instruction finishes at each clock cycle. To see how this can speed up performance is that, suppose it took time Ts (worst case) for an instruction to complete in a single cycle model. Suppose in a pipelined implementation, the clock cycle was Tp < Ts . (For 5 stages, we would like Tp = T5s but that would only be possible if each stage required the same amount of time. Typically that’s not the case and so Ts > Tp > T5s .) Thus in a maximally efficient pipeline with 5 stages, you can get a speedup of at most a factor 5. (But even a factor 2 speedup in practice would be a huge gain!)

MIPS pipeline: 5 stages
The MIPS pipeline has five stages:
• IF: instruction fetch
• ID: instruction decode and register read
• ALU: ALU execution
• MEM: data memory read or write
• WB: write result back into a register
Because different instructions are present at different stages of the pipeline at any one clock cycle, new registers are needed between each successive stages of the pipeline. These pipeline registers contain all control information that is needed by that instruction. These registers are referred to by the pair of stages:

• IF/ID
• ID/ALU
• ALU/MEM
• MEM/WB
1
There are many familiar examples of “pipelining” in the world: a car wash, a cafeteria, a factory assembly line. For the latter, have a look at a clip from Charlie Chaplin’s Modern Times. But MUTE the volume. It is a silent film. http://www.youtube.com/watch?v=CReDRHDYhk8

1

COMP 273 Winter 2012

16 - pipelining

Mar. 13, 2012

The pipeline registers pass the control signals and other values through the pipeline. Recall the single cycle model. In that model, each of the control variables was given a value that depended on the instruction. These control variables were typically either selector signals for multiplexors, or write enable signals.

The IF/ID pipeline register contains the fetched instruction (one word). The ID/ALU contains the fetched instruction, plus controls that are needed to execute the instruction. (These control signals are available by the end of the ID stage and can be written into the pipeline register there namely the register ID/ALU.) ALU/MEM register contains the controls that are needed to execute the remaining stages of the instruction (MEM, WB), as well as values that were computed in the ALU stage. MEM/WB contains controls needed to execute the WB stage, as well as any data values that need to be written back.

M
U
X
4
PC

RegWrite
ReadReg1
ReadReg2

ReadData1
ReadData2

WriteReg...

Read more

Keywords

+4 /watch?v=credrhdyhk8 0 1 13 16 2 2012 273 3 32 4 40 5 6 7 8 accord add addi addit address along also altern alu alu/mem alu/mem.rd alu/mem.regwrite alusrc1 alusrc2 amount anoth answer argument aris arm asid assembl assumpt avail avoid awar away back becom begin behind beq better branch briefli bubbl cafeteria call car carri case caus chang chaplin charli check clip clobber clock code combin come common comp compil complet complic comput condit condtion consid contain control correct correspond could cours creat current cycl damag data datapath decod dedic default defeat depend describ design detail detect diagram differ difficulti direct discuss divis doesn done e.g easiest effect effici either enabl end enough ensur enter even eventu everi exampl execut fact factor factori familiar fetch figur film finish first five floa float follow forward fpmult1 fpmult2 fpmult6 front function gain general get given goal handl hardwar hazard hold howev huge human i.e id id/alu id/alu.rs id/alu.rt identifi idl if/id imagin implement includ increment inde independ indic inform inher input insert instead instruct interact interpret issu j jal jr judg jump keep key know known label label1 label2 last latter lead least lectur left let like line load long look lw m machin made mani mar maxim mean mem mem/wb mem/wb.rd mem/wb.regwrite memori mention met method microinstruct mind mip model modern move multicycl multipl multiplexor must mute name need never new next nop note noth notic number obey occur omit one op opcod oper origin pair paragraph part particular pass path pc perform pipelin pipelining1 plus point possibl practic present prevent previous problem process processor produc program properti provid purpos put quit rather rd read readdata1 readdata2 readreg1 readreg2 real realli reason recal reduc refer regist regwrit remain reorder replac requir rest result rs rt rule runtim s0 s1 s2 s3 s4 s5 satisfi second see select selector send sequenc sever show signal silent simpl sinc singl situat slide slight smart solut solv sometim specif speed speedup spend stage stall stand step still sub subtl subtract success suffici suppos t0 t1 t2 t3 t5 t5s take taken think though three thus time took topic tp trail trick ts two typic u uncondit uniform unit updat use usual valu variabl visual volum want wash way wb well whether whose winter won word work world worst would write writedata writereg written wrong www.youtube.com www.youtube.com/watch?v=credrhdyhk8 x