Chapter3 Control Unit
Chapter3 Control Unit
Chapter – 3
Control Unit
3.1 Control Memory
Extra Stuff:
Microprogram
Program stored in memory that generates all the control signals required to execute the
instruction set correctly
Consists of microinstructions
Microinstruction
Contains a control word and a sequencing word
Control Word - All the control information required for one clock cycle
Sequencing Word - Information needed to decide the next microinstruction address
Vocabulary to write a microprogram
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 1
Computer Organization and Architecture Chapter 3 : Control Unit
Microrogrammed Sequencer
The next address generator is sometimes called a microprogram sequencer, as it
determines the address sequence that is read from control memory.
Typical functions of a microprogram sequencer are:
o Incrementing the control address register by one
o Loading into the control address register an address from control memory
o Transferring an external address
o Loading an initial address to start the control operations
Pipeline Register
The data register is sometimes called a pipeline register.
o It allows the execution of the microoperations specified by the control word
simultaneously with the generation of the next microinstruction.
This configuration requires a two-phase clock
o The system can operate by applying a single-phase clock to the address register.
Without the control data register
Thus, the control word and next-address information are taken directly
from the control memory.
Advantages
The main advantage of the microprogrammed control is the fact that once the hardware
configuration is established; there should be no need for further hardware or wiring
change.
Most computers based on the reduced instruction set computer (RISC) architecture
concept use hardwired control rather than a control memory with a microprogram.
(Why?)
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 2
Computer Organization and Architecture Chapter 3 : Control Unit
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 3
Computer Organization and Architecture Chapter 3 : Control Unit
Conditional Branching
The branch logic of Fig. 3-2 provides decision-making capabilities in the control unit.
The status conditions are special bits in the system that provides parameter
information.
o e.g. the carry-out, the sign bit, the mode bits, and input or output status
The status bits, together with the field in the microinstruction that specifies a branch
address, control the conditional branch decisions generated in the branch logic.
The branch logic hardware may be implemented by multiplexer.
o Branch to the indicated address if the condition is met;
o Otherwise, the address register is incremented.
An unconditional branch microinstruction can be implemented by loading the branch
address from control memory into the control address register.
If Condition is true, then Branch (address from the next address field of the current
microinstruction)
else Fall Through
Conditions to Test: O(overflow), N(negative), Z(zero), C(carry), etc.
Unconditional Branch
Fixing the value of one status bit at the input of the multiplexer to 1
Mapping of Instructions
A special type of branch exists when a microinstruction specifies a branch to the first
word in control memory where a microprogram routine for an instruction is located.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 4
Computer Organization and Architecture Chapter 3 : Control Unit
The status bits for this type of branch are the bits in the operation code part of the
instruction.
One simple mapping process that converts the 4-bit operation code to a 7-bit address
for control memory is shown in Fig. 3-3.
o Placing a 0 in the most significant bit of the address
o Transferring the four operation code bits
o Clearing the two least significant bits of the control address register
This provides for each computer instruction a microprogram routine with a capacity
of four microinstructions.
o If the routine needs more than four microinstructions, it can use addresses
1000000 through 1111111.
o If it uses fewer than four microinstructions, the unused memory locations
would be available for other routines.
One can extend this concept to a more general mapping rule by using a ROM or
programmable logic device (PLD) to specify the mapping function.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 5
Computer Organization and Architecture Chapter 3 : Control Unit
Mapping from the OP-code of an instruction to the address of the Microinstruction which
is the starting microinstruction of its execution microprogram.
Subroutine
Subroutines are programs that are used by other routines to accomplish a particular
task.
Microinstructions can be saved by employing subroutines that use common sections
of microcode.
e.g. effective address computation
The subroutine register can then become the source for transferring the address for
the return to the main routine.
The best way to structure a register file that stores addresses for subroutines is to
organize the registers in a last-in, first-out (LIFO) stack.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 6
Computer Organization and Architecture Chapter 3 : Control Unit
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 7
Computer Organization and Architecture Chapter 3 : Control Unit
Microinstruction Format
The microinstruction format for the control memory is shown in Fig. 3-6.
The 20 bits of the microinstruction are divided into four functional parts.
o The three fields F1, F2, and F3 specify microoperations for the computer.
o The CD field selects status bit conditions.
o The BR field specifies the type of branch.
o The AD field contains a branch address.
Microoperations
The three bits in each field are encoded to specify seven distinct microoperations
as listed in Table 3-1.
o No more than three microoperations can be chosen for a microinstruction,
one from each field.
o If fewer than three microoperations are used, one or more of the fields will
use the binary code 000 for no operation.
It is important to realize that two or more conflicting microoperations cannot be
specified simultaneously. e.g. 010 001 000
Each microoperation in Table 3-1 is defined with a register transfer statement and
is assigned a symbol for use in a symbolic microprogram.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 8
Computer Organization and Architecture Chapter 3 : Control Unit
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 9
Computer Organization and Architecture Chapter 3 : Control Unit
The CD field consists of two bits which are encoded to specify four status bit
conditions as listed in Table 3-1.
The BR field consists of two bits. It is used, in conjunction with the address
field AD, to choose the address of the next microinstruction.
o The jump and call operations depend on the value of the CD field.
o The two operations are identical except that a call microinstruction stores
the return address in the subroutine register SBR.
o Note that the last two conditions in the BR field are independent of the
values in the CD and AD fields.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 10
Computer Organization and Architecture Chapter 3 : Control Unit
Sample Format
Five fields: label; micro-ops; CD; BR; AD
The label field: may be empty or it may specify a symbolic address
terminated with a colon
The microoperations field: of one, two, or three symbols separated by
commas , the NOP symbol is used when the microinstruction has no
microoperations
The CD field: one of the letters {U, I, S, Z} can be chosen where
U: Unconditional Branch
I: Indirect address bit
S: Sign of AC
Z: Zero value in AC
The BR field: contains one of the four symbols {JMP, CALL, RET,
MAP}
The AD field: specifies a value for the address field of the
microinstruction with one of {Symbolic address, NEXT, empty}
o When the BR field contains a RET or MAP symbol, the AD field
is left empty
Fetch Subroutine
During FETCH, Read an instruction from memory and decode the instruction and update PC.
The first 64 words are to be occupied by the routines for the 16 instructions.
The last 64 words may be used for any other purpose.
o A convenient starting location for the fetch routine is address 64.
The three microinstructions that constitute the fetch routine have been listed in three
different representations.
o The register transfer representation:
To see how the transfer and return from the indirect subroutine occurs:
o MAP microinstruction caused a branch to address 0
o The first microinstruction in the ADD routine calls subroutine INDRCT when
I=1
o The return address is stored in the subroutine register SBR.
o The INDRCT subroutine has two microinstructions:
INDRCT: READ U JMP NEXT
DRTAR U RET
o Therefore, the memory has to be accessed to get the effective address, which
is then transferred to AR.
o The execution of the ADD instruction is carried out by the microinstructions
at addresses 1 and 2
o The first microinstruction reads the operand from memory into DR.
o The second microinstruction performs an add microoperation with the content
of DR and AC and then jumps back to the beginning of the fetch routine.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 12
Computer Organization and Architecture Chapter 3 : Control Unit
Binary Microprogram
The symbolic microprogram must be translated to binary either by means of an
assembler program or by the user if the microprogram is simple.
The equivalent binary form of the microprogram is listed in Table 7-3.
Even though address 3 is not used, some binary value, e.g. all 0’s, must be
specified for each word in control memory.
However, if some unforeseen error occurs, or if a noise signal sets CAR to the
value of 3, it will be wise to jump to address 64.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 13
Computer Organization and Architecture Chapter 3 : Control Unit
Control Memory
When a ROM is used for the control memory,the microprogram binary list
provides the truth table for fabricating the unit.
o To modify the instruction set of the computer, it is necessary to generate a
new microprogram and mask a new ROM.
The advantage of employing a RAM for the control memory is that the
microprogram can be altered simply by writing a new pattern of 1’s and 0’s
without resorting to hardware procedure.
However, most microprogram systems use a ROM for the control memory
because it is cheaper and faster than a RAM.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 14
Computer Organization and Architecture Chapter 3 : Control Unit
Types of Micro-operation
Transfer data between registers
Transfer data from register to external interface
Transfer data from external interface to register
Perform arithmetic/logical ops with register for i/p, o/p
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 15
Computer Organization and Architecture Chapter 3 : Control Unit
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 16
Computer Organization and Architecture Chapter 3 : Control Unit
Hardwired Implementation
In this implementation, CU is essentially a combinational circuit. Its i/p signals
are transformed into set of o/p logic signal which are control signals.
Control unit inputs
Flags and control bus
o Each bit means something
Instruction register
o Op-code causes different control signals for each different instruction
o Unique logic for each op-code
o Decoder takes encoded input and produces single output
o Each decoder i/p will activate a single unique o/p
Clock
o Repetitive sequence of pulses
o Useful for measuring duration of micro-ops
o Must be long enough to allow signal propagation along data paths and
through processor circuitry
o Different control signals at different times within instruction cycle
o Need a counter as i/p to control unit with different control signals being
used for t1, t2 etc.
o At end of instruction cycle, counter is re-initialised
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 17
Computer Organization and Architecture Chapter 3 : Control Unit
Implementation
For each control signal, a Boolean expression of that signal as a function of the
inputs is derived
With that the combinatorial circuit is realized as control unit.
Micro-programmed Implementation
An alternative to hardwired CU
Common in contemporary CISC processors
Use sequences of instructions to perform control operations performed by micro
operations called micro-programming or firmware
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 18
Computer Organization and Architecture Chapter 3 : Control Unit
Micro-instruction Types
Each micro-instruction specifies single or few micro-operations to be performed -
vertical micro-programming
Each micro-instruction specifies many different micro-operations to be performed in
parallel - horizontal micro-programming
Horizontal Micro-programming
Wide memory word
High degree of parallel operations possible
Little encoding of control information
Vertical Micro-programming
Width is narrow
n control signals encoded into log2 n bits
Limited ability to express parallelism
Considerable encoding of control information requires external memory word
decoder to identify the exact control line being manipulated
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 19
Computer Organization and Architecture Chapter 3 : Control Unit
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 20
Computer Organization and Architecture Chapter 3 : Control Unit
Microprogram Sequencer
The basic components of a microprogrammed control unit are the control memory and
the circuits that select the next address.
The address selection part is called a microprogram sequencer.
A microprogram sequencer can be constructed with digital functions to suit a particular
application.
To guarantee a wide range of acceptability, an integrated circuit sequencer must provide
an internal organization that can be adapted to a wide range of application.
The purpose of a microprogram sequencer is to present an address to the control memory
so that a microinstruction may be read and executed.
The block diagram of the microprogram sequencer is shown in Fig. 3-12.
o The control memory is included to show the interaction between the sequencer
and the attached to it.
o There are two multiplexers in the circuit; first multiplexer selects an address from
one of the four sources and routes to CAR, second multiplexer tests the value of
the selected status bit and result is applied to an input logic circuit.
o The output from CAR provides the address for control memory, contents of CAR
incremented and applied to one of the multiplexers input and to the SBR.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 21
Computer Organization and Architecture Chapter 3 : Control Unit
o Although the diagram shows a single subroutine register, a typical sequencer will
have a register stack about four to eight levels deep. In this way, a push, pop
operation and stack pointer operates for subroutine call and return instructions.
o The CD (Condition) field of the microinstruction selects one of the status bits in
the second multiplexer.
o The Test variable (either 1 or 0) i.e. T value together with the two bits from the
BR (Branch) field go to an input logic circuit.
o The input logic circuit determines the type of the operation.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 22
Computer Organization and Architecture Chapter 3 : Control Unit
Based on the function listed in each entry was defined in Table 3-1, the truth table for the input
logic circuit is shown in Table 3-4.
Therefore, the simplified Boolean functions for the input logic circuit can be given as:
S1 I1
S 0 I1 I 0 I1T
L I1I 0T
o The bit values for S1 and S0 are determined from the stated function and the path in the
multiplexer that establishes the required transfer.
o Note that the incrementer circuit in the sequencer of Fig. 7-12 is not a counter constructed
with flip-flops but rather a combinational circuit constructed with gates.
Compiled By: Er. Hari Aryal [haryal4@gmail.com] Reference: M. Mano & W. Stallings | 23