版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
UsingWinMIPS64SimulatorASimpleTutorialThisexerciseintroducesWinMIPS64,aWindowsbasedsimulatorofapipelinedimplementationoftheMIPS6464-bitprocessor.1.StartingandconfiguringWinMIPS64StartWinMIPS64fromthetaskbar.Awindow(denotedthemainwindow)appearswithsevenchildwindowsandastatuslineatthebottom.ThesevenwindowsarePipeline,Code,Data,Registers,Statistics,CyclesandTerminal.PipelinewindowThiswindowshowsaschematicrepresentationofthefivepipelinestagesoftheMIPS64processorandtheunitsforfloatingpointoperations(addition/subtraction,multiplicationanddivision).Itshowswhichinstructionisineachstageofthepipeline.CodewindowThiswindowshowsathreecolumnrepresentationofthecodememory,showingfromlefttoright1)abyteaddress,2)ahexnumbergivingthe32-bitmachinecoderepresentationoftheinstruction,and3)theassemblylanguagestatement.Double-left-clickingonaninstructionsetsorclearsbreak-points.DatawindowThiswindowshowsthecontentsofdatamemory,byteaddressable,butdisplayedin64-bitchunks,asappropriatefora64-bitprocessor.Toeditanintegervaluedouble-left-click.Todisplayandeditasafloating-pointnumber,double-right-click.RegisterwindowThiswindowshowsthevaluesstoredintheregisters.Iftheregisterisdisplayedingrey,thenitisintheprocessofbeingwrittentobyaninstruction.Ifdisplayedusingacolour,thecolourindicatesthestageinthepipelinefromwhichthisvalueisavailableforforwarding.Thiswindowallowsyoutointeractivelychangethecontentsofthose64-bitintegerandfloating-pointregistersthatarenotintheprocessofbeingwrittento,orbeingforwarded.Todothis,double-left-clickontheregisteryouwanttochangeandapop-upwindowwillaskyoufornewcontent.PressOKtoconfirmthechange.ClockCyclediagramThiswindowgivesarepresentationofthetimingbehaviourofthepipeline.Itrecordsthehistoryofinstructionsastheyenterandemergefromthepipeline.Aninstructionthatcausesastallishighlightedinblue:instructionsheldupasaresultofastallaregrayed.StatisticsThiswindowprovidesstatisticsonthenumberofsimulationcycles,instructions,theaverageCyclesPerInstruction(CPI),thetypesofstalls,andnumbersofconditionalbranchesandLoad/Store-instructions.TerminalThiswindowmimicsadumbterminalI/Odevicewithsomelimitedgraphicscapability.StatusLineThestatuslineatthebottomnormallydisplays"Ready",butwillduringprogramsimulationprovideusefulinformationonthecurrentstatusofthesimulation.Tomakesurethesimulationisreset,clickontheFilemenuandclickResetMIPS64.WinMIPS64canbeconfiguredinmanyways.Youcanchangethestructureandtimerequirementsofthefloating-pointpipeline,andthecode/datamemorysize.TovieworchangestandardsettingsclickConfigure/Architecture(readthisas:clickConfiguretoopenthemenu,thenclickingonArchitecture)andyouwillseethefollowingsettings:Youcanchangethesettingsbyclickingintheappropriatefieldandeditingthegivennumbers.AnychangestotheFloating-pointlatencieswillbereflectedinthePipelinewindow.TheCodeAddressBusreferstotheactualnumberofwiresintheaddressbus.Soavalueof10meansthat210=1024bytesofcodememorywillbedisplayedintheCodewindow.Whenyouarefinished,clickOKtoreturntothemainwindow.ThreemoreoptionsintheConfigurationmenucanbeselected:Multi-Step,EnableForwarding,EnableBranchTargetBufferandEnableDelaySlot.OftheseEnableForwardingshouldbeenabled,thatis,asmallhookshouldbeshownbesideit.Ifthisisnotthecase,clickontheoption.Youcanchangethesizeand/orpositionofchildwindowsorbringuponlyonewindowusingthemaximiseoptionforthatwindow.2.Loadingatestprogram.Useastandardtexteditortocreatethisfilesum.s,whichisaMIPS64programthatcalculatesthesumoftwointegersAandBfrommemory,andstorestheresultintothememoryonlocationC..dataA:.word10B:.word8C:.word0.textmain:ldr4,A(r0)ldr5,B(r0)daddr3,r4,r5sdr3,C(r0)haltAsmallcommandlineutilityasm.exeisprovidedtotestaprogramforsyntacticalcorrectness.TocheckthisprogramtypeH:>asmsum.sInordertobeabletostartthesimulation,theprogrammustbeloadedintothemainmemory.Toaccomplishthis,selectFile/Open.Alistofassemblerprogramsincurrentdirectoryappearsinawindow,includingsum.s.ToloadthisfileintoWinMIPS64,dothefollowing:Clickonsum.sClicktheOpenbuttonTheprogramisnowloadedintothememoryandthesimulationisreadytobegin.YoucanviewthecontentofcodememoryusingtheCodewindow,andobservetheprogramdataintheDataWindow.3.Simulation3.1Cycle-by-cycleSimulationAtanystageyoucanpressF10torestartthesimulationfromthebeginning.AtthestartyouwillnotethatthefirstlineintheCodewindowwiththeaddress0000iscolouredyellow.TheIFstageinthePipelinewindowisalsocolouredinyellowandcontainstheassemblermnemonicofthefirstinstructionintheprogram.NowinspecttheCodewindowandobservethefirstinstructionldr4,A(r0).LookintheDatawindowtofindtheprogramvariableA.Clock1:PressingExecute/SingleCycle(orsimplypressingF7)advancesthesimulationforonetimesteporoneclocktick;intheCodeWindow,thecolourofthefirstinstructionischangedtoblueandthesecondinstructioniscolouredinyellow.Thesecoloursindicatethepipelinestagetheinstructionisin(yellowforIF,blueforID,redforEX,greenforMEM,andpurpleforWB).IfyoulookintheIFstageinthePipelinewindow,youcanseethatthesecondinstructionldr5,B(r0)isintheIFstageandthefirstinstructionldr4,A(r0)hasadvancedtothesecondstage,ID.Clock2:PressingF7againwillre-arrangethecoloursintheCodewindow,introducingredforthethirdpipelinestageEX.Instructiondaddr3,r4,r5entersthepipeline.Notethatthecolourofaninstructionindicatesthestageinthepipelinethatitwillcompleteonthenextclocktick.Clock3:PressingF7againwillre-arrangethecoloursintheCodewindow,introducinggreenforthefourthpipelinestageMEM.Instructionsdr3,C(r0)entersthepipeline.ObservetheClockCycleDiagramwhichshowsahistoryofwhichinstructionwasineachstagebeforeeachclocktick.Clock4:PressF7again.Eachstageinthepipelineisnowactivewithaninstruction.Thevaluethatwillendupinr4hasbeenreadfrommemory,buthasnotyetbeenwrittenbacktor4.HoweveritisavailableforforwardingfromtheMEMstage.Henceobservethatr4isdisplayedasgreen(thecolourforMEM)intheRegisterswindow.Canyouexplainthevalueofr4?Notethatthelastinstructionhalthasalreadyenteredthepipeline.Clock5:PressF7again.Somethinginterestinghappens.Thevaluedestinedforr5becomesavailableforforwarding.Howeverthevalueforr5wasnotavailableintimeforthedaddr3,r4,r5instructiontoexecuteinEX.SoitremainsinEX,stalled.Thestatuslinereads"RAWstallinEX(R5)",indicatingwherethestalloccurred,andwhichregister'sunavailabilitywasresponsibleforit.ThepictureintheClockCycleDiagramandthePipelinewindowclearlyshowsthatthedaddinstructionisstalledinEX,andthattheinstructionsbehinditinthepipelinearealsounabletoprogress.IntheClockCycleDiagram,thedaddinstructionishighlightedinblue,andtheinstructionsbehindareshowningray.Clock6:PressF7.Thedaddr3,r4,r5instructionexecutesanditsoutput,destinedforr3,becomesavailableforforwarding.Thisvalueis12hex,whichisthesumof10+8=18indecimal.Thisisouranswer.Clock7:PressF7.ThehaltinstructionenteringIFhashadtheeffectof"freezing"thepipeline,sononewinstructionsareacceptedintoit.Clock8:PressF7.ExamineDatamemory,andobservethatthevariableCnowhasthevalue12hex.Thesdr3,C(r0)instructionwroteittomemoryintheMEMstageofthepipeline,usingtheforwardedvalueforr3.Clock9:PressF7.Clock10:PressF7.TheprogramisfinishedLookattheStatisticswindowandnotethattherehasbeenoneRAWstall.10clockcycleswereneededtoexecute5instructions,soCPI=2.Thisisartificiallyhighduetotheone-offstart-upcostinclockcyclesneededtoinitiallyfillthepipeline.Thestatisticswindowisextremelyusefulforcomparingtheeffectsofchangesintheconfiguration.Letusexaminetheeffectofforwardingintheexample.Untilnow,wehaveusedthisfeature;whatwouldtheexecutiontimehavebeenwithoutforwarding?Toaccomplishthis,clickonConfigure.Todisableforwarding,clickonEnableForwarding(thehookmustvanish).
Repeatthecycle-by-cycleprogramexecution,re-examinetheStatisticswindowandcomparetheresults.NotethattherearemorestallsasinstructionsareheldupinIDwaitingforaregister,andhencewaitingforanearlierinstructiontocompleteWB.Theadvantagesofforwardingshouldbeobvious.3.2OtherexecutionmodesClickonFile/ResetMIPS64.IfyouclickonFile/FullReset,youwilldeletethedatamemory,soyouwillhavetorepeattheprocedureforprogramloading.ClickingonFile/ReloadorF10isahandywaytorestartasimulation.Youcanrunsimulationforaspecifiednumberofcycles.UseExecute/Multicycle...forthis.ThenumberofcyclessteppedthroughcanbechangedviaConfigure/Multi-step.Youcanrunthewholeprogrambyasinglekey-press-pressF4.AlternativelyclickonExecute/Runto.Also,youcansetbreakpoints.PressF10.Tosetabreak-point,double-left-clickontheinstruction,forexampleondaddr3,r4,r5.NowpressF4.TheprogramwillhaltwhenthisinstructionentersIF.Toclearthebreak-point,double-left-clickonthesameinstructionagain.3.3TerminalOutputThesimulatorsupportsasimpleI/Odevice,whichworkslikeasimpledumbterminalscreen,withsomegraphicalcapability.Theoutputofaprogramcanappearonthisscreen.Tooutputtheresultofthepreviousprogram,modifyitlikethis.dataA: .word10B: .word8C: .word0CR: .word320x10000DR: .word320x10008.textmain:ldr4,A(r0)ldr5,B(r0)daddr3,r4,r5sdr3,C(r0)lwur1,CR(r0);ControlRegisterlwur2,DR(r0);DataRegisterdaddir10,r0,1sdr3,(r2);r3output..sdr10,(r1);..toscreenhaltAfterthisprogramisexecutedyoucanseetheresultoftheadditionprintedindecimalontheTerminalwindow.ForamorecompleteexampleoftheI/Ocapabilities,seethetestio.sandhail.sexampleprograms.TheInstructionsetThefollowingassemblerdirectivesaresupported.data-startofdatasegment.text-startofcodesegment.code-startofcodesegment(sameas.text).org<n>-startaddress.space<n>-leavenemptybytes.asciiz<s>-enterszeroterminatedasciistring.ascii<s>-enterasciistring.align<n>-alignton-byteboundary.word<n1>,<n2>..-entersword(s)ofdata(64-bits).byte<n1>,<n2>..-enterbytes.word32<n1>,<n2>..-enters32bitnumber(s).word16<n1>,<n2>..-enters16bitnumber(s).double<n1>,<n2>..-entersfloating-pointnumber(s)where<n>denotesanumberlike24,<s>denotesastringlike"fred",and<n1>,<n2>..denotesnumbersseparatedbycommas.Theintegerregisterscanbereferredtoasr0-r31,orR0-R31,or$0-$31orusingstandardMIPSpseudo-names,like$zeroforr0,$t0forr8etc.Notethatthesizeofanimmediateislimitedto16-bits.Themaximumsizeofanimmediateregistershiftis5bits(soashiftbygreaterthan31bitsisillegal).Floatingpointregisterscanbereferredtoasf0-f31,orF0-F31Thefollowinginstructionsaresupported.Noteregisanintegerregister,fregisafloating-point(FP)register,andimmisanimmediatevalue.lbreg,imm(reg)-loadbytelbureg,imm(reg)-loadbyteunsignedsbreg,imm(reg)-storebytelhreg,imm(reg)-load16-bithalf-wordlhureg,imm(reg)-load16-bithalfwordunsignedshreg,imm(reg)-store16-bithalf-wordlwreg,imm(reg)-load32-bitwordlwureg,imm(reg)-load32-bitwordunsignedswreg,imm(reg)-store32-bitwordldreg,imm(reg)-load64-bitdouble-wordsdreg,imm(reg)-store64-bitdouble-wordl.dfreg,imm(reg)-load64-bitfloating-points.dfreg,imm(reg)-store64-bitfloating-pointhalt-stopstheprogramdaddireg,reg,imm-addimmediatedadduireg,reg,imm-addimmediateunsignedandireg,reg,imm-logicalandimmediateorireg,reg,imm-logicalorimmediatexorireg,reg,imm-exclusiveorimmediateluireg,imm-loadupperhalfofregisterimmediatesltireg,reg,imm-setiflessthanimmediatesltiureg,reg,imm-setiflessthanimmediateunsignedbeqreg,reg,imm-branchifpairofregistersareequalbnereg,reg,imm-branchifpairofregistersarenotequalbeqzreg,imm-branchifregisterisequaltozerobnezreg,imm-branchifregisterisnotequaltozerojimm-jumptoaddressjrreg-jumptoaddressinregisterjalimm-jumpandlinktoaddress(callsubroutine)jalrreg-jumpandlinktoaddressinregisterdsllreg,reg,imm-shiftleftlogicaldsrlreg,reg,imm-shiftrightlogicaldsrareg,reg,imm-shiftrightarithmeticdsllvreg,reg,reg-shiftleftlogicalbyvariableamountdsrlvreg,reg,reg-shiftrightlogicalbyvariableamountdsravreg,reg,reg-shiftrightarithmeticbyvariableamountmovzreg,reg,reg-moveifregisterequalszeromovnreg,reg,reg-moveifregisternotequaltozeronop-nooperationandreg,reg,reg-logicalandorreg,reg,reg-logicalorxorreg,reg,reg-logicalxorsltreg,reg,reg-setiflessthansltureg,reg,reg-setiflessthanunsigneddaddreg,reg,reg-addintegersdaddureg,reg,reg-addintegersunsigneddsubreg,reg,reg-subtractintegersdsubureg,reg,reg-subtractintegersunsigneddmulreg,reg,reg-signedintegermultiplicationdmulureg,reg,reg-unsignedintegermultiplicationddivreg,reg,reg-signedintegerdivisionddivureg,reg,reg-unsignedintegerdivisionadd.dfreg,freg,freg-addfloating-pointsub.dfreg,freg,freg-subtractfloating-pointmul.dfreg,freg,freg-multiplyfloating-pointdiv.dfreg,freg,freg-dividefloating-pointmov.dfreg,freg-movefloating-pointcvt.d.lfreg,freg-convert64-bitintegertoadoubleFPformatfreg,freg-convertdoubleFPtoa64-bitintegerformatfreg,freg-setFPflagiflessthanfreg,freg-setFPflagiflessthanorequaltoc.eq.dfreg,freg-setFPflagifequaltobc1fimm-branchtoaddressifFPflagisFALSEbc1timm-branchtoaddressifFPflagisTRUEmtc1reg,freg-movedatafromintegerregistertoFPregistermfc1reg,freg-movedatafromFPregistertointegerregisterMemoryMappedI/OareaAddressesofCONTROLandDATAregistersCONTROL:.word320x10000DATA:.word320x10008SetCONTROL=1,SetDATAtoUnsignedIntegertobeoutputSetCONTROL=2,SetDATAtoSignedIntegertobeoutputSetCONTROL=3,SetDATAtoFloatingPointtobeoutputSetCONTROL=4,SetDATAtoaddressofstringtobeoutputSetCONTROL=5,SetDATA+5toxcoordinate,DATA+4toycoordinate,andDATAtoRGBcolourtobeoutputSetCONTROL=6,ClearstheterminalscreenSetCONTROL=7,ClearsthegraphicsscreenSetCONTROL=8,readtheDATA(eitheranintegerorafloating-point)fromthekeyboardSetCONTROL=9,readonebytefromDATA,nocharacterecho.NotesonthePipelineSimulationThepipelinesimulationattemptstomimicasfaraspossiblethatdescribedinAppendixAofComputerArchitecture:AQuantitativeApproach.Howeverinafe
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 劳动合同法员工离职的规定2024年-
- 转租房屋租赁协议范例
- 房屋建设四邻合作协议
- 房地产开发承包合同
- 房地产项目抵押借款合同
- 房产认购协议书
- 新昌县茶叶种植收购合同汇编
- 2023年高考押题预测卷01浙江卷-生物(原卷版)
- 2023年高考地理第一次模拟考试卷-(天津A卷)(全解全析)
- 2023年高考地理复习精题精练-城镇化(解析版)
- 电动客车驱动桥总成设计
- 四川省阿坝藏族羌族自治州《综合知识》事业单位国考真题
- 2023年人民法院电子音像出版社招聘笔试题库及答案解析
- 大学生心理健康优秀说课-比赛课件
- 收款账户变更的声明
- 九年级道德与法治中考复习资料
- 《化学发展简史》学习心得
- 班组建设与班组长管理技巧课件
- 签派员执照考试题库汇总-8签派和实践应用
- 30屈原《楚辞·橘颂》课件
- 销售人员十大军规课件
评论
0/150
提交评论