Chapter 17 Microprogrammed Control Yonsei University Contents • • • • • 17-2 Basic Concepts Microinstruction Sequencing Microinstruction Execution TI 8800 Applications of Microprogramming Yonsei University Introduction Basic Concepts • An alternative to a hardwired control unit is a microprogrammed control unit(specified by a microprogram) • Microprogrammed control unit – Sequencing through microinstructions – Generating control signals to execute each microinstruction • A control signals are used to cause register transfers and ALU operations • An approach to control unit design that was organized and systematic and avoid the complexities of a hardwired implementation 17-3 Yonsei University Microinstructions Basic Concepts • To implement a control unit as an interconnection of basic logic elements is no easy task • An alternative, which is quite common in contemporary CISC processors, is to implement a microprogrammed control unit • Microprogramming language • Microinstruction – A sequence of instructions is a microprogram, or firmware – Easier to design in firmware than hardware – More difficult to write a firmware than a software 17-4 Yonsei University Microinstructions Basic Concepts • All that the control unit is allowed to do is generate a set of control signals • This condition(either on and off) can be represented by a binary digit for each control line • So we construct a control word in which each bit represents one control line 17-5 Yonsei University Horizontal Microinstruction Basic Concepts • A sequence of control words to represent the sequence of micro-operations • The sequence of micro-operations is not fixed. • Put our control words in a memory(with unique address) • Add an address field to each control word.(the location of the next control word to be executed) • Add a few bits to specify the condition 17-6 Yonsei University Typical Microinstruction Formats Basic Concepts Microinstruction Address Jump Condition Internal CPU Control Signals -Unconditional -Zero System Bus Control Signals -Overflow -Indirect Bit (a) Horizontal Microinstruction Microinstruction Address Function Codes Jump Condition (b) Vertical Microinstruction 17-7 Yonsei University Format of Microinstruction • • • 17-8 Basic Concepts One bit for each internal processor control line One bit for each system bus control line Condition field(to be executed next) Yonsei University Interpretation of Microinstruction Basic Concepts • To execute this microinstruction, turn on all the control lines indicated by a 1 bit; leave off all control lines indicated by a 0 bit. -> one or more micro-operations to be performed • If the condition indicated by the condition bits is false, execute the next microinstruction in sequence • If true, the next microinstruction to be executed is indicated in the address field. 17-9 Yonsei University Organization of Control Memory Basic Concepts Fetch Cycle Routine Jump to Indirect or Execute Indirect Cycle Routine Jump to Execute Jump to Fetch Jump to Opcode Routine Interrupt Cycle Routine Execute Cycle Beginning AND Rou Routine Jump to Fetch or Interrupt ADD Routine Jump to Fetch or Interrupt IOF Routine Jump to Fetch or Interrupt 17-10 Yonsei University Control Memory Basic Concepts • A concise description of the complete operation of the control unit • The sequence of micro-operations to be performed during each cycle (fetch, indirect, execute, interrupt) • It specifies the sequencing of these cycles 17-11 Yonsei University Microprogrammed Control Unit Basic Concepts • The control memory contains the set of microinstructions • The control address register contains the address of the next microinstruction to be read • When a microinstruction is read from the control memory, it is transferred to the control buffer register • Reading a microinstruction from the control memory is the same as executing that microinstruction 17-12 Yonsei University Control Unit Microarchitecture 17-13 Basic Concepts Yonsei University Control Unit Functions • • • • • 17-14 Basic Concepts To execute an instruction sequencing logic unit issues a READ command to the control memory The word whose address is specified in the control address register is read into the control buffer register The content of the control buffer register generates control signals and next-address information for the sequencing logic unit The sequencing logic unit loads a new address into the control address register based on the nextaddress information from the control buffer register and the ALU flags All this happens during one clock pulse Yonsei University Three Decisions Basic Concepts • Depending on the value of ALU flags and the control register, one of the three decisions are made • Get the next instruction – Add 1 to the control address register • Jump to a new routine based on a jump microinstruction – Load the address field of the control buffer register into the control address register • Jump to a machine instruction routine – Load the control address register based on the opcode in the IR 17-15 Yonsei University Functioning of MCU 17-16 Basic Concepts Yonsei University Decoder Basic Concepts • The upper decoder – Translate the opcode of the IR into a control memory address • The lower decoder – Used for vertical microinstructions (not for horizontal microinstructions) • The advantage of vertical microinstruction – More compact (fewer bits) at the expense of a small additional amount of logic and time delay 17-17 Yonsei University Wilkes’s Control Unit 17-18 Basic Concepts Yonsei University Wilkes Control Basic Concepts • Matrix partially filled with diodes • During a machine cycle, one row of the matrix is activated with a pulse • This generates signals at those points where a diode is present • Each row of the matrix is one microinstruction, and the layout of the matrix is the control memory 17-19 Yonsei University Wilkes Control Basic Concepts • The difference with horizontal microprogramming – In the previous description, the control address register could be incremented by one to get the next address – The next address is contained in the microinstruction – To permit branching, a row must contain two address parts, controlled by a conditional signal 17-20 Yonsei University Wilkes Control Basic Concepts • The processor of the hypothetical machine includes the following registers – – – – A : multiplicand B : accumulator(least-significant half) C : accumulator(most-significant half) D : shift register • Three registers – E : serves as both a MAR and temporary storage – F : program counter – G : another temporary register; used for counting 17-21 Yonsei University Machine Instruction Set for Wilkes Order Effect of order An Sn Hn Vn Tn Un Rn Ln Gn In On C(Acc) + C(n) to Acc1 C(Acc) – C(n) to Acc1 C(n) to Acc2 C(Acc2) × C(n) to Acc, where C(n) ≥ 0 C(Acc1) to n, 0 to Acc C(Acc1) to n C(Acc) × to Acc − ( n +1) C(Acc) × 2 to Acc Basic Concepts n +1 IF C(Acc) < 0,2transfer control to n; if C(Acc) ≥ 0, ignore(I.e.,proceed serially) Read next character on input mechanism into n Send C(n) to out put mechanism Notation Acc = accumulator Acc1 = most significant half of accumulator Acc2 = least significant half of accumulator n = storage location n C(X) = contents of X (X = register or storage location) 17-22 Yonsei University Microinstruction for Wilkes 17-23 Basic Concepts Yonsei University Microinstruction for Wilkes 17-24 Basic Concepts Yonsei University Microinstruction for Wilkes The action of The address of each micro- to be taken by the ALU instruction 17-25 Basic Concepts The action of the setting the using address of the to be taken by of the two of the two next microthe control unit flag(flip-flop)flag(filp-flop) instruction to be fetch Yonsei University Microinstruction for Wilkes Basic Concepts • Column 1 – The address of each micro-instruction • Column 2 – The actions to be taken by the ALU • Column 3 – The actions to be taken by the control unit • Column 4 – specifies the signal that sets the flag • Column 5 – use of the two flags(flip-flop) • Columns 6 and 7 – The address of the next microinstruction to be fetched 17-26 Yonsei University Advantages and Disadvantages Basic Concepts • Advantages – Simplifies the design of the control unit • Cheaper and less error-prone to implement – The decoders and sequencing logic unit of a microprogrammed control unit are very simple pieces of logic • Disadvantages – Slower than a hardwired unit of comparable technology 17-27 Yonsei University Advantages and Disadvantages Basic Concepts • Despite this, microprogramming is the dominant technique for implementing control units in contemporary CISC, due to its ease of implementation • RISC processors typically use hardwired control units 17-28 Yonsei University Design Consideration Microinstruction Sequencing • The two basic task(microprogrammed control unit) – Microinstruction sequencing : Get the next microinstruction from the control memory – Microinstruction execution : Generate the control signals needed to execute the microinstruction • Design Consideration – The address of the next microinstruction to be executed • Determined by instruction register – occurs once per instruction cycle • Next sequential address – most common • Branch – necessary part of a microprogram 17-29 Yonsei University Sequencing Techniques Microinstruction Sequencing • Condition flags, the contents of the instruction register and a control memory address must be generated for the next microinstruction • Based on the format of the address information – Two address fields – Single address field – Variable format 17-30 Yonsei University Two Address Fields Microinstruction Sequencing • The simplest approach is to provide two address fields in each microinstruction • A multiplexer is provided that serves as a destination for both address fields plus the instruction register • This scheme requires more bits in the microinstruction than other approaches 17-31 Yonsei University BCL Two Address Fields 17-32 Microinstruction Sequencing Yonsei University Single Address Field Microinstruction Sequencing • A common approach is to have a single address field – Options for next address are as follows • Address field • Instruction register code • Next sequential address • The address-selection signals determine which option is selected – Reduces the number of address fields to one – The address field often will not be used – There is some inefficiency in the microinstruction coding scheme 17-33 Yonsei University BCL Single Address Field 17-34 Microinstruction Sequencing Yonsei University Variable Format Microinstruction Sequencing • Two entirely different microinstruction formats – The first format • The next address is either the next sequential address or an address derived from the instruction register – The second format • Either a conditional or unconditional branch is being specified – One disadvantage of this approach is that one entire cycle is consumed with each branch microinstruction 17-35 Yonsei University BCL Variable Format 17-36 Microinstruction Sequencing Yonsei University Address Generation Microinstruction Sequencing • Various address-generation techniques – Explicit – Implicit • Conditional branch instruction depends on the following information – ALU flags – Part of the opcode or address mode fields of the machine instruction – Parts of a selected register, such as the sign bit – Status bits within the control unit 17-37 Yonsei University Variable Address Generation 17-38 Microinstruction Sequencing Explicit Implicit Two-field Unconditional branch Conditional branch Mapping Addition Residual control Yonsei University IBM 3033 Control Address Register BA (8) BB (4) BD (4) BC (4) 17-39 Microinstruction Sequencing BF (4) BE (4) Yonsei University Address Generation Microinstruction Sequencing • The opcode portion of a machine instruction must be mapped into a microinstruction address • A common implicit technique – One that involves combining or adding two portions of an address to form the complete address – IBM 3033, IBM S/360 – Residual control • The use of a microinstruction address that has previously been saved in temporary storage within the control unit 17-40 Yonsei University LSI-11 Microinstruction Sequencing Microinstruction Sequencing • Microcomputer version of a PDP-11 • Use a 22-bit microinstruction and a control memory of 2K22-bit words 17-41 Yonsei University LSI-11 Microinstruction Sequencing Microinstruction Sequencing • The next microinstruction address is determined in one of five ways – Next sequential address : In the absence of other instructions, the control unit’s control address register is incremented by 1 – Opcode mapping : At the beginning of each instruction cycle, the next microinstruction address is determined by the opcode – Subroutine facility : One level – Interrupt testing : Certain microinstructions specify a test for interrupts. If an interrupt has occurred, this determines the next microinstruction address – Branch : Conditional and unconditional branch microinstructions are used 17-42 Yonsei University Microinstruction Execution Microinstruction Execution • The microinstruction cycle is the basic event • Each cycle is made up of two cycle – Fetch and execute • This section deals with the execution of a microinstruction 17-43 Yonsei University Control Unit Organization 17-44 Microinstruction Execution Yonsei University Taxonomy of Microinstruction • • • • 17-45 Microinstruction Execution Vertical/horizontal Packed/unpacked Hard/soft microprogramming Direct/indirect encoding Yonsei University Taxonomy of Microinstruction Microinstruction Execution • We can do better than Wilkes’s scheme if we observe that not all of the possible combinations will be used – Two sources cannot be gated to the same destination – A register cannot be both source and destination C C – Only one pattern of control signals can be presented to the ALU at a time – Only one pattern of control signals can be presented to the external control bus at a time 5 17-46 12 Yonsei University Taxonomy of Microinstruction Microinstruction Execution • Given some number Q < 2 K possibilities – These could be encoded with log 2 Q bits, with ( log 2 Q < K ) – Tightest possible form – not used • It is as difficult to program as a pure decoded (Wilkes) scheme. • It requires a complex and therefore slow control logic module. 17-47 Yonsei University Taxonomy of Microinstruction Microinstruction Execution • Some compromises are made – More bits than are strictly necessary are used to encode the possible combinations – Some combinations that are physically allowable are not possible to encode • Reduce the number of bits • The net result is to use more than log 2 Q bits 17-48 Yonsei University The Microinstruction Spectrum Microinstruction Execution Characteristic Unencoded Many bits Detailed view of hardware Difficult to program Concurrency fully exploited Little or no control logic Fast execution Optimize performance Highly encoded Few bits Aggregated view of hardware Easy to program Concurrency not fully exploited Complex control logic Slow execution Optimize programming Terminology Unpacked Horizontal Hard 17-49 Packed Vertical Soft Yonsei University Taxonomy of Microinstruction Microinstruction Execution • As the bits become more packed, a given number of bits contains more information • The term horizontal and vertical relate to the relative width of microinstructions • The term hard and soft microprogramming are used to suggest the degree of closeness to the underlying control signals and hardware layout – Hard microprograms are generally fixed and committed to read-only memory – Soft microprograms are more changeable and are suggestive of user microprogramming 17-50 Yonsei University Microinstruction Encoding Microinstruction Execution (a) Direct Signals 17-51 Yonsei University Microinstruction Encoding Microinstruction Execution (b) Indirect Encoding 17-52 Yonsei University Microinstruction Encoding Microinstruction Execution • The design of an encoded microinstruction format – Organize the format into independent fields. Each field depicts a set of actions such that actions from different fields can occur simultaneously – Define each field such that the alternative actions that can be specified by the field are mutually exclusive – Only one of the actions specified for a given field could occur at a time 17-53 Yonsei University Microinstruction Encoding Microinstruction Execution • Functional encoding – Identify functions within the machine and designates fields by function type – For example, if various sources can be used for transferring data to the accumulator, one field can be designated for this purpose • Resource encoding – View the machine as consisting of a set of independent resources and devotes one field to each.(e.g., I/O, memory, ALU) 17-54 Yonsei University Microinstruction Encoding Microinstruction Execution • Another aspect of encoding – Whether it is direct or indirect – With indirect encoding, one field is used to determine the interpretation of another field • For example – ALU with eight different arithmetic operation and eight different shift operations – A 1-bit field could be used to indicate whether a shift or arithmetic operation is to be used; a 3-bit field would indicate the operation – This technique generally implies two levels of decoding, increasing propagation delay 17-55 Yonsei University Alternative Microinstruction Formats Microinstruction Execution (a) Vertical Microinstruction Repertoire 17-56 Yonsei University Alternative Microinstruction Formats Microinstruction Execution (b) Horizontal Microinstruction Format 17-57 Yonsei University LSI-11 Microinstruction Execution Microinstruction Execution • LSI-11 Control Unit Organization • LSI-11 Microinstruction Format 17-58 Yonsei University LSI-11 Control Unit Organization Microinstruction Execution • The board contains three LSI chips, an internal bus known as the microinstruction bus(MIB), and some additional interfacing logic • The organization of the LSI-11 processor • The control store chip or chips contain the 22bit-wide control memory • MIB ties all the component together 17-59 Yonsei University Block Diagram of the LSI-11 17-60 Microinstruction Execution Yonsei University Organization of LSI-11 Control Unit 17-61 Microinstruction Execution Yonsei University LSI-11 Microinstruction Execution Microinstruction Execution • The Translation array – The opcode us used to determine the start of a microroutine – At appropriate times, address mode bits of the microinstruction are tested to perform appropriate addressing – Interrupt conditions are periodically tested – Conditional branch microinstructions are evaluated 17-62 Yonsei University Some LSI-11 Microinstruction Arithmetic Operations Microinstruction Execution General Operation Add word (byte, literal) MOV word (byte) Test word (byte, literal) Jump Increment word (byte) by 1 Return Increment word (byte) by 2 Conditional jump Negate word (byte) Set (reset) flags Conditionally increment (decrement) byte Load G low Conditionally add word(byte) Conditionally MOV word (byte) Add word(byte) with carry Input/Output Operations Conditionally add digits Input word (byte) Subtract word(byte) Input status word (byte) Compare word(byte, literal) Read Subtract word(byte) with carry Write Decrement word(byte) by 1 Read (write) and increment word (byte) by 1 Logical Operations Read (write) and increment word (byte) by 2 AND word (byte, literal) Read (write) acknowledge Test word (byte) Output word (byte, status) OR word (byte) Exclusive-OR word (byte) Bit clear word (byte) Shift word (byte) right (left) with (without) carry Complement word (byte) 17-63 Yonsei University LSI-11 Microinstruction Format Microinstruction Execution • LSI uses an extremely vertical microinstruction format, which is only 22 bits wide • Optimize the performance of the control unit within the constraint of a vertical, easily programmed design • The high-order 4bit control special functions on the processor board 17-64 Yonsei University LSI-11 Microinstruction Format Microinstruction Execution (a) Format of the Full LSI-11 Microinstruction 17-65 Yonsei University LSI-11 Microinstruction Format Microinstruction Execution (b) Format of the Encoded Part of the LSI-11 Microinstruction 17-66 Yonsei University IBM 3033 Microinstruction Execution Microinstruction Execution • The Control memory consists of 4K words • The first half of these (0000-07FF) contain 108bit microinstruction • The remainder (0800-0FFF) are used to store 126-bit microinstruction • Although this is a rather horizontal format, encoding is still extensively used • The ALU operates on inputs from four dedicated, non-user-visible registers A, B, C, D 17-67 Yonsei University IBM 3033 Microinstruction Format 17-68 Microinstruction Execution Yonsei University IBM 3033 Control Fields 17-69 Microinstruction Execution Yonsei University Texas Instrument 8800 TI 8800 • The 8800 SDB consists of the following components – – – – – 17-70 Microcode memory Microsequencer 32-bit ALU Floating-point and integer processor Local data memory Yonsei University TI 8800 Block Diagram 17-71 TI 8800 Yonsei University Microinstruction Format TI 8800 • The microinstruction format for the 8800 consists 128 bits broken down into 30 functional fields • The fields are grouped into five major categories – – – – – 17-72 Control of board 8847 floating-point and integer processor chip 8832 registered ALU 8818 microsequencer WCS data field Yonsei University TI 8800 Microinstruction Format 17-73 TI 8800 Yonsei University TI 8800 Microinstruction Format 17-74 TI 8800 Yonsei University Microsequencer TI 8800 • To generate the next microinstruction address for the microprogram • This 15-bit address is provided to the microcode memory • Five source – – – – – 17-75 Microprogram counter(MPC) register Stack DRA and DRB port Register counters RCA and RCB External input onto the bidirectional Y port Yonsei University Microsequencer TI 8800 • Principal functional groups – – – – – 17-76 16-bit microprogram counter(MPC) Two register counters, RCA and RCB 65-word by 16-bit stack Interrupt return register and Y output Y output multiplexer by which the next address can be selected from MPC, RCA, RCB, external buses DRA and DRB, or the stack Yonsei University TI 8800 Microsequencer 17-77 TI 8800 Yonsei University Registers/Counters TI 8800 • Registers RCA and RCB may be loaded from the DA bus • The values may be used as counters to control the flow of execution and may be automatically decremented when accessed 17-78 Yonsei University Stack TI 8800 • The stack allows multiple levels of nested calls or interrupts and it can be used to support branching and looping • Six stack operation are possible – – – – – – 17-79 Clear Pop Push Read Hold Load stack pointer Yonsei University Control of Microsequencer TI 8800 • The microsequencer is controlled by the 12-bit field of the current microinstruction, field 28 • Subfield – – – – – – 17-80 OSEL (1bit) SELDR (1bit) ZEROIN (1bit) RC2-RC0 (3bits) S2-S0 (3bits) MUX2-MUX0 Yonsei University Control of Microsequencer TI 8800 • As an example, the instruction INC88181 is used to cause the next microinstruction in sequence to be selected, If the currently selected condition code is 1 • INC88181 = 000000111110 – Decode directly into • OSEL = 0 • SELDR = 0 • ZEROIN = 0 • R = 000 • S = 111 • MUX = 110 17-81 Yonsei University Microsequencer Microinstruction Bits 17-82 Yonsei University TI 8800 TI 8832 ALU Instruction Field 17-83 TI 8800 Yonsei University TI 8832 ALU Instruction Field 17-84 TI 8800 Yonsei University TI 8832 ALU Instruction Field 17-85 TI 8800 Yonsei University TI 8832 ALU Instruction Field 17-86 TI 8800 Yonsei University TI 8832 ALU Instruction Field 17-87 TI 8800 Yonsei University Applications of Microprogramming Applications of Microprogramming • The set of current applications for microprogramming includes the following – – – – – – – 17-88 Realization of computers Emulation Operating system support Realization of special purpose devices High level language support Microdiagnostics User tailoring Yonsei University