Unit 4 Microprocessor
Unit 4 Microprocessor
Microprogrammed Control
Prepared by
Er. Binod Kumar Rajbhar
Terminologies:
• Hardwired Control Unit: When the control signals are generated by hardware using
conventional logic design techniques, the control unit is said to be hardwired.
• Micro Programmed Control Unit: A control unit whose binary control variable are stored in
memory is called a micro programmed control unit.
• Control Memory: Control Memory is the storage in the micro-programmed control unit to
store the micro-program.
• Control Word: The control variables at any given time can be represented by a control
word string of 1’s and 0’s called a control word.
• Micro-Operations: Micro-Operations perform basic operation on data stored in one or
more registers, including transferring data between registers or between registers and
external buses of the central processing unit (CPU), and performing arithmetic or logical
operations on registers.
• Microcode: A very low-level instruction set which is stored permanently in a computer or
peripheral controller and controls the operation of the device.
• Microinstruction: A single instruction in microcode. It is the most elementary instruction in
the computer, such as moving the contents of a register to the arithmetic logic unit (ALU).
• Micro-program: A set or sequence of micro-operations.
Micro-Programmed vs Hardwired Control
Design of Basic Computer:
• The basic computer consists of the following hardware components:
A memory unit with 4096 words of 16 bit each
Nine registers: AR (Address register), PC (Program Counter), DR (Data
Register), AC (Accumulator), IR (Instruction Register), TR (Temporary
Register), OUTR (Output Register), INPR (Input Register), and SC
(Sequence Counter).
Flip-flops: IEN (Interrupt enable), FGI (Input Flag), and FGO (Output Flag).
Two decoder: a 3X8 operation and a 4X16 timing decoder.
A 16-bit common bus
Control logic gates.
Adder and logic circuit connected to the input of AC.
Design of Accumulator Logic:
The circuit associated with the AC register are shown in fig. below. The
adder and logic circuit has three sets of inputs.
One set of 16 inputs comes from the outputs of AC.
Another set of 16 inputs comes from the data register DR.
A third set of eight inputs comes from the input register INPR.
The outputs of the adder and logic circuit provide the data inputs for the
register. In addition, it is necessary to include logic gates for controlling
the LD, INR, and CLR in the register and for controlling the operation
of the adder and logic circuit.
Control of AC Register- Gate Structure:
• The gate structure that controls the LD, INR, and CLR inputs of AC is shown in
fig.
• The outputs of the AND gate that generates this control function is connected
to the CLR input of the register.
• Similarly, the output of the gate that implements the increment micro
operation is connected to the INR input of the register.
• The other seven micro operations are generated in the adder and logic circuit
and are loaded into AC at the proper time.
• The outputs of the gates for each control function is marked with symbolic
name. These outputs are used in the design of the adder and logic circuit.
ALU Organization:
• Various circuits are required to process data or perform arithmetical
operations which are connected to microprocessor’s ALU.
• Accumulator and data buffer stores data temporarily. These data are
processed as per control instructions to solve problems. Such
problems are addition, multiplication etc.
Function of ALU:
Function of ALU can be categorized into following 3 categories:
• Arithmetic Operations: Addition, multiplication etc. are example of arithmetic
operations. Finding greater than or smaller than or equality between two
numbers by using subtraction is also a form of arithmetic operations.
• Logical Operations: Operations like AND, OR, NOR, NOT etc. using logical
circuitry are examples of logical operations.
• Data manipulations: Operations such as flushing a register is an example of
data manipulation. Shifting binary numbers are also example of data
manipulation.
Control memory:
A computer that employs a micro-programmed control unit will have two
separate memories: a main memory and a control memory.
The main memory is available to the user for storing the programs. The contents
of main memory may alter when the data are manipulated and every time that the
program is changed. The user's program in main memory consists of machine
instructions and data.
In contrast, the control memory holds a fixed micro-program that cannot be altered
by the occasional user. The micro-program consists of microinstructions that
specify various internal control signals for execution of register micro-operations.
Each machine instruction initiates a series of microinstructions in control memory.
These microinstructions generate the micro-operations to fetch the instruction from
main memory; to evaluate the effective address, to execute the operation specified
by the instruction, and to return control to the fetch phase in order to repeat the
cycle for the next instruction.
The control unit initiates a series of sequential steps of micro-operations. During any
given time, certain micro-operations are to be initiated, while others remain idle.
The control variables at any given time can be represented by a string of 1's and 0's
called a control word.
As such, control words can be programmed to perform various operations on the
components of the system.
The micro-instruction specifies one or more micro-operations for the system. A
sequence of microinstructions constitutes a micro-program.
Micro-programmed Control Organization:
The general configuration of a micro-programmed control unit is demonstrate in the
block diagram given below. The control memory is assumed to be a ROM, within
which all control information is permanently stored.
The control memory address register specifies the address of the micro-operation,
and the control data register holds the micro-instruction read from memory.
Address sequencing:
Microinstructions are stored in control memory in groups, with each group
specifying a routine.
Each computer instruction has its own micro-program routine in control memory to
generate the micro-operation routine in control memory to generate the micro-
operations that execute the instruction.
To appreciate the address sequencing in a micro-program control unit:
o An initial address is loaded into the control address register when power is turned on in the
computer. This address is usually the address of the first microinstruction that activates the
instruction fetch routine.
o The control memory next must go through the routine that determines the effective address of the
operand.
o The next step is to generate the micro-operations that execute the instruction fetched from
memory.
o Once the required routine is reached, the micro instructions that execute the instruction may be
sequenced by incrementing the control address register.
• The transformation from the instruction code bits to an address in control memory where
the routine is located is referred to as a mapping process.
• The address sequencing capabilities required in a control memory are:
• Incrementing of the control address register.
• Unconditional branch or conditional branch, depending on status bit condition.
• A mapping process from the bits of the instruction to an address for control memory.
• A facility for subroutine call and return.
• The block diagram of a control memory and the associated hardware needed for selecting
the next microinstruction address is shown in fig.
• The microinstruction in control memory contains:
• A set of bits to initiate micro-operations in computer registers.
• Other bits to specify the method by which the next address is obtained.
Address sequencing:
Conditional Branching:
• The branch logic of control memory provides decision making capabilities in the
control unit.
• The status conditions are special bits in the system that provides parameter information
• The status bits, together with the field in the microinstruction that specifies a branch
address, control the conditional branch address, control the conditional branch decisions
generated in the branch logic.
• The branch logic hardware may be implemented by multiplexer.
• Branch to the instruction address if the condition is met;
• 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.
Mapping of instruction:
• Each instruction has its own micro-program routine stored in a given location of control memory.
The transformation from the instruction code bits to an address in control memory where the
routine is located is referred to as mapping process.
• A mapping procedure is a rule that transforms the instruction code into a control memory address.
• For example, a computer with a simple instruction format as shown in fig. has an operation code
of four bits. Assume further that the control memory has 128 words, requiring an address of 7
bits. For each operation code there exist a micro-program routine in control memory that executes
the instruction.
• One simple mapping process that converts the 4-bit operation code to 7-bit address for control
memory.
• This mapping consists of placing a 0 in the most significant bit of the address,
• Transferring the four operation code bits,
• Clearing the two least significant bits of the control address register.
• This provides for each computer instruction a micro-program routine with a capacity of four
microinstructions.
• If the routine needs more than four microinstructions, it can use addresses 1000000 through 1111111.
• If it uses fewer than four microinstructions, the unused memory locations would be available for other
routines.
• One can extend this concept to more general mapping rule by using ROM or programmable logic
device (PLD) to specify the mapping function.
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 register in last-in, first-out (LIFO) stack.
Micro-program:
• Micro-program is a sequence of microinstructions that controls the operation of an
arithmetic and logic unit so that machine code instruction are executed.
• It is a microinstruction program that controls the function of a central processing unit or
peripheral controller of a computer.
• Micro instruction Format:
• The microinstruction format for the control memory is shown in fig. below.
• The 20 bits of the microinstruction are divided into four functional part.
• The three fields F1, F2 and F3 specify micro-operations for the computer
• The CD field selects status bit conditions.
• The BR field specifies the type of branch to be used.
• The AD field contains a branch address. The address field is seven bits wide, since the control memory
has 128=27 words.
Symbols and Binary Code for Micro-Operations:
• Each micro-operation in Table is defined with a register transfer statement and is
assigned a symbol for use in a symbolic micro-program. All transfer-type micro-
operations symbols use five letters. The first two letters designate the source register, the
third letter is always a T, and the last two letters designate the destination register. For
example, the micro- operation that specifies the transfer AC <-DR (F1 = 100) has the
symbol DRTAC, which stands for a transfer from DR to AC.
• The CD (condition) field consists of two bits which are encoded to specify four status bit
conditions as listed in Table. The first condition is always a 1, so that a reference to CD =
00 (or the symbol U) will always find the condition to be true. We will use the symbols U,
I, S, and Z for the four status bits when we write micro-programs in symbolic form.
• The BR (branch) field consists of two bits. It is used, in conjunction with the address field
AD, to choose the address of the next microinstruction. As shown in Table, when BR = 00,
the control performs a jump GMP) operation (which is similar to a branch), and when BR
• = 01, it performs a call to subroutine (CALL) operation. The return from
subroutine is accomplished with a BR field equal to 10. This causes the transfer
of the return address
• from SBR to CAR. The mapping from the operation code bits of the instruction
to an address for CAR is accomplished when the BR field is equal to 11.
Symbolic vs Binary Micro-program:
Deign of control unit/ structure of CU:
• Control unit generates timing and control signals for the operations of the
computer. The control unit communicates with ALU and main memory. It also
controls the transmission between processor, memory and the various peripherals.
It also instruct the ALU which operation has to be performed on data.
• Control unit can be designed by two methods:
• Hardwired control unit
• Micro Programmed control unit
Basic Requirements of Control Unit:
• The functional requirements of control unit are those functions that the control unit
must perform and these are the basis for the design and implementation of the control
unit.
• A three step process that lead to the characterization of the Control Unit:
• Define the basic elements of the processor
• Describe the micro-operations that the processor performs
• Determine the functions that the control unit must perform to cause the micro- operations to be
performed.
1.Basic elements of Processor:
The following are the basic functional elements of a CPU:
• ALU: is the functional essence of the computer
• Registers: are used to store data internal to the CPU
2. Types of Micro-Operation:
These operations consists of a sequence of micro-operations. All micro
instruction fall into one of the following categories:
• Transfer data between registers
• Transfer data from register to external
• Transfer data from external to register
• Perform arithmetic or logical operations
• Commercial sequencers include within the unit an internal register stack used for
temporary storage of addresses during micro-program looping and subroutine calls.
Some sequencers provide an output register which can function as the address
register for the control memory.
• The control memory is included in the diagram to show the interaction between the
sequencer and the memory attached to it.
• There are two multiplexers in the circuit
• The first multiplexer selects an address from one of the four sources and routes it into the CAR (Control
Address Register).
• The second multiplexer tests the value of a selected status bit and the result of the test is applied to an
input logic circuit.
• The output from CAR provides the address for the control memory.
• The contents of CAR is incremented and applied to one of the multiplexer inputs and to the SBR.
• The other three input come from the address field of the present microinstruction, from the output of
SBR (Subroutine Register) and from an external source that maps the instruction
Micro-program Sequencer: