Unit 4 The Control Unit: Structure No
Unit 4 The Control Unit: Structure No
Structure
4.0 4.1 4.2 4.3 4.4 4.5 4.6 Introduction Objectives The Control Unit The Hardwired Control Wilkes Control The Micro-Programmed Control The Micro-Instructions
4.6.1 Types of Micro-Instructions 4.6.2 Control Memory Organisation 4.6.3 Micro-Instruction Formats
Page No.
65 65 65 71 72 74 75
78 81 81
4.0 INTRODUCTION
By now we have discussed instruction sets and register organisation followed by a discussion on micro-operations and a simple arithmetic logic unit circuit. We have also discussed the floating point ALU and arithmetic processors, which are commonly used for floating point computations. In this unit we are going to discuss the functions of a control unit, its structure followed by the hardwired type of control unit. We will discuss the microprogrammed control unit, which are quite popular in modern computers because of flexibility in designing. We will start the discussion with several definitions about the unit followed by Wilkes control unit. Finally, we will discuss the concepts involved in micro-instruction execution.
4.1 OBJECTIVES
After going through this unit you will be able to: define what is a control unit and its function; describe a simple control unit organization; define a hardwired control unit; define the micro-programmed control unit; define the term micro-instruction; and identify types and formats of micro-instruction.
making ALU to perform a particular operation on the data regulating other internal operations.
But how does a control unit control the above operations? What are the functional requirements of the control unit? What is its structure? Let us explore answers of these questions in the next sections. Functional Requirements of a Control Unit Let us first try to define the functions which a control unit must perform in order to get things to happen. But in order to define the functions of a control unit, one must know what resources and means it has at its disposal. A control unit must know about the: (a) Basic components of the CPU (b) Micro-operation this CPU performs. The CPU of a computer consists of the following basic functional components: The Arithmetic Logic Unit (ALU), which performs the basic arithmetic and logical operations. Registers which are used for information storage within the CPU. Internal Data Paths: These paths are useful for moving the data between two registers or between a register and ALU. External Data Paths: The roles of these data paths are normally to link the CPU registers with the memory or I/O interfaces. This role is normally fulfilled by the system bus. The Control Unit: This causes all the operations to happen in the CPU.
The micro-operations performed by the CPU can be classified as: Micro-operations for data transfer from register-register, register-memory, I/Oregister etc. Micro- operations for performing arithmetic, logic and shift operations. These micro-operations involve use of registers for input and output.
The basic responsibility of the control unit lies in the fact that the control unit must be able to guide the various components of CPU to perform a specific sequence of microoperations to achieve the execution of an instruction. What are the functions, which a control unit performs to make an instruction execution feasible? The instruction execution is achieved by executing microoperations in a specific sequence. For different instructions this sequence may be different. Thus the control unit must perform two basic functions: Cause the execution of a micro-operation. Enable the CPU to execute a proper sequence of micro-operations, which is determined by the instruction to be executed.
But how are these two tasks achieved? The control unit generates control signals, which in turn are responsible for achieving the above two tasks. But, how are these control signals generated? We will answer this question in later sections. First let us discuss a simple structure of control unit.
66
Structure of Control Unit A control unit has a set of input values on the basis of which it produces an output control signal, which in turn performs micro-operations. These output signals control the execution of a program. A general model of control unit is shown in Figure 1.
In the model given above the control unit is a black box, which has certain inputs and outputs. The inputs to the control unit are: The Master Clock Signal: This signal causes micro-operations to be performed in a square. In a single clock cycle either a single or a set of simultaneous microoperations can be performed. The time taken in performing a single microoperation is also termed as processor cycle time or the clock cycle time in some machines. The Instruction Register: It contains the operation code (opcode) and addressing mode bits of the instruction. It helps in determining the various cycles to be performed and hence determines the related micro-operations, which are needed to be performed. Flags: Flags are used by the control unit for determining the status of the CPU & the outcomes of a previous ALU operation. For example, a zero flag if set conveys to control unit that for instruction ISZ (skip the next instruction if zero flag is set) the next instruction is to be skipped. For such a case control unit cause increment of PC by program instruction length, thus skipping next instruction. Control Signals from Control Bus: Some of the control signals are provided to the control unit through the control bus. These signals are issued from outside the CPU. Some of these signals are interrupt signals and acknowledgement signals.
On the basis of the input signals the control unit activates certain output control signals, which in turn are responsible for the execution of an instruction. These output control signals are: Control signals, which are required within the CPU: These control signals cause two types of micro-operations, viz., for data transfer from one register to another; and for performing an arithmetic, logic and shift operation using ALU. Control signals to control bus: These control signals transfer data from or to CPU register to or from memory or I/O interface. These control signals are issued on the control bus to activate a data path on the data / address bus etc. 67
Now, let us discuss the requirements from such a unit. A prime requirement for control unit is that it must know how all the instructions will be executed. It should also know about the nature of the results and the indication of possible errors. All this is achieved with the help of flags, op-codes, clock and some control signals to itself. A control unit contains a clock portion that provides clock-pulses. This clock signal is used for measuring the timing of the micro-operations. In general, the timing signals from control unit are kept sufficiently long to accommodate the proportional delays of signals within the CPU along various data paths. Since within the same instruction cycle different control signals are generated at different times for performing different micro-operations, therefore a counter can be utilised with the clock to keep the count. However, at the end of each instruction cycle the counter should be reset to the initial condition. Thus, the clock to the control unit must provide counted timing signals. Examples, of the functionality of control units along with timing diagrams are given in further readings. How are these control signals applied to achieve the particular operation? The control signals are applied directly as the binary inputs to the logic gates of the logic circuits. All these inputs are the control signals, which are applied to select a circuit (for example, select or enable input) or a path (for example, multiplexers) or any other operation in the logic circuits. A program execution consists of a sequence of instruction cycles. Each instruction cycle is made up of a number of sub cycles. One such simple subdivision includes fetch, indirect, execute, and interrupt cycles, with only fetch and execute cycles always occurring. Each sub cycle involves one or more micro-operations. Let us revisit the micro-operations described in Unit 2 to discuss how the events of any instruction cycle can be described as a sequence of such micro-operations. The Fetch Cycle The beginning of each instruction cycle is the fetch cycle, and causes an instruction to be fetched from memory. The fetch cycle consists of four micro-operations that are executed in three timing steps. The fetch cycle can be written as: T1 : MAR T2 : MBR PC T3 : IR PC [MAR] PC + I MBR
where I is the instruction length. We assume that a clock is available for timing purposes and that it emits regularly spaced clock pulses. Each clock pulse defines a time unit. Thus, all the units are of equal duration. Each micro-operation can be performed within the time of a single time unit. The notation (T1, T2, T3) represents successive time units. What is done in these time units? In the first time unit the content of PC is moved to MAR. In the second time unit the contents of memory location specified by MAR is moved to MBR and the contents of the PC is incremented by I. In the third time unit the content of MBR is moved to IR.
Once an instruction is fetched, the next step is to fetch the operands. Considering the same example as of Unit 2, the instruction may have direct and indirect addressing modes. An indirect address is handled using indirect cycle. The following microoperations are required in the indirect cycle: T1 : MAR IR (address) T2 : MBR [MAR] T3 : IR (address) MBR (address) The MAR is loaded with the address field of IR register. Then the memory is read to fetch the address of operand, which is transferred to the address field of IR through MBR as data is received in MBR during the read operation. Thus, the IR now is in the same state as of direct address, viz., as if indirect addressing had not been used. IR is now ready for the execute cycle. The Execute Cycle The fetch and indirect cycles involve a small, fixed sequence of micro-operations. Each of these cycles has fixed sequence of micro-operations that are common to all instructions. This is not true of the execute cycle. For a machine with N different opcodes, there are N different sequences of micro-operations that can occur. Let us consider some hypothetical instructions: An add instruction that adds the contents of memory location X to Register R1 with R1 storing the result: ADD R1, X The sequence of micro-operations may be: T1 : MAR T2 : MBR T3 : R1 IR (address) [MAR] R1 + MBR
At the beginning of the execute cycle IR contains the ADD instruction and its direct operand address (memory location X). At time T1, the address portion of the IR is transferred to the MAR. At T2 the referenced memory location is read into MBR Finally, at T3 the contents of R1 and MBR are added by the ALU. Let us discuss one more instruction: ISZ X, it increments the content of memory location X by 1. If the result is 0, the next instruction in the sequence is skipped. A possible sequence of micro-operations for this instruction may be: T1 : MAR T2 : MBR T3 : MBR T4 : [MAR] IR (address) [MAR] MBR+ 1 MBR PC+ I )
Please note that for this machine we have assumed that MBR can be incremented by ALU directly. 69
The PC is incremented if MBR contains 0. This test and action can be implemented as one micro-operation. Note also that this micro-operation can be performed during the same time unit during which the updated value in MBR is stored back to memory. Such instructions are useful in implementing looping. The Interrupt Cycle On completion of the execute cycle the current instruction execution gets completed. At this point a test is made to determine whether any enabled interrupts have occurred. If so, the interrupt cycle is performed. This cycle does not execute an interrupt but causes start of execution of Interrupt Service Program (ISR). Please note that ISR is executed as just another program instruction cycle. The nature of this cycle varies greatly from one machine to another. A typical sequence of micro-operations of the interrupt cycle are: T1 : MBR T2 : MAR PC T3 : [MAR] PC Save-Address ISR- Address MBR
At time T1, the contents of the PC are transferred to the MBR, so that they can be saved for return from the interrupt. At time T2 the MAR is loaded with the address at which the contents of the PC are to be saved, and PC is loaded with the address of the start of the interrupt-servicing routine. At time T3 MBR, which contains the old value of the PC, is stored in the memory. The processor is now ready to begin the next instruction cycle. The Instruction Cycle The instruction cycle for this given machine consists of four cycles. Assume a 2-bit instruction cycle code (ICC). The ICC can represent the state of the processor in terms of cycle. For example, we can use: 00 : Fetch 01 : Indirect 10 : Execute 11 : Interrupt At the end of each of the four cycles, the ICC is set appropriately. Please note that an indirect cycle is always followed by the execute cycle and the interrupt cycle is always followed by the fetch cycle. For both the execute and fetch cycles, the next cycle depends on the state of the system. Let us show an instruction execution using timing diagram and instruction cycles:
70
Please note that the address line determine the location of memory. Read/ write signal controls whether the data is being input or output. For example, at time T2 in M2 the read control signal becomes active, A9 A0 input contains MAR that value is kept enabled on address bits and the data lines are enabled to accept data from RAM, thus enabling a typical RAM data output on the data bus. For reading no data input is applied by CPU but it is put on data bus by memory after the read control signal to memory is activated. Write operation is activated along with data bus carrying the output value. This diagram is used for illustration of timing and control. However, more information on these topics can be obtained from further readings.
In the hardwired organization, the control unit is designed as a combinational circuit. That is, the control unit is implemented by gates, flip-flops, decoder and other digital circuits. Hardwired control units can be optimised for fast operations. The block diagram of control unit is shown in Figure 3. The major inputs to the circuit are instruction register, the clock, and the flags. The control unit uses the opcode of instruction stored in the IR register to perform different actions for different instructions. The control unit logic has a unique logic input for each opcode. This simplifies the control logic. This control line selection can be performed by a decoder. 71
A decoder will have n binary inputs and 2n binary outputs. Each of these 2n different input patterns will activate a single unique output line. The clock portion of the control unit issues a repetitive sequence of pulses for the SS duration of micro-operation(s). These timing signals control the sequence of execution of instruction and determine what control signal needs to applied at what time for instruction execution.
replaces the sequential and combinational circuits of hardwired control unit by a simple control unit in conjunction with a storage unit that stores the sequence of steps of instruction that is a micro-program. In Wilkes microinstruction has two major components: a) b) Control field which indicates the control lines which are to be activated and Address field, which provides the address of the next microinstruction to be executed.
The control memory in Wilkes control is organized, as a PLAs like matrix made of diodes. This is partial matrix and consists of two components, the control signals and the address of the next micro-instruction. The register I contains the address of the next micro-instruction that is one step of instruction execution, for example T1 in M1 or T2 in M2 etc. as in Figure 2. On decoding the control signals are generated that cause execution of micro-operation(s) of that step. In addition, the control unit indicates the address of the next micro-operation which gets loaded through register II to register I. Register I can also be loaded by register II and enable IR input control signal. This will pass the address of first micro-instruction of execute cycle. During a machine cycle one row of the matrix is activated. The first part of the row generates the control signals that control the operations of the processor. The second part generates the address of the row to be selected in the next machine cycle. At the beginning of the cycle, the address of the row to be selected is contained in register I. This address is the input to the decoder, which is activated by a clock pulse. This activates the row of the control matrix. The two-register arrangement is needed, as the decoder is a combinational circuit; with only one register, the output would become the input during a cycle. This may be an unstable condition due to repetitive loop.
73
The micro-instructions are stored in the control memory. The address register for the control memory contains the address of the next instruction that is to be read. The control memory Buffer Register receives the micro-instruction that has been read. A micro-instruction execution primarily involves the generation of desired control signals and signals used to determine the next micro-instruction to be executed. The sequencing logic section loads the control memory address register. It also issues a read command to control memory. The following functions are performed by the micro-programmed control unit: 1. 2. 74 The sequence logic unit specifies the address of the control memory word that is to be read, in the Address Register of the Control Memory. It also issues the READ signal. The desired control memory word is read into control memory Buffer Register.
3. 4.
The content of the control memory buffer register is decoded to create control signals and next-address information for the sequencing logic unit. The sequencing logic unit finds the address of the next control word on the basis of the next-address information from the decoder and the ALU flags.
As we have discussed earlier, the execute cycle steps of micro-operations are different for all instructions in addition the addressing mode may be different. All such information generally is dependent on the opcode of the instruction Register (IR). Thus, IR input to Address Register for Control Memory is desirable. Thus, there exist a decoder from IR to Address Register for control memory. (Refer Figure 5). This decoder translates the opcode of the IR into a control memory address.
75
The next important question about the micro-instruction is: how are they organized in the control memory? One of the simplest ways to organize control memory is to arrange micro-instructions for various sub cycles of the machine instruction in the memory. The Figure 6 shows such an organisation.
Let us give an example of control memory organization. Let us take a machine instruction: Branch on zero. This instruction causes a branch to a specified main memory address in case the result of the last ALU operation is zero, that is, the zero flag is set. The pseudocode of the micro-program for this instruction can be; Test "zero flag If SET branch to label ZERO Unconditional branch to label NON-ZERO ZERO: (Microcode which causes replacement of program counter with the address provided in the instruction) Branch to interrupt or fetch cycle. NON -ZERO: (Microcode which may set flags if desired indicating the branch has not taken place). Branch to interrupt or fetch cycle. (For Next- Instruction Cycle)
such a micro-instruction may be hundreds of bits. A typical horizontal microinstruction with its related fields is shown in Figure 7(a).
In a vertical micro-instruction many similar control signals can be encoded into a few micro-instruction bits. For example, for 16 ALU operations, which may require 16 individual control bits in horizontal micro-instruction, only 4 encoded bits are needed in vertical micro-instruction. Similarly, in a vertical micro-instruction only 3 bits are needed to select one of the eight registers. However, these encoded bits need to be passed from the respective decoders to get the individual control signals. This is shown in figure 7(b). 77
In general, a horizontal control unit is faster, yet requires wider instruction words, whereas vertical control units, although; require a decoder, are shorter in length. Most of the systems use neither purely horizontal nor purely vertical micro-instructions figure 7(c).
2. 3. 4.
Therefore, we do not need 2N combinations. Suppose, we only need 2K (which is less than 2N) combinations, then we need only K encoded bits instead of N control signals. The K bit micro-instruction is an extreme encoded micro-instruction. Let us touch upon the characteristics of the extreme encoded and unencoded micro-instructions: Unencoded micro-instructions 78 One bit is needed for each control signal; therefore, the number of bits required in a micro-instruction is high. It presents a detailed hardware view, as control signal need can be determined. Since each of the control signals can be controlled individually, therefore these micro-instructions are difficult to program. However, concurrency can be exploited easily. Almost no control logic is needed to decode the instruction as there is one to one mapping of control signals to a bit of micro-instruction. Thus, execution of micro-instruction and hence the micro-program is faster. The unencoded micro-instruction aims at optimising the performance of a machine.
Highly Encoded micro-instructions The encoded bits needed in micro-instructions are small. It provided an aggregated view that is a higher view of the CPU as only an encoded sequence can be used for micro-programming. The encoding helps in reduction in programming burden; however, the concurrency may not be exploited to the fullest. Complex control logic is needed, as decoding is a must. Thus, the execution of a micro-instruction can have propagation delay through gates. Therefore, the execution of micro-program takes a longer time than that of an unencoded micro-instruction. The highly encoded micro-instructions are aimed at optimizing programming effort.
In most of the cases, the design is kept between the two extremes. The LSI 11 (highly encoded) and IBM 3033 (unencoded) control units are close examples of these two approaches. Execution/decoding of slightly encoded micro-instructions In general, the micro-programmed control unit designs are neither completely unencoded nor highly encoded. They are slightly coded. This reduces the width of control memory and micro-programming efforts. The basic technique for encoding is shown in Figure 8. The micro-instruction is organised as a set of fields. Each field contains a code, which, upon decoding, activates one or more control signals. The execution of a micro-instruction means that every field is decoded and generates control signals. Thus, with N fields, N simultaneous actions can be specified. Each action results in the activation of one or more control signals. Generally each control signal is activated by no more than one field. The design of an encoded microinstruction format can be stated in simple terms: Organize the format into independent fields. That is, 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. That is, only one of the actions specified for a given field could occur at a time.
Another aspect of encoding is whether it is direct or indirect (Figure 8). With indirect encoding, one field is used to determine the interpretation of another field. Another aspect of micro-instruction execution is the micro-instruction sequencing that involves address calculation of the next micro-instruction. In general, the next microinstruction can be (refer Figure 6): Next micro-instruction in sequence Calculated on the basis of opcode Branch address (conditional or unconditional).
A detailed discussion on these topics is beyond this unit. You must refer to further readings for more detailed information on Micro-programmed Control Unit Design.
79
Figure (a):
f) 2.
What art the possibilities for the next instruction address? ............................................................................................................................... ............................................................................................................................... ............................................................................................................. .
3.
How many address fields are there in Wilkes Control Unit? ............................................................................................................................... ............................................................................................................................... ..............................................................................................................
80
4.
Compare and contrast unencoded and highly encoded micro-instructions. ............................................................................................................................... ............................................................................................................................... ..............................................................................................................
4.8 SUMMARY
In this unit we have discussed the organization of control units. Hardwired, Wilkes and micro-programmed control units are also discussed. The key to such control units are micro-instruction, which can be briefly (that is types and formats) described in this unit. The function of a micro-programmed unit, that is, micro-programmed execution, has also been discussed. The control unit is the key for the optimised performance of a computer. The information given in this unit can be further appended by going through further readings.
Wilkes control typically has one address field. However, for a conditional branching micro-instruction, it contains two addresses. The Wilkes control, in fact, is a hardware representation of a micro-programmed control unit.
4. Unencoded Micro instructions Large number of bits Difficult to program No decoding logic Highly encoded Relatively less bits Easy to program Need decoding logic 81
82