Datapath Design IIExecuting JumpsStage Computation: JumpsExecuting callStage Computation: callExecuting retStage Computation: retComputation StepsComputation StepsComputed ValuesSEQ HardwareSummaryDatapath Design IIIFetch LogicFetch LogicFetch Control Logic in HCLFetch Control LogicDecode LogicA SourceE DestinationExecute LogicALU A InputALU OperationMemory LogicInstruction StatusMemory AddressMemory ReadPC Update LogicPC UpdateSEQ OperationSEQ Operation #2SEQ Operation #3SEQ Operation #4SEQ Operation #5SEQ Summary1Datapath Design IITopicsControl flow instructionsHardware for sequential machine (SEQ)Systems I2Executing JumpsFetchRead 5 bytesIncrement PC by 5DecodeDo nothingExecuteDetermine whether to take branch based on jump condition and condition codesMemoryDo nothingWrite backDo nothingPC UpdateSet PC to Dest if branch taken or to incremented PC if not branchjXX Dest 7fn DestXX XXfall thru:XX XXtarget:Not takenTaken3Stage Computation: JumpsCompute both addressesChoose based on setting of condition codes and branch conditionjXX Desticode:ifun M1[PC]valC M4[PC+1]valP PC+5FetchRead instruction byteRead destination addressFall through addressDecodeBch Cond(CC,ifun)ExecuteTake branch? Memory Writeback PC Bch ? valC : valPPC updateUpdate PC4Executing callFetchRead 5 bytesIncrement PC by 5DecodeRead stack pointerExecuteDecrement stack pointer by 4MemoryWrite incremented PC to new value of stack pointerWrite backUpdate stack pointerPC UpdateSet PC to Destcall Dest 8 0DestXX XXreturn:XX XXtarget:5Stage Computation: callUse ALU to decrement stack pointerStore incremented PCcall Desticode:ifun M1[PC]valC M4[PC+1]valP PC+5FetchRead instruction byteRead destination address Compute return pointvalB R[%esp]DecodeRead stack pointervalE valB + –4ExecuteDecrement stack pointerM4[valE] valP MemoryWrite return value on stack R[%esp] valE WritebackUpdate stack pointer PC valCPC updateSet PC to destination6Executing retFetchRead 1 byteDecodeRead stack pointerExecuteIncrement stack pointer by 4MemoryRead return address from old stack pointerWrite backUpdate stack pointerPC UpdateSet PC to return addressret 9 0XX XXreturn:7Stage Computation: retUse ALU to increment stack pointerRead return address from memoryreticode:ifun M1[PC] FetchRead instruction byte valA R[%esp]valB R[%esp]DecodeRead operand stack pointerRead operand stack pointervalE valB + 4ExecuteIncrement stack pointervalM M4[valA] MemoryRead return addressR[%esp] valE WritebackUpdate stack pointer PC valMPC updateSet PC to return address8Computation StepsAll instructions follow same general patternDiffer in what gets computed on each stepOPl rA, rBicode:ifun M1[PC]rA:rB M1[PC+1] valP PC+2FetchRead instruction byteRead register byte[Read constant word]Compute next PCvalA R[rA]valB R[rB]DecodeRead operand ARead operand BvalE valB OP valASet CCExecutePerform ALU operationSet condition code register Memory[Memory read/write] R[rB] valE WritebackWrite back ALU result[Write back memory result] PC valPPC updateUpdate PCicode,ifunrA,rBvalCvalPvalA, srcAvalB, srcBvalECond codevalMdstEdstMPC9Computation StepsAll instructions follow same general patternDiffer in what gets computed on each stepcall DestFetchDecodeExecuteMemoryWritebackPC updateicode,ifunrA,rBvalCvalPvalA, srcAvalB, srcBvalECond codevalMdstEdstMPCicode:ifun M1[PC]valC M4[PC+1]valP PC+5valB R[%esp]valE valB + –4M4[valE] valP R[%esp] valE PC valCRead instruction byte[Read register byte]Read constant wordCompute next PC[Read operand A]Read operand BPerform ALU operation[Set condition code reg.][Memory read/write] [Write back ALU result]Write back memory resultUpdate PC10Computed ValuesFetchicode Instruction codeifun Instruction functionrA Instr. Register ArB Instr. Register BvalC Instruction constantvalP Incremented PCDecodesrcA Register ID AsrcB Register ID BdstE Destination Register EdstM Destination Register MvalA Register value AvalB Register value BExecutevalE ALU resultBch Branch flagMemoryvalM Value from memory11SEQ HardwareKeyBlue boxes: predesigned hardware blocksE.g., memories, ALUGray boxes: control logicDescribe in HCLWhite ovals: labels for signalsThick lines: 32-bit word valuesThin lines: 4-8 bit valuesDotted lines: 1-bit valuesInstructionmemoryInstructionmemoryPCincrementPCincrementCCCCALUALUDatamemoryDatamemoryNewPCrBdstE dstMALUAALUBMem.controlAddrsrcA srcBreadwriteALUfun.FetchDecodeExecuteMemoryWrite backdata outRegisterfileRegisterfileA BMERegisterfileRegisterfileA BMEBchdstE dstM srcA srcBicode ifun rAPCvalC valPvalBvalADatavalEvalMPCnewPC12SummaryTodayControl flow instructionsHardware for sequential machine (SEQ)Next timeControl logic for instruction executionTiming and clocking13Datapath Design IIITopicsControl logic for instruction executionTiming and clockingSystems I14Fetch LogicPredefined BlocksPC: Register containing PCInstruction memory: Read 6 bytes (PC to PC+5)Split: Divide instruction byte into icode and ifunAlign: Get fields for rA, rB, and valCInstructionmemoryInstructionmemoryPCincrementPCincrementrBicode ifun rAPCvalC valPNeedregidsNeedvalCInstrvalidAlignAlignSplitSplitBytes 1-5Byte 015Fetch LogicControl LogicInstr. Valid: Is this instruction valid?Need regids: Does this instruction have a register byte?Need valC: Does this instruction have a constant word?InstructionmemoryInstructionmemoryPCincrementPCincrementrBicode ifun rAPCvalC valPNeedregidsNeedvalCInstrvalidAlignAlignSplitSplitBytes 1-5Byte 016Fetch Control Logic in HCL# Determine instruction codeint icode = [imem_error: INOP;1: imem_icode;];# Determine instruction functionint ifun = [imem_error: FNONE;1: imem_ifun;];InstructionmemoryInstructionmemoryPCSplitSplitByte 0imem_erroricode ifun17Fetch Control Logicpushl rAA 0rA8jXX Dest7fn Destpopl rAB 0rA8call Dest8 0Destrrmovl rA, rB2 0rA rBirmovl V, rB3 0 8rB Vrmmovl rA, D(rB)4 0rA rB Dmrmovl D(rB), rA5 0rA rB DOPl rA, rB6fn rA rBret 9 0nop 0 0halt 1 0pushl rAA 0rA8pushl rAA 0A 0rA8rA8jXX Dest7fn DestjXX Dest7fn7fn Destpopl rAB 0rA8popl rAB 0B 0rA8rA8call Dest8 0Destcall Dest8 08 0Destrrmovl rA, rB2 0rA rBrrmovl rA, rB2 02 0rA rBrA rBirmovl V, rB3 0 8rB Virmovl V, rB3 03 0 8rB8rB
View Full Document