Unit 3
Control Unit
Microoperation
A microoperation is the smallest operation performed on data stored in
registers inside the CPU. It is the fundamental or atomic operations of the
processor.
It is a basic hardware-level operation that manipulates binary data.
Microoperations are executed in one clock pulse (clock cycle). Exmples :
Register transfer: moving data from one register to another (e.g., R1 ← R2).
Arithmetic: addition, subtraction, increment, decrement (e.g., R3 ← R1 + R2).
Logic: AND, OR, XOR, complement.
Shift: left shift, right shift, rotate.
Memory access: reading from or writing to main memory.
Microinstruction
A microinstruction is a binary control word that specifies one or more
microoperations to be performed in a single clock cycle.
It tells the CPU what operations to perform at a particular step.
Microprogram
A microprogram is a sequence of microinstructions stored in control memory.
It consists of microinstructions that generate the control signals needed to
fetch, decode, and execute machine instructions. Unlike a user program, the
microprogram is not alterable by the user and defines the computer's
instruction set.
It is used to implement machine-level instructions.
Each machine instruction (like ADD, SUB, LOAD) is executed by a set of
microinstructions. These microinstructions together form a microprogram.
Control unit
The control unit (CU) is one of the most important components of a digital
computer.
Its main function is to initiate and control the sequence of microoperations
required to execute instructions.
It directs the operation of all parts of the computer by generating
appropriate control signals.
Types of control unit
1. Hardwired control unit: When control signals are generated using fixed
hardware circuits (logic gates, flip-flops, decoders), it is called a hardwired
control unit.
Characteristics
Fast operation
Difficult to modify
Complex design for large instruction sets
2. Microprogrammed control unit: Microprogramming is an alternative
method for designing the control unit.
It provides a systematic and flexible way of controlling microoperation
sequences.
Instead of using hardware circuits, control signals are generated using stored
instructions (microinstructions). The idea of microprogramming is to control
the execution of instructions using a sequence of microinstructions.
Each microinstruction generates control signals required for microoperations.
It is considered more flexible, easier to design and modify, suitable for
complex instruction sets.
Control memory:
The memory used to store microinstructions is called control memory. Each
memory location contains one microinstruction. A sequence of
microinstructions forms a microprogram.
A computer with a microprogrammed control unit uses two memories:
1. Main Memory: Stores user programs and data
2. Control Memory: Stores microinstructions (control information) and
microinstruction stored in control memory is called control word that
contains one or more than one microoperations that must be performed in
one clock cycle.
Microprogram Control organization:
This diagram shows how a microprogrammed control unit works to generate control
signals for executing instructions.
Control memory (ROM) stores control words (microinstructions). Each location in
control memory contains a microinstruction. Control address register(CAR) specifies
the address of microinstruction to be fetched from control memory, and the control
data register (CDR) holds the microinstruction read from memory. The
microinstruction contains a control word that specifies one or more microoperations
for the data processor. After executing these microoperations, the system must
determine the next microinstruction address. Next address generator is sometimes
called a microprogram sequencer is responsible for determining the address of the
next microinstruction. It ensures proper sequencing and control flow of the
microprogram. The address of the next microinstruction can be specified in several
ways:
a. Incrementing of control address register
b. Unconditional branch, next address is explicitly specified in the
current microinstruction. CAR is directly loaded with this address.
Used for jumping to another microinstruction.
c. Conditional branching, next address depends on a condition or
status flag, if condition is true branch, otherwise continue
sequentially.
d. Mapping from instruction register (opcode mapping): The opcode
of the instruction is used to determine the starting address of the
corresponding microprogram. Used to begin execution of
machine instructions.
e. A facility for subroutine call and return.
Mapping of instructions:
In a microprogrammed control unit, each machine instruction must be executed by
a microprogram.
Therefore, we need a method to convert the instruction opcode into the starting
address of its microprogram in control memory. This process is called Opcode
Mapping. Suppose instruction has 4 bit opcode and control memory has 128 words.
Since 127=27 we need a 7 bit address to access control memory.
To convert a 4-bit opcode into a 7 bit control memory address, place 0 in MSB and
insert 4 bit opcode and set two LSB to 0. This provides for each computer
instruction a microprogram routine with a capacity of four microinstructions. If
routine needs more than four micro instructions it can use addresses 1000000
through 1111111. If it uses fewer than four microinstructions the unused memory
locations would be available for other routines.
Symbolic microprogram
A symbolic microprogram is a human-readable representation of low-level
operations in computer architecture, using mnemonics and symbols to define
microinstructions that are later translated into binary code by an assembler.
Each symbolic microinstruction is divided into five fields
1. Label - Either blank or specify a symbolic address terminated with a
colon (indicates a potential branch) 2.
2. Microoperations field contains one, Two, Three Symbols, separated by
commas (indicates that the microoperation being performed)
3. CD fields selects branching condition using symbols like
U(unconditional), I (indirect address), S(sign of accumulator), Z (zero in
accumulator)
4. BR field specifies the branch typee using symbol such as JMP, CALL,
RET, or MAP
5. The AD field specifies a value for the address field of the
microinstruction into one fo three possible ways.
a. With a symbolic address which must also appear as a label
b. With the symbol NEXT to designate the next addresss in sequence
c. When BR field contains a RET or MAP symbol, the AD field is left
empty and is converted to seven zero by the assembler
We will use the pseudoinstruction ORG to define the first instruction
(or origin) of a microprogram, e.g., ORG 64 begins at 1000000.
The fetch routine: The control memory has 128 words, and each word
contains 20 bits. To microprogram the control memory, it is necessary to
determine the bit values of each of the 128 words. The first 64 words
(addresses 0 to 63) are to be occupied by the routines for the 16
instructions. The last 64 words may be used for any other purpose. A
convenient starting location for the fetch routine is address 64. The
microinstructions needed for the fetch routine are
AR ← PC The PC holds address of next instruction. The
address of the instruction is transferred from PC
to AR
DR ← M[AR], PC ← PC + 1 the instruction is then read from memory into
DR. Since no instruction register is available, the
instruction code remains in DR.
AR ← DR(0–10), The address part is transferred to AR and then
CAR(2–5) ← DR(11–14), control is transferred to one of 16 routines by
CAR(0,1,6) ← 0 mapping the operation code part of the
instruction from DR into CAR.
The fetch routine needs three microinstructions, which are placed in control
memory at addresses 64, 65, and 66. Using the assembly language
conventions defined previously, we can write the symbolic microprogram for
the fetch routine as follows:
ORG 64
FETCH:
NEXT JMP U PCTAR
NEXT JMP U READ, INCPC
MAP U DRTAR
The translation of the symbolic microprogram to binary produces the
following binary microprogram. The bit values are obtained from Table 7-1.
Binary microprogram
The microprogram is usually translated to binary either by means of an
assembler program or by the user if the microprogram is simple enough. The
equivalent binary form of the microprogram is listed in Table 7-3. The binary
content of each microinstruction is derived from the symbols and their
equivalent binary values as defined in Table 7-1.
Note that address 3 has no equivalent in the symbolic microprogram since
the ADD routine has only three microinstructions at addresses 0, 1, and 2.
The next routine starts at address 4. Even though address 3 is not used,
some binary value must be specified for each word in control memory. We
could have used zero for the unused location since this word is never
referenced.
The addition routine begins with ORG = 0, which means the control
unit starts reading microinstructions from the 0th location of control
memory. The initial microinstruction has fields F1, F2, F3 = (000),
indicating that no micro-operations are performed (NOP).
The condition field CD = 01 and branch field BR = 01 specify a
conditional branch. The address field AD = 1000011 (i.e., 67 in
decimal) directs the control unit to jump to location 67, which contains
the INDIRECT subroutine.
During this branching process, the current value of the Control Address
Register (CAR) is incremented and stored in the Subroutine Register
(SBR). This allows the system to return to the next sequential
microinstruction after completing the subroutine.
The INDIRECT subroutine is then executed to obtain the effective
address of the operand. After completing this subroutine, control
returns to the address stored in the SBR.
Next, the operand is fetched from memory using the address stored in
the Address Register (AR) and is loaded into the Data Register (DR).
The control unit then proceeds to the next microinstruction, where the
addition operation is performed. The result of the addition is stored in
the Accumulator (AC).
Finally, since the last microinstruction contains the control address
1000000, the control unit branches to the fetch routine to fetch the
next instruction.
Design of control unit:
The design of a control unit using microinstructions involves dividing
each microinstruction into several fields, where each field performs a
specific and independent function. These fields contain control bits that
initiate micro-operations, determine the selection of the next control
address, and specify branching conditions.
To reduce the number of control bits required, mutually exclusive
micro-operations are grouped together and encoded within a
single field. If a field contains k bits, it can represent up to 2k different
micro-operations. These encoded values are then decoded using a
decoder to generate the appropriate control signals.
This encoding technique significantly reduces the size of control
memory. However, it introduces additional hardware in the form of
decoders and may increase execution delay due to signal propagation
through these decoding circuits.
For example, consider a microinstruction of 9 bits divided into three
fields: F1, F2, and F3, each consisting of 3 bits. Each field is
connected to a 3-to-8 decoder, which produces eight possible
outputs corresponding to different micro-operations. These outputs are
connected to various components of the processor.
For instance, if field F1 = 101, it may initiate the transfer of data from
the Data Register (DR) to the Address Register (AR). If F1 = 110,
it may transfer data from the Program Counter (PC) to the AR. The
decoder outputs control multiplexers that select the appropriate data
source, and the transfer takes place during a clock pulse when the
corresponding control signal is activated. Similarly, arithmetic and logic
operations such as AND and ADD are also controlled through decoder
outputs instead of direct control signals.
Microprogram sequencer
A microprogram sequencer is a key component of a microprogrammed
control unit. Its main function is to generate the address of the next
microinstruction to be executed from control memory. The control memory
stores microinstructions, and the sequencer ensures that these
microinstructions are executed in the correct order by selecting the
appropriate next address.
Main Components and Working
1. Control Address Register (CAR)
Holds the address of the current microinstruction.
The content of CAR is used to access control memory.
2. Control Memory
Stores microinstructions.
Each microinstruction contains:
Control signals (micro-operations)
Branch condition (CD)
Branch type (BR)
Address field (AD)
3. Multiplexers (MUX1 and MUX2)
MUX1 selects the next address for CAR from different sources.
MUX2 selects status conditions (like zero, sign, carry, etc.) for decision-
making.
4. Subroutine Register (SBR)
Stores return addresses during subroutine calls.
Used to return control after completing a subroutine.
5. Incrementer
Increments the CAR to point to the next sequential microinstruction.
Sources of Next Address
The next address loaded into CAR can come from different sources:
1. Incremented CAR → for sequential execution
2. Address field (AD) → for branching
3. Subroutine Register (SBR) → for returning from subroutine
4. External mapping (MAP) → for starting execution of a new
instruction
MUX1 selects one of these sources based on control signals.
Hardwired control unit:
A hardwired control unit is a type of control unit in which control signals are
generated using fixed logic circuits such as gates, flip-flops, decoders, and
multiplexers. Unlike a microprogrammed control unit, it does not use control
memory or microinstructions. Instead, all control operations are directly
implemented using hardware.
In this approach the control unit receives:
Instruction opcode (from Instruction Register)
Timing signals (clock pulses)
Status flags (Zero, Carry, etc.)
These inputs are fed into a combinational logic circuit. The logic circuit generates
the required control signals for executing the instruction