您好,欢迎访问三七文档
CS1104–ComputerOrganizationPART2:ComputerArchitectureLecture5Single-CycleControlandDatapath2TopicsBuildingadatapathsupportasubsetoftheMIPS-Iinstruction-setAsinglecycleprocessordatapathallinstructionactionsinone(long)cycleAmulticycleprocessordatapatheachinstructionstakesmultiple(shorter)cyclesControl:microprogramming3TheMIPSInstructionFormatsAllMIPSinstructionsare32bitslong.Thethreeinstructionformats:R-typeI-typeJ-typeThedifferentfieldsare:op:operationoftheinstructionrs,rt,rd:thesourceanddestinationregisterspecifiersshamt:shiftamountfunct:selectsthevariantoftheoperationinthe“op”fieldaddress/immediate:addressoffsetorimmediatevaluetargetaddress:targetaddressofthejumpinstructionoptargetaddress026316bits26bitsoprsrtrdshamtfunct0611162126316bits6bits5bits5bits5bits5bitsoprsrtimmediate0162126316bits16bits5bits5bits4DatapathandControlDatapathControlRegistersMemoriesMultiplexorsBusesALUsFSMorMicro-programming5We'rereadytolookatanimplementationoftheMIPSSimplifiedtocontainonly:memory-referenceinstructions:lw,swarithmetic-logicalinstructions:add,sub,and,or,sltcontrolflowinstructions:beq,jGenericImplementation:usetheprogramcounter(PC)tosupplyinstructionaddressgettheinstructionfrommemoryreadregistersusetheinstructiontodecideexactlywhattodoAllinstructionsusetheALUafterreadingtheregistersWhy?memory-reference?arithmetic?controlflow?TheProcessor:Datapath&Control6Abstract/SimplifiedView:Twotypesoffunctionalunits:elementsthatoperateondatavalues(combinational)elementsthatcontainstate(sequential)MoreImplementationDetailsRegistersRegister#DataRegister#DatamemoryAddressDataRegister#PCInstructionALUInstructionmemoryAddress7Unclockedvs.ClockedClocksusedinsynchronouslogicwhenshouldanelementthatcontainsstatebeupdated?cycletimerisingedgefallingedgeStateElements8Theset-reset(SR)latchoutputdependsonpresentinputsandalsoonpastinputsAnunclockedstateelementRSQQTruthtable:RSQ00Q01110011?statechange9Outputisequaltothestoredvalueinsidetheelement(don'tneedtoaskforpermissiontolookatthevalue)Changeofstate(value)isbasedontheclockLatches:whenevertheinputschange,andtheclockisassertedFlip-flop:statechangesonlyonaclockedge(edge-triggeredmethodology)Aclockingmethodologydefineswhensignalscanbereadandwritten—wouldn'twanttoreadasignalatthesametimeitwasbeingwrittenLatchesandFlip-flops10Twoinputs:thedatavaluetobestored(D)theclocksignal(C)indicatingwhentoread&storeDTwooutputs:thevalueoftheinternalstate(Q)andit'scomplementD-latchQCD_QDCQ11Dflip-flopOutputchangesonlyontheclockedgeQQ_QQ_QDlatchDCDlatchDDCCDCQ12OurImplementationAnedgetriggeredmethodologyTypicalexecution:readcontentsofsomestateelements,sendvaluesthroughsomecombinationallogic,writeresultstooneormorestateelementsClockcycleStateelement1CombinationallogicStateelement2133-ported:onewrite,tworeadportsRegisterFileReadreg.#1Readreg.#2Writereg.#Readdata1Readdata2WriteWritedata14Registerfile:readportsMuxRegister0Register1Registern–1RegisternMuxReaddata1Readdata2Readregisternumber1Readregisternumber2Implementationofthereadports•RegisterfilebuiltusingDflip-flops15Registerfile:writeportNote:westillusetherealclocktodeterminewhentowriten-to-1decoderRegister0Register1Registern–1CCDDRegisternCCDDRegisternumberWriteRegisterdata01n–1n16SimpleImplementationIncludethefunctionalunitsweneedforeachinstructionWhydoweneedthisstuff?PCInstructionmemoryInstructionaddressInstructiona.Instructionmemoryb.ProgramcounterAddSumc.AdderALUcontrolRegWriteRegistersWriteregisterReaddata1Readdata2Readregister1Readregister2WritedataALUresultALUDataDataRegisternumbersa.Registersb.ALUZero55531632Signextendb.Sign-extensionunitMemReadMemWriteDatamemoryWritedataReaddataa.DatamemoryunitAddress17IncrementingtheProgramCounter(PC)PCInstructionmemoryReadaddressInstruction4AddFetchinginstructionsandincrementingthePC18DatapathforR-typeInstructionsInstructionRegistersWriteregisterReaddata1Readdata2Readregister1Readregister2WritedataALUresultALUZeroRegWriteALUoperation3oprsrtrdshamtfunct0611162126316bits6bits5bits5bits5bits5bitsR-type19DatapathforLoad/StoreInstructionsInstruction1632RegistersWriteregisterReaddata1Readdata2Readregister1Readregister2DatamemoryWritedataReaddataWritedataSignextendALUresultZeroALUAddressMemReadMemWriteRegWriteALUoperation3oprsrtimmediate0162126316bits16bits5bits5bits20DatapathforBranchInstructionsTheALUisusedtoevaluatethebranchconditionandaseparateadderisusedtocomputethebranchtargetaddressasthesumoftheincrementedPCandthesign-extendedlower16bitsoftheinstructionshiftedleftby2bits1632SignextendZeroALUSumShiftleft2TobranchcontrollogicBranchtargetPC+4frominstructiondatapathInstructionAddRegistersWriteregisterReaddata1Readdata2Readregister1Readregister2WritedataRegWriteALUoperation321CombiningDatapathsforMemory&R-typeInstructionsInstructionRegistersWriteregisterReaddata1Readdata2Readregister1Readregister2WritedataALUresultALUZeroRegWriteALUoperation3Instruction1632RegistersWriteregisterReaddata1Readdata2Readregister1Readregister2DatamemoryWritedataReaddataWritedataSigne
本文标题:art-II-Lecture-5-Single-cycle-control-and-datapath
链接地址:https://www.777doc.com/doc-5331876 .html