Datapath Design IOverviewY86 Instruction SetBuilding BlocksHardware Control LanguageHCL OperationsAn Abstract ProcessorSlide 8SEQ Hardware StructureSEQ StagesInstruction DecodingExecuting Arith./Logical OperationStage Computation: Arith/Log. OpsExecuting rmmovlStage Computation: rmmovlExecuting poplStage Computation: poplSummaryDatapath Design ITopicsTopicsSequential instruction execution cycleInstruction mapping to hardwareInstruction decodingSystems I2OverviewHow do we build a digital computer?How do we build a digital computer?Hardware building blocks: digital logic primitivesInstruction set architecture: what HW must implementPrincipled approachPrincipled approachHardware designed to implement one instruction at a timePlus connect to next instructionDecompose each instruction into a series of stepsExpect that most steps will be common to many instructionsExtend design from thereExtend design from thereOverlap execution of multiple instructions (pipelining)Later in this courseParallel execution of many instructionsIn more advanced computer architecture course3Y86 Instruction SetByte0 1 2 3 4 5pushl rA A 0 rA 8jXX Dest 7 fn Destpopl rA B 0 rA 8call Dest 8 0 Destrrmovl rA, rB 2 0 rA rBirmovl V, rB 3 0 8 rB Vrmmovl rA, D(rB) 4 0 rA rB Dmrmovl D(rB), rA 5 0 rA rB DOPl rA, rB 6 fn rA rBret 9 0nop 0 0halt 1 0addl 6 0subl 6 1andl 6 2xorl 6 3jmp 7 0jle 7 1jl 7 2je 7 3jne 7 4jge 7 5jg 7 64Building BlocksCombinational LogicCombinational LogicCompute Boolean functions of inputsContinuously respond to input changesOperate on data and implement controlStorage ElementsStorage ElementsStore bitsAddressable memoriesNon-addressable registersLoaded only as clock risesRegisterfileRegisterfileABWdstWsrcAvalAsrcBvalBvalWClockALUfunABMUX01=Clock5Hardware Control LanguageVery simple hardware description languageCan only express limited aspects of hardware operationParts we want to explore and modifyData TypesData Types bool: Booleana, b, c, … int: wordsA, B, C, …Does not specify word size---bytes, 32-bit words, …StatementsStatements bool a = bool-expr ; int A = int-expr ;6HCL OperationsClassify by type of value returnedBoolean ExpressionsBoolean ExpressionsLogic Operations a && b, a || b, !aWord ComparisonsA == B, A != B, A < B, A <= B, A >= B, A > BSet Membership A in { B, C, D }»Same as A == B || A == C || A == DWord ExpressionsWord ExpressionsCase expressions [ a : A; b : B; c : C ]Evaluate test expressions a, b, c, … in sequenceReturn word expression A, B, C, … for first successful test7An Abstract ProcessorWhat does a processor do?What does a processor do?Consider a processor that only executes nops.Consider a processor that only executes nops.void be_a_processor(unsigned int pc, unsigned char* mem){ while(1) { char opcode = mem[pc]; assert(opcode == NOP); pc = pc + 1; } }FetchDecodeExecute8An Abstract ProcessorExecutes nops and absolute jumpsExecutes nops and absolute jumpsvoid be_a_processor(unsigned int pc, unsigned char* mem){ while(1) { char opcode = mem[pc]; switch (opcode) { case NOP: pc++; case JMP: pc = *(int*)&mem[(pc+1)];Missing execute and memory access9SEQ Hardware StructureStateStateProgram counter register (PC)Condition code register (CC)Register FileMemoriesAccess same memory spaceData: for reading/writing program dataInstruction: for reading instructionsInstruction FlowInstruction FlowRead instruction at address specified by PCProcess through stagesUpdate program counterInstructionmemoryInstructionmemoryPCincrementPCincrementCCCCALUALUDatamemoryDatamemoryFetchDecodeExecuteMemoryWrite backicode ifunrA , rBvalCRegisterfileRegisterfileA BMERegisterfileRegisterfileA BMEPCvalPsrcA, srcBdstA, dstBvalA, valBaluA, aluBBchvalEAddr, DatavalMPCvalE, valMnewPC10SEQ StagesFetchFetchRead instruction from instruction memoryDecodeDecodeRead program registersExecuteExecuteCompute value or addressMemoryMemoryRead or write dataWrite BackWrite BackWrite program registersPCPCUpdate program counterInstructionmemoryInstructionmemoryPCincrementPCincrementCCCCALUALUDatamemoryDatamemoryFetchDecodeExecuteMemoryWrite backicode ifunrA , rBvalCRegisterfileRegisterfileA BMERegisterfileRegisterfileA BMEPCvalPsrcA, srcBdstA, dstBvalA, valBaluA, aluBBchvalEAddr, DatavalMPCvalE, valMnewPC11Instruction DecodingInstruction FormatInstruction FormatInstruction byte icode:ifunOptional register byte rA:rBOptional constant word valC5 0 rA rB DicodeifunrArBvalCOptionalOptional12Executing Arith./Logical OperationFetchFetchRead 2 bytesDecodeDecodeRead operand registersExecuteExecutePerform operationSet condition codesMemoryMemoryDo nothingWrite backWrite backUpdate registerPC UpdatePC UpdateIncrement PC by 2Why?OPl rA, rB 6fnrA rB13Stage Computation: Arith/Log. OpsFormulate instruction execution as sequence of simple stepsUse same general form for all instructionsOPl rA, rBicode:ifun M1[PC]rA:rB M1[PC+1] valP PC+2FetchRead instruction byteRead register byteCompute next PCvalA R[rA]valB R[rB]DecodeRead operand ARead operand BvalE valB OP valASet CCExecutePerform ALU operationSet condition code register MemoryR[rB] valE WritebackWrite back resultPC valPPC updateUpdate PC14Executing rmmovlFetchFetchRead 6 bytesDecodeDecodeRead operand registersExecuteExecuteCompute effective addressMemoryMemoryWrite to memoryWrite backWrite backDo nothingPC UpdatePC UpdateIncrement PC by 6rmmovl rA, D(rB)4 0rArB D15Stage Computation: rmmovlUse ALU for address computationrmmovl rA, D(rB)icode:ifun M1[PC]rA:rB M1[PC+1]valC M4[PC+2]valP PC+6FetchRead instruction byteRead register byteRead displacement DCompute next PCvalA R[rA]valB R[rB]DecodeRead operand ARead operand BvalE valB + valCExecuteCompute effective address M4[valE] valAMemoryWrite value to memory WritebackPC valPPC updateUpdate PC16Executing poplFetchFetchRead 2 bytesDecodeDecodeRead stack pointerExecuteExecuteIncrement stack pointer by 4MemoryMemoryRead from old stack pointerWrite backWrite backUpdate stack pointerWrite result to registerPC UpdatePC UpdateIncrement PC by 2popl rA b 0 rA 817Stage Computation: poplUse ALU to increment stack pointerMust
View Full Document