您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > lab3复杂流水线实验报告
Lab3复杂流水化实验Experiment1:Tostudythebasicsofforwarding.ForalltheprogramspleaseselectStallDetectionandForwardingshouldbeON.(a)WriteasampleprogramthatforwardsbetweenEXEstageandMEMstageonupperinputoftheALU.Writetheprogrambelowandshowforwardingwitharrow.Testitonthesimulatorandmentionwhatvalueisbeingforwarded.DONOTUSELWINSTRUCTION.Instruction123456789ADDR1,R2,R3IFIDEXEMEMWBSUBR5,R1,R4IFIDEXEMEMWB其中ADD指令中在MEM阶段的ALUout-555(R2+R3)前递到SUB指令的EXE阶段的upperinput。(b)WriteasampleprogramthatforwardsbetweenEXEstageandWBstageonupperinputoftheALU.Writetheprogrambelowandshowforwardingwitharrow.Testitonthesimulatorandmentionwhatvalueisbeingforwarded.DONOTUSELWINSTRUCTION.Instruction123456789ADDR1,R2,R3IFIDEXEMEMWBNOPIFIDEXEMEMWBSUBR5,R1,R4IFIDEXEMEMWB其中ADD指令中在WB阶段的输出555(R2+R3)前递到SUB指令的EXE阶段的upperinput。(c)WriteasampleprogramthatforwardsbetweenEXEstageandMEMstageonlowerinputoftheALU.Writetheprogrambelowandshowforwardingwitharrow.Testitonthesimulatorandmentionwhatvalueisbeingforwarded.DONOTUSELWINSTRUCTION.Instruction123456789ADDR1,R2,R3IFIDEXEMEMWBSUBR5,R4,R1IFIDEXEMEMWB其中ADD指令中在MEM阶段的ALUout-555(R2+R3)前递到SUB指令的EXE阶段的upperinput。(d)WriteasampleprogramthatforwardsbetweenEXEstageandWBstageonlowerinputoftheALU.Writetheprogrambelowandshowforwardingwitharrow.Testitonthesimulatorandmentionwhatvalueisbeingforwarded.DONOTUSELWINSTRUCTION.Instruction123456789ADDR1,R2,R3IFIDEXEMEMWBNOPIFIDEXEMEMWBSUBR5,R4,R1IFIDEXEMEMWB其中ADD指令中在WB阶段的输出555(R2+R3)前递到SUB指令的EXE阶段的upperinput。(e)WriteasampleprogramthatforwardsbetweenMEMstageandWBstage.Writetheprogrambelowandshowforwardingwitharrow.Testitonthesimulatorandmentionwhatvalueisbeingforwarded.Instruction123456789LWR1,0(R2)IFIDEXEMEMWBSWR3,0(R1)IFIDEXEMEMWB其中ADD指令在WB阶段的输出555(R2+R3)前递到SW指令的MEM阶段。(f)WriteaprogramthatcausesLoadUseDelayStall.SeewhatdataistobemovedandnoticeexactlywhentherequiredDataispassedontothewaitinginstruction.Showitasanarrowonthefollowingdiagram.Instruction123456789LWR1,0(R3)IFIDEXEMEMWBADDR2,R1,R3IFIDEXEEXEMEMWBBRANCHHAZARDS.(LabExperiment2)(a)Letusnowstudysomebranchhazard.FirstofallmakesurethattheAggressivebranchingoptionisOFF,StallDetectionisONandForwardingisON.SelectAlwaysFlushoptionfromthebranchPolicyandwritethefollowingprogram.Doesthisprogramworkproperly.Ifnotmodifytheprogramsothatitworksproperly.Itfills10memorylocationsmemorywithavalue222.Checkwhatshouldbethevaluesofalltheregistersifthisprogramworkistoproperly(nousefulinstructionturningintoNOPorgettingflushed).CarefullynotetheuseofSLTIinstructioninthefollowingloop.ADDIR3,R0,0ADDIR1,R0,0ADDIR2,R0,222Loop:AddiR1,R1,4SWR2,100(R1)ADDIR3,R3,1SLTIR5,R3,10BNEQR5,R0,loopADDIR7,R1,10ADDIR8,R2,5ADDIR2,R2,100(i)CalculatetheCPIforthisprogram.61/65(ii)Whatchangescanwemaketothisprogramsothatitworksproperly(usefulinstructionsaftertheprogramdonotflush)可以在BNEQ跳转后面加3条ADDR0,R0,R0(iii)RunthesameprogramwithPredictNToptioninBranchPolicy.Whatdifferencedoyouseewhenloopcompletes.PredictNT:循环执行完了顺序执行了剩下3条语句。AlwaysFlush:循环执行完了依然将剩下3条语句flush掉了。(b)ThisproblemissimilartoproblemA-1attheendofthebook.(ExerciseA-1.)Notethatyouneedtocalculatetheoffsetintheactualprogramintermsofnumberofinstructions.Offset=-6(A)ProcessorConfiguration.StallDetectionON.,Forwarding:OFF,AggressiveBranching:YES,BranchPolicy:AlwaysFlush.Runtheaboveprogramandfillthefollowingtablefortheinstructionsintheloopbodyforfirst2or3iterations.TotalClockcyclestoruntheprogram____12345678910111213LWR1,0(R2)IFIDEXEMEMWBADDIR1,R1,#1IFIDIDIDEXEMEMWBSWR1,0(R2)IFIFIFIDIDIDEXEMEMWBADDIR2,R2,#4IFIFIFIDEXEMEMWBSUBR4,R3,R2IFIDIDIDEXEBNEZR4,Loop1IFIFIFIDADDIR2,R0,0IFADDIR3,R0,014151617181920212223242526LWR1,0(R2)IFIDEXEMEMWBADDIR1,R1,#1IFIDIDIDEXEMEMWBSWR1,0(R2)IFIFIFIDIDIDEXEMEMWBADDIR2,R2,#4IFIFIFIDEXEMEMSUBR4,R3,R2MEMWBIFIDIDBNEZR4,Loop1IDIDEXEMEMWBIFIFADDIR2,R0,0FLUSHEDIFIDEXEMEMWBADDIR3,R0,0(b)Redothepart(a)withforwardingONandotherprocessorconfigurationissame.Totalclockcycles___12345678910111213LWR1,0(R2)IFIDEXEMEMWBIFIDEXEMEMADDIR1,R1,#1IFIDEXEEXEMEMWBIFIDEXESWR1,0(R2)IFIDIDEXEMEMWBIFIDADDIR2,R2,#4IFIFIDEXEMEMWBIFSUBR4,R3,R2IFIDEXEMEMWBBNEZR4,Loop1IFIDIDEXEMEMWBADDIR2,R0,0IFIFIDEXEMEMWBADDIR3,R0,014151617181920212223242526LWR1,0(R2)WBIFIDEXEMEMWBADDIR1,R1,#1EXEMEMWBIFIDEXEEXEMEMWBSWR1,0(R2)IDEXEMEMWBIFIDIDEXEMEMWBADDIR2,R2,#4IFIDEXEMEMWBIFIFIDEXEMEMSUBR4,R3,R2IFIDEXEEXEWBIFIDEXEBNEZR4,Loop1IFIDIDEXEMEMWBIFIDADDIR2,R0,0IFIFIDEXEMEMWBIFADDIR3,R0,0实验心得:通过本次实验,我更加深刻的理解了流水线中的前递技术的实现,以及不同类型的指令在不同的阶段前递,方式也不同。同时,我对branch指令数据冒险的解决也有了一个更加清晰的认识,branch类型主要通过循环内改写和循环展开这两种方式,通过不同的实例,清楚地知道不同情况下考虑策略的不同。通过实验,更加清晰的理解了课上的理论内容,也对复杂流水化有了一个更加全面系统的认知,收获很大。
本文标题:lab3复杂流水线实验报告
链接地址:https://www.777doc.com/doc-4946823 .html