Pipeline Control Hazards!and Instruction Variations"Hakim&Weatherspoon&CS&3410,&Spring&2011&Computer)Science)Cornell)University)See)P&H)Appendix)4.8)&)2.16)and)2.17))2)Announcements"PA1$available:$mini.MIPS$processor$PA1)due)next)Friday)Work)in)pairs)Use)your)resou rces )• FAQ,)class)notes,)book,)SecGons,)office)hours,)newsgroup,)CSUGLab))Prelims:))• Thursday,)March)10th)in)class)• Thursday,)April)28th)Evening)))3)Goals for Today"Recap:)Data)Hazards)• Data)dependencies)• Problem,)detecGon,)and)soluGons))(delaying,)stalling,)forwarding,)bypass,)etc))Control)Hazards)• What)is)the)next)instrucGon)to)execute)if)a)branch)is)taken?))Not)taken?)InstrucGon)VariaGons)• sdf))4)Data Hazard Recap"Delay)Slot(s))• Modify)ISA)to)match)implementaGon))Stall)• Pause)current)and)all)subsequent)instrucGons))Forward/Bypass)• Try)to)steal)correct)value)from)elsewhere)in)pipeline)• Otherwise,)fall)back)to)stalling)or)require)a)delay)slot))Tradeoffs?)5)More Hazards"beq)r1,)r2,)L)add)r3,)r0,)r3)sub)r5,)r4,)r6)L:)or)r3,)r2,)r4)data)mem)inst)mem)D)B)A)PC#+4#6)More Hazards"beq)r1,)r2,)L)add)r3,)r0,)r3)sub)r5,)r4,)r6)L:)or)r3,)r2,)r4)data)mem)inst)mem)D)B)A)PC#+4#7)Control Hazards"Control)Hazards)• instrucGons)are)fetched)in)stage)1)(IF))• branch)and)jump)decisions)occur)in)stage)3)(EX)))• i.e.)next)PC)is)not)known)unGl)2)cycles)afer)branch/jump))Delay)Slot)• ISA)says)N)instrucGons)afer)branch/jump)always)executed)– MIPS)has)1)branch)delay)slot))Stall)(+)Zap))• prevent)PC)update)• clear)IF/ID)pipeline)register)– instrucGon)just)fetched)might)be)wrong)one,)so)convert)to)nop)• allow)branch)to)conGnue)into)EX)stage)8)Delay Slot"beq)r1,)r2,)L)ori)r2,)r0,)1)L:)or)r3,)r1,)r4)data)mem)inst)mem)D)B)A)PC#+4#branch)calc)decide)branch)9)Control Hazards: Speculative Execution"Control)Hazards)• instrucGons)are)fetched)in)stage)1)(IF))• branch)and)jump)decisions)occur)in)stage)3)(EX)))• i.e.)next)PC)not)known)unGl)2)cycles)afer)branch/jump)Stall)Delay)Slot)SpeculaGve)ExecuGon)• Guess)direcGon)of)the)branch)– Allow)instrucGons)to)move)through)pipeline)– Zap)them)later)if)wrong)guess)• Useful)for)l o ng)pipelines))10)Loops"11)Branch Prediction"12)Pipelining: What Could Possibly Go Wrong?"Data)hazards)• register)file)reads)occur)in)stage)2)(IF)))• register)file)writes)occur)in)stage)5)(WB))• next)instrucGons)may)read)values)soon)to)be)wrilen))Control)hazards)• branch)instrucGon)may)change)the)PC)in)stage)3)(EX))• next)instrucGons)have)already)started)execuGng))Structural)hazards)• resource)contenGon)• so)far:)impossible)because)of)ISA)and)pipeline)design))13)Variations"More)shifs)14)Variations"CondiGon)flags)15)Variations"CondiGon)flags)16)Variations"CondiGonal)instrucGons)top:##CMP#r3,#r4## #SUBGT#r3,#r3,#r4## #SUBLT#r4,#r4,#r3##
View Full Document