Microprogrammed Control Unit Overview
Microprogrammed Control Unit Overview
org
1
Microprogrammed Control
Control Unit
● The function of the control unit in a digital computer is to initiate sequences of microoperations.
● Two methods of implementing control unit are
○ Hardwired control
○ Microprogrammed control.
● Hardwired Control
○ Design involves the use of fixed instructions, fixed logic blocks, encoders, decoders, etc.
○ Key characteristics are high-speed operation, expensive, relatively complex, and no flexibility of adding
new instructions.
○ Example CPUs: Intel 8085, Motorola 6802, and any RISC (Reduced Instruction Set Computer) CPUs.
3
Microprogrammed Control Unit
● A control unit whose binary control variables are stored in memory is called a microprogrammed control unit.
● Main advantage - for different control sequence; only have to change microprogram residing in control
memory. (No need of hardware changes)
● The control function that specifies a microoperation is a binary variable.
● The control variables at any given time can be represented by a string of 1’s and 0’s called a control word.
● Each word in control memory contains a microinstruction.
● The microinstruction specifies one or more microoperations.
● A sequence of microinstructions constitutes a microprogram.
4
Microprogrammed Control Unit
● A computer with microprogrammed control unit will have 2 memories.
○ Main Memory.
○ 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.
● A memory that is part of a control unit is referred to as a control memory.
● The control memory holds a fixed microprogram that cannot be altered by the user and contains various
control signals.
● The control memory can be a read-only memory (ROM) since alterations are not needed.
● Writable control memory is used in dynamic programing.
5
Microprogrammed Control Unit
● The control memory is a ROM in which all control information is permanently stored.
● The control address register specifies the address of the microinstruction
● Control data register holds the microinstruction read from memory.
● The microinstruction contains a control word that specifies one or more microoperations for the data
processor.
● The next address is computed in the next address generator(sequencer) and then transferred into the
control address register to read the next microinstruction.
● The control data register(pipeline register) holds the present microinstruction while the next address is
computed and read from memory.
6
Address Sequencing
7
Address Sequencing
● Microinstructions are stored in control memory in groups, with each group specifying a routine.
● Each computer instruction has its own microprogram routine in control memory to generate the
microoperations that execute the instruction.
● The hardware that controls the address sequencing must be capable of sequencing the microinstructions
within a routine and be able to branch from one routine to another.
8
Executing a Single Instruction
9
In brief, the address sequencing capabilities required in a
control memory
10
Incrementing CAR
● The incrementer increments the content of the
control address register by one, to select the next
microinstruction in sequence.
Conditional Branching
● Branch logic provides decision-making capabilities in
the control unit.
● The status bits, together with the field in the
microinstruction that specifies a branch address,
control the conditional branch decisions
● Simplest way to implement branch logic is to test
the specified condition and branch to an address if
the condition is met; else increment the address
register.
11
Mapping of Instruction
● A special type of branch instruction.
● Here a branching is done to the first word in control memory where a microprogram routine for an instruction
is located.
● The status bits for this branch are the bits in the operation code of the instruction.
● Can be implemented using ROM.
● The bits of the instruction specify the address of a mapping ROM.
● The contents of the mapping ROM give the bits for the control address register.
● This concept provides flexibility for adding instructions for control memory as the need arises.
12
Subroutines
● 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.
● Must have a provision for storing the return address during a subroutine call and restoring the address during
a subroutine return.
● This may be accomplished by placing the incremented address from the control address register into a
subroutine register and branching to the beginning of the subroutine.
● The subroutine register can then become the source for transferring the address for the return to the main
routine.
13
Microprogram Example
14
Microinstruction Format
● Generating microcode for the control memory is called microprogramming.
15
Microinstruction Field Description
16
Microinstruction Field Description
17
Symbolic Microinstructions
● Symbolic microprogram can be translated into its binary equivalent by means of an assembler.
● Each symbolic microinstruction is divided into five fields
○ Label
○ Microoperations
○ CD
○ BR
○ AD
● The label field may be empty or it specify a symbolic address.
● It is terminated with a colon (:)
● The microoperations field consists of one, two, or three symbols, separated by commas.
There may be no more than one symbol from each F field.
The NOP symbol is used when the microinstruction has no microoperations.
18
Symbolic Microinstructions
● The CD field has one of the letters U, I, S, or Z.
● 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 in one of three possible ways:
○ With a symbolic address, which must also appear as a label.
○ With the symbol NEXT to designate the next address in sequence.
○ When the BR field contains a RET or MAP symbol, the AD field is left empty.
● We will use also the pseudoinstruction ORG to define the origin, or first address, of a microprogram routine.
19
The Fetch Routine
● The microinstructions needed for the fetch routine are
AR ← PC
DR ← M[AR], PC ← PC + 1
AR ← DR(0 - 10), CAR(25) ← DR(11 - 14), CAR(0,1,6) ← 0
● Symbolic microprogram for the fetch routine
ORG 64
FETCH: PCTAR U JMP NEXT
READ,INCPC U JMP NEXT
DRTAR U MAP
● Equivalent binary microprogram
Binary Address Fl F2 F3 CD BR AD
1000000 110 000 000 00 00 1000001
1000001 000 100 101 00 00 1000010
1000010 101 000 000 00 11 0000000
20
Design of Control Unit
21
● Bits of the microinstruction are usually divided into
fields, with each field defining a separate
function.(F1-F2-F3, CD, BR,AD)
● Each field requires a decoder to produce the
corresponding control signals.
● Each of the three fields of the microinstruction
presently available in the output of control memory
are decoded with a 3x8 decoder to provide eight
outputs.
● Each of these outputs must be connected to the
proper circuit to initiate the corresponding
microoperation.
22
Microprogram Sequencer
● The basic components of microprogrammed control unit are the control memory and the circuits that select
the next address.
● The address selection part is called as microprogram sequencer.
● Microprogram sequencer can be constructed with digital functions to suit a particular application.
● Two imp. factors that must be considered while designing the microinstruction sequencer:
○ The size of the microinstruction.
○ The address generation time.
● The purpose of microprogram sequencer is to present an address to the control memory so that a
microinstruction may be read and executed.
● The next address logic of the sequencer determines the specific address source to be loaded into the CAR.
● The choice of the address source is guided by the next address information bits that the sequencer receives
from address information bits that the sequencer receives from the present microinstruction.
23
[Link]
24
[Link]
1
General Register Organization
Central Processing Unit
● The part of the computer that performs the data-processing operations is called the central
processing unit(CPU).
● The register set stores data used during the execution of the instructions.
● ALU performs the required microoperations for executing the instructions.
● The control unit supervises the transfer of information among the registers and instructs the
ALU as to which operation to perform.
3
General Register Organization
● The combined value of a binary selection inputs specifies the control word.
● It consist of four fields SELA,SELB,and SELD contains three bit each and OPR field contains four
bits thus the total bits in the control word are 13-bits.
● The three bit of SELA select a source registers of the a input of the ALU.
● The three bits of SELB select a source registers of the b input of the ALU.
● The three bits of SELD select a destination register using the decoder.
● The four bits of OPR select the operation to be performed by ALU.
6
Example : R2=R1+R3
7
Stack Organization
8
Stack Organization
● A useful feature that is included in the CPU of most computers is a stack or last-in, first-out
(LIFO) list.
● The register that holds the address for the stack is called a stack pointer (SP) because its value
always points at the top item in the stack.
● The stack in digital computers is essentially a memory unit with an address register that can
count only after an initial value is loaded into it.
● The two operations of a stack are the insertion and deletion of items.
9
Register Stack
10
Register Stack
12
Memory Stack
13
Instruction Formats
14
Instruction Formats
● The bits of the instruction are divided into groups called fields.
1. Opcode field - specifies the operation to be performed.
2. Address field - specifies a memory address / processor register.
3. Mode field - specifies the way the operand or the effective address is determined.
● The number of address fields depends on the internal organization of registers.
● Three types of CPU organizations:
1. Single accumulator organization.
Eg: ADD X
2. General register organization.
Eg: ADD R1, R2, R3 - MOV R1, R2
3. Stack organization
Eg: PUSH X
● Based on these, instructions are classified into four formats.
15
Three-Address Instruction
● Computers with three-address instruction formats can use each address field to specify either a
processor register or a memory operand.
● The program in assembly language that evaluates X = (A + B) * (C + D)
ADD R1, A, B // R1 ← M[A] + M[B]
ADD R2, C, D // R2 ← M[C] + M[D]
MUL X, R1, R2 // M[X] ← R1* R2
● Advantage - It results in short programs when evaluating arithmetic expressions.
● Disadvantage - The binary-coded instructions require too many bits to specify three addresses.
● Eg: Commercial computer Cyber 170.
16
Two-Address Instruction
17
One-Address Instruction
18
Zero-Address Instruction
19
Addressing Modes
20
Addressing Mode
21
1. Implied Mode
22
2. Immediate Mode
23
3. Register Mode
24
4. Register Indirect Mode
● The instruction specifies a register in the CPU whose contents give the address of the operand
in memory.
● The selected register contains the address of the operand rather than the operand itself.
● Before using a register indirect mode instruction, the programmer must ensure that the
memory address of the operand is placed in the processor register with a previous instruction.
● Advantage - The address field of the instruction uses fewer bits to select a register.
25
5. Autoincrement or Autodecrement Mode
● Similar to the register indirect mode except that the register is incremented or decremented
after (or before) its value is used to access memory.
● When the address stored in the register refers to a table of data in memory, it is necessary to
increment or decrement the register after every access to the table.
● This can be achieved by using the increment or decrement instruction.
26
[Link] Address Mode
27
7. Indirect Address Mode
● The address field of the instruction gives the address where the effective address is stored in
memory.
● Control fetches the instruction from memory and uses its address part to access memory again
to read the effective address.
28
8. Relative Address Mode
● Content of the program counter is added to the address part of the instruction in order to
obtain the effective address.
● The address part of the instruction is usually a signed number (positive or negative).
● This number is added to the content of the program counter, producing an effective address
whose position in memory is relative to the address of the next instruction.
● It is often used with branch-type instructions.
● Example:
Let PC contains the number 825.
The address part of the instruction contains the number 24.
The instruction at location 825 is read from memory during the fetch phase and the program
counter is then incremented by one to 826.
The effective address computation for the relative address mode is 826 + 24 = 850.
29
9. Indexed Addressing Mode
● Content of an index register is added to the address part of the instruction to obtain the
effective address.
● The index register is a special CPU register that contains an index value.
● The address field of the instruction defines the beginning address of a data array in memory.
● The distance between the beginning address and the address of the operand is the index value
stored in the index register.
● Any operand in the array can be accessed with the same instruction if the index register
contains the correct index value.
● The index register can be incremented to facilitate access to consecutive operands.
30
10. Base Register Addressing Mode
● In this mode the content of a base register is added to the address part of the instruction to
obtain the effective address.
● Similar to the indexed addressing mode except that the register is now called a base register.
● The difference between the two modes is in the way they are used rather than in the way that
they are computed.
● A base register holds a base address and the address field of the instruction gives a
displacement relative to this base address.
● This mode is used to facilitate the relocation of programs in memory.
● When programs and data are moved from one segment of memory to another, as required in
multiprogramming systems, the address values of instructions must reflect this change of
position.
● Here only the value of the base register requires updating to reflect the beginning of a new
memory segment.
31
Data Transfer and Manipulation
32
Data Transfer & Manipulation
● Computers provide an extensive set of instructions to give the user the flexibility to carry out
various computational tasks.
● The basic set of operations available in a typical computer can be classified into three
categories:
1. Data transfer instructions
2. Data manipulation instructions
3. Program control instructions
● Data transfer instructions cause transfer of data from one location to another without changing
the binary information content.
● Data manipulation instructions are those that perform arithmetic, logic, and shift operations.
● Program control instructions provide decision-making capabilities and change the path taken by
the program when executed in the computer.
33
Data Transfer Instruction
● Data transfer instructions move data from one place in the computer to another without
changing the data content.
● The most common transfers are between memory and processor registers, between processor
registers and input or output, and between the processor registers themselves.
● Typical Instructions are,
1. Load (LD) - Transfer from memory to a processor register, usually an accumulator.
2. Store (ST) - Transfer from a processor register into memory.
3. Move (MOV) - Transfer from one register to another.
4. Exchange (XCH) - Swaps information between two registers or a register and a memory
word.
5. Input (IN), Output (OUT) - Transfer data among processor registers and input or output
terminals.
6. Push (PUSH), Pop(POP) - Transfer data between processor registers and a memory stack.
34
Data Manipulation Instructions
● Perform operations on data and provide the computational capabilities for the computer.
● Divided into three basic types:
1. Arithmetic instructions.
2. Logical and bit manipulation instructions.
3. Shift instructions.
35
Arithmetic Instructions
36
Logical and Bit Manipulation Instructions
● Clear (CLR)
● Complement (COM)
● AND (AND)
● OR (OR)
● Exclusive-OR (XOR)
● Clear carry (CLRC)
● Set carry (SETC)
● Complement carry (COMC)
● Enable interrupt (EI)
● Disable interrupt (DI)
37
Shift Instructions
● Shifts are operations in which the bits of a word are moved to the left or right.
● The bit shifted in at the end of the word determines the type of shift used.
● Types
1. Logical Shift.
2. Arithmetic Shift
3. Rotate Shift
38
Logical Shift
39
Arithmetic Shift
● Arithmetic Shift Right - Preserve sign bit in the left most position. Sign bit shifted to right along
with other numbers but sign bit remain unchanged.
40
Rotate Shift
● Bits are shifted out one end are not lost but circulated back into other end.
● Rotate Left Through Carry(ROLC), Rotate right through Carry (RORC) treats carry bit as an
extension of register whose word is being rotated.
41
Program Control
42
Program Control Instructions
● Program control instructions specify conditions for altering the content of the program counter.
● Provides decision making capabilities.
● Branch (BR) : BR ADR, branch the program to Address ADR. (PC←ADR)
● Jump (JMP)
● Skip (SKP) : Skip instruction(PC←PC + 1) if some condition is met.
● Call (CALL) : Used with subroutines
● Return (RET)
● Compare (CMP) : Compare by subtraction.
● Test (by ANDing) TST : AND instruction without storing result.
43
[Link]
44
[Link]
1
Data Transfer and Manipulation
2
Data Transfer & Manipulation
● Computers provide an extensive set of instructions to give the user the flexibility to carry out
various computational tasks.
● The basic set of operations available in a typical computer can be classified into three
categories:
1. Data transfer instructions
2. Data manipulation instructions
3. Program control instructions
● Data transfer instructions cause transfer of data from one location to another without changing
the binary information content.
● Data manipulation instructions are those that perform arithmetic, logic, and shift operations.
● Program control instructions provide decision-making capabilities and change the path taken by
the program when executed in the computer.
3
Data Transfer Instruction
● Data transfer instructions move data from one place in the computer to another without
changing the data content.
● The most common transfers are between memory and processor registers, between processor
registers and input or output, and between the processor registers themselves.
● Typical Instructions are,
1. Load (LD) - Transfer from memory to a processor register, usually an accumulator.
2. Store (ST) - Transfer from a processor register into memory.
3. Move (MOV) - Transfer from one register to another.
4. Exchange (XCH) - Swaps information between two registers or a register and a memory
word.
5. Input (IN), Output (OUT) - Transfer data among processor registers and input or output
terminals.
6. Push (PUSH), Pop(POP) - Transfer data between processor registers and a memory stack.
4
Data Manipulation Instructions
● Perform operations on data and provide the computational capabilities for the computer.
● Divided into three basic types:
1. Arithmetic instructions.
2. Logical and bit manipulation instructions.
3. Shift instructions.
5
Arithmetic Instructions
6
Logical and Bit Manipulation Instructions
● Clear (CLR)
● Complement (COM)
● AND (AND)
● OR (OR)
● Exclusive-OR (XOR)
● Clear carry (CLRC)
● Set carry (SETC)
● Complement carry (COMC)
● Enable interrupt (EI)
● Disable interrupt (DI)
7
Shift Instructions
● Shifts are operations in which the bits of a word are moved to the left or right.
● The bit shifted in at the end of the word determines the type of shift used.
● Types
1. Logical Shift.
2. Arithmetic Shift
3. Rotate Shift
8
Logical Shift
9
Arithmetic Shift
● Arithmetic Shift Right - Preserve sign bit in the left most position. Sign bit shifted to right along
with other numbers but sign bit remain unchanged.
10
Rotate Shift
● Bits are shifted out one end are not lost but circulated back into other end.
● Rotate Left Through Carry(ROLC), Rotate right through Carry (RORC) treats carry bit as an
extension of register whose word is being rotated.
11
Program Control
12
Program Control Instructions
● Program control instructions specify conditions for altering the content of the program counter.
● Provides decision making capabilities.
● Branch (BR) : BR ADR, branch the program to Address ADR. (PC←ADR)
● Jump (JMP)
● Skip (SKP) : Skip instruction(PC←PC + 1) if some condition is met.
● Call (CALL) : Used with subroutines
● Return (RET)
● Compare (CMP) : Compare by subtraction.
● Test (by ANDing) TST : AND instruction without storing result.
13