| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
In the microprogrammed control unit design, the control signals are generated by a program similar to machine language programs. The basic idea is that the control unit stores the values of the signals in memory instead of computing them. This can be accomplished by allocating for every signal a bit in memory, and if the signal is to be 1, the bit will store a 1; otherwise it will store a 0. For example, suppose that the control unit needs to generate 20 control signals. Then, 20 bits are allocated for each memory address. Each memory address will store the signal values for a particular clock cycle. For example, memory address 0 will store the signal values for clock cycle T1, memory address 1 will store the signal value for clock cycle T2, and so on. The word whose bits represent the various control signals required is called a Control Word (CD). An individual control word is also called a Microinstruction. A Microroutine is the sequence of control words corresponding to the control sequence of a machine instruction. The Control Store stores the microroutines for all instructions in the instruction set of a computer. The Control Store is a ROM since once it is programmed, it will be just read to get the signal values. Let us consider the instruction ADD R1, [R3] (R1← R1 + [R3]) for the single-bus CPU. The control sequence for fetching this instruction and executing it using the single-bus CPU is shown in the next table:
We can store the required control signals for this control sequence in memory as follows:
Note that for this example we assumed that the ALU can perform the following four operations: C=A+B, C=B+1, C=A-B, C=B-1. The following table shows the ALU functions and the corresponding selection lines:
To read the control words sequentially from the control store, a Microprogram Counter (uPC) is used. The uPC is incremented every clock cycle causing successive microinstructions to be read from the control store. Thus, the control signals are delivered to the various parts of the CPU in the correct sequence. When the instruction register (IR) is loaded with a new instruction, the address of the microroutine for the instruction to be executed is loaded into the uPC. Thus, we need an address generator that generates the address of the microroutine for each instruction based on its opcode. The microprogrammed control unit block diagram is shown below:
Microprogrammed Control Unit with Conditional BranchingLet us next consider the branch on Negative instruction JMPN Label (PC← Label if N=1). The microroutine for this instruction is shown in the following table:
In this example, the starting address of the microroutine for the branch on Negative instruction is 25. As can be seen from this example, in addition to generating the control signals, the control unit needs to check conditions codes or status flags to choose between alternative courses of action. Thus, additional fields are added to the microinstruction to allow the capability of conditional branching. The branch address is also added to the microinstruction. The control unit organization to allow conditional branching in the microprogram is illustrated below:
In the microprogrammed control unit with conditional branching, the uPC is incremented every time a microinstruction is fetched from the microprogram memory, except in the following situations:
|