Control Unit Functions in CPU Design
Control Unit Functions in CPU Design
COA- Module 5
1
COA- MODULE V
BASIC PROCESSING
UNIT
COA- Module 5
4
Machine Cycle
COA- Module 5
Model of Control Unit
COA- Module 5
Functions of Control Unit using Control Signals
Sequencing
CU causes the CPU to step through a series of micro-
operations in proper sequence based on the program being
executed.
E.g. In order to carry out a task such as ADD, the control unit
must generate a set of control signals in a predefined
sequence governed by the HW structure of the processing
section.
Execution
CU causes each micro-operation to be performed
Control Signals
External: inputs indicating the state of the system
Internal: logic required to perform the sequencing and
execution functions
COA- Module 5
Fundamental Concepts contd..
Inputs to control unit are:
Master clock
Status info from processing section
Command signals from external agent
Outputs produced by control unit
Signals that drive the processing section and responses to an external
envent (operation complete or abort) due to exceptions (overflow and
underflow)
Control unit undertakes the following responsibilities
Instruction interpretation:
COA- Module 5
Fetch/execute cycle
Step I:
Fetch the contents of the memory location pointed
to by Program Counter (PC).
PC points to the memory location which has the
instruction to be executed.
Load the contents of the memory location into
Instruction Register (IR).
Step II:
Increment the contents of the PC by 4 (assuming the
memory is byte addressable and the word length is 32
bits).
Step III:
Carry out the operation specified by the instructions in the
IR.
Steps I and II constitute the fetch phase, and are repeated
as many times as necessary to fetch the complete
instruction.
COA- Modulephase.
Step III constitutes the execution 5 10
Internal organization of a processor
COA- Module 5 11
Organization
PC
Decoder
contr
MAR ol
IR
memory
bus MDR Register
file
R0
Y
R1
R2
AL
U Rn-1
Z
CPU
bus 5
COA- Module 12
Register
Const Y_in
gating Ri_in
4
Y x
x
Select MUX Ri
ALU x
Z_in x Ri_out
Z
Z_out
C
P
COA- Module
U 5 13
Input & Output Gating for one Register Bit
COA- Module 5 1
4
Registers and the
bus
bus line 0
bus line 1
register
Instruction
Addres
decoder
s line
s MAR and control
logic
Memor
y bus
MDR HAS
TWO INPUTS MDR
AND TWO Dat
a IR
OUTPUTS line
s
Y
Constant R0
4
Selec MUX
processor
t
Internal
Ad
Bus
d A B
ALU Sub R n - 1
contr ALU
ol
lines Carry-
XOR in TEMP
Single bus organization
COA- Module 5
Single bus organization (contd..)
Instruction decoder and control logic block, or control
unit issues signals to control the operation of all units
inside the processor and for interacting with the
memory bus.
Control signals depend on the instruction loaded in the
Instruction Register (IR)
Outputs from the control logic block are connected to:
Control lines of the memory bus.
ALU, to determine which operation is to be performed.
Select input of the multiplexer MUX to select between
Register Y and constant 4.
Control lines of the registers, to select the registers.
COA- Module 5
Single bus organization (contd..)
COA- Module 5
Registers and the bus (contd..)
COA- Module 5
The Processing Unit
1. Basic Processing
Cycle
1. Register Transfer
2. Types of Operations 2. Fetch from Memory
3. Control Mechanisms 3. Store to Memory
4. Arithmetic/Logic Ops.
5. Execution of Complete
Instruction
6. Branching Ops.
COA- Module 5
2. Types of Operations
COA- Module 5
2.1. Register Transfers
COA- Module 5
Registers and the bus (contd..)
Bu
s
D Q
1
Q Riout
Cloc
Ri in k
Bu
s
D Q
1
Q Riout
Cloc
Ri in k
Riin = 1:
Multiplexer selects the data on the bus.
Data is loaded into the flip-flop at the rising edge of the
clock.
Riin = 0:
Multiplexer feeds back the value currently stored in the flip-
flop. Q output represents the value currently stored in the
COA- Module 5
flip-flop. 26
Registers and the bus (contd..)
Bu
s
D Q
1
Q Riout
Cloc
Ri in k
Riout = 1:
Tri-state gate loads the value of the flip-flop onto the
bus. Data is loaded onto the bus at the rising edge of
the clock.
Riout = 0:
Gate’s output is in high-impedance (electrically disconnected)
state. Corresponds to open-circuit state.
COA- Module 5 27
Registers and the bus (contd..)
0 0
D D
1 Q 1 Q
Cloc
Q Cloc
Q
Riin k Riin k
COA- Module 5 28
Registers and the bus (contd..)
0 0
D D
1 Q 1 Q
Cloc
Q Cloc
Q
Riin k Riin k
COA- Module 5
Registers and the bus (contd..)
Operation of an edge-triggered
flip-flop
Low-to-High transition
• Data is loaded from the register to the bus (or to the register from the
bus) at the rising edge of the clock.
• Data is loaded at the L-H transition of the clock.
COA- Module 5
Simple register transfer example
Clock period
1 3
2
[Link] signals R3out and R4in become 1. They stay valid until the
end of the clock cycle.
[Link] a small delay, the contents of R3 are placed onto the bus. The
contents of R3 stay onto the bus until the end of the clock cycle.
3. At the end of the clock cycle, the data onto the bus is loaded into R4.
R3out
and R4in become 0.
COA- Module 5
The Processing Unit
1. Basic Processing
Cycle
1. Register Transfer
2. Types of Operations 2. Fetch from Memory
3. Control Mechanisms 3. Store to Memory
4. Arithmetic/Logic Ops.
5. Execution of Complete
Instruction
6. Branching Ops.
COA- Module 5
2.2. Fetch from Memory (1)
x x
MDR
x x
MDR_in MDR_i
E n
COA- Module 5
2.2. Fetch from memory (2)
e.g., Move (Ri),Rj
Control Step
1 MAR
1 . [Ri]
Start read on memory
Control Step 2 bus Wait for MFC Memory
2 . response Load MDR from Function
Control Step 3 memory bus Rj Complete
3 . [MDR]
4
Addres
. MAR s
5 Dat
. MDR a CPU
Rea
Memor
Memory d
y MF
C
COA- Module 5
Fetch from memory (3)
Signal Activation Sequence Internal
processor
Control Step Ri_out, MAR_in, Read bus
1. MDR_inE,
Ri_in
Control Step WMFC
2. MDR_out, Rj_in
Control Step x
3.
MDR_out MDR_ou
Ri
E t
Memory x x
bus Data MD x
lines R
x x Ri_out
MDR_in MDR_i
E n
COA- Module 5
2.2. Fetch from Memory
Timing
(4) 1 of the Operation2
3 1. Ri_out, MAR_in,
CLK Read
2. MDR_inE,
WMFC
3. MDR_out, Rj_in
MAR_i
n
New MAR to
addres Address [Link]
s Read
MR [Link]
Cmd.
MDR_in
E
Valu [Link] to
Dat e MDR
[Link]
a ete
MDR_ou
MFC
t
COA- Module 5
The Processing Unit
1. Basic Processing
Cycle
1. Register Transfer
2. Types of Operations 2. Fetch from Memory
3. Control Mechanisms 3. Store to Memory
4. Arithmetic/Logic Ops.
5. Execution of Complete
Instruction
6. Branching Ops.
COA- Module 5
2.3. Store into Memory
Dat
Memor a CPU
y
Writ
e
MF
C
COA- Module 5
The Processing Unit
1. Basic Processing
Cycle
1. Register Transfer
2. Types of Operations 2. Fetch from Memory
3. Control Mechanisms 3. Store to Memory
4. Arithmetic/Logic Ops.
5. Execution of Complete
Instruction
6. Branching Ops.
COA- Module 5
2.4. Arithmetic Operation
ADD R3,R2,R1
Step Action
1. Address out _
R1
Y_in
R_out
2
. Address out
_R2 R_out
F_alu
“ADD”
Address in _
Z_in
R3 Z_out
R_in
COA- Module 5
CO-Unit VI-Basic Processor
Register Transfers
1. Address_out R1 R_out
CPU bus
Y_in
R_ou
t
R0
Y_in Y
R1
R2
ALU
R3
Z register file
Address_out
COA- Module 5
Register Transfers
2. Address_out
R2 R_out CPU bus R_out
F_alu “ADD”
Z_in
R0
Y_in Y
R1
R2
F_alu
ALU
R3
Z_in Z register file
Address_out
COA- Module 5
Register Transfers
R2
ALU
R3
Z register file
Z_out R_in
Address_in
COA- Module 5
Steps in
time CPU bus
Ste 1 2 3
Y_in
p Y
Y_in
Z_i ALU
n
Z_in Z
Z_ou
t
R_in
Z_out
COA- Module 5
The Processing Unit
1. Basic Processing
Cycle 1. Register Transfer
2. Types of Operations 2. Fetch from Memory
3. Control Mechanisms 3. Store to Memory
4. Arithmetic/Logic Ops.
5. Execution of Complete
Instruction
6. Branching Ops.
COA- Module 5 46
2.5. Execution of a Complete Instruction
1 Fetch instruction
. Fetch the
2 operand Perform
. operation Store
3 result
.
Exampl ADD (R3),R1
e 4
[R1]
. M([R3]) +
[R1]
COA- Module 5 47
Execution fetch (1)
[R1] M([R3]) +
Step Action
[R1]
1 PC_out, MAR_in,
Read Set carry-in Step 1-3:
ALU Instruction fetch and
F_alu = PC update
“ADD” Z_in
Z_out,
PC_in Wait
for MFC [PC] [PC ]
3 MDR_out, +1
IR_in
[IR] M([PC ])
COA- Module 5
Fetch [R1] M([R3]) +
[R1] 1.. PC_out, MAR_in,
instruction
MAR_in
MAR Read Set carry-in
ALU
PC_out F_alu = “ADD”
Z_in
PC IR
Read
COA- Module 5
Fetch
[R1] M([R3]) +
instruction [R1]
MAR_in
MAR
PC_in IR
PC
Z_out,
PC_in Wait
for MFC ALU MDR
MDR_in
Z
Read
COA- Module 5
Execution fetch [R1] M([R3]) +
(3) [R1]
Step 1-3:
Step Action instruction
1 PC_out, MAR_in, fetch
Read Set carry-in and PC
ALU update
F_alu =
“ADD” Z_in
Z_out,
PC_in Wait
for MFC
[IR]
3 MDR_out,
M([PC ])
IR_in
COA- Module 5
Fetch [R1] M([R3]) +
instruction [R1]
3. MDR_out, IR_in Q What is loaded into
MAR IR?
PC IR
IR_in
ALU MDR
Read
MDR_out
WFMC
COA- Module 5
Execute
Step Action
4 Address_out=R3, Step 4 and 5:
R_out MAR_in operand fetch
Read
Address_out=R1,
Perform
R_out Y_in, Wait for
addition
MFC
6 MDR_out,
Z_in F_alu =
Store
“ADD”
Result
7 Address_in=R1,
R_in Z_out, End
COA- Module 5
Execute
Read
PC Decoder
control
MAR
IR
memory bus
MDR register file
4. R0
R3_out Y
MAR_i R1
n Read
R2
ALU
R3
Z
Step Action
4 Address_out=R3, Step 4 and 5:
R_out MAR_in operand fetch
Read
Address_out=R1,
R_out Y_in, Wait for Perform
MFC addition
6 MDR_out,
Z_in
F_alu =
7 “ADD”
Address_in=R1, Store
R_in Z_out, End Result
COA- Module 5 56
Execute
WFMC Decoder
PC
control
MAR
IR
memory bus
CPU bus
MDR
R0
Y
R1
R1_out
Y_in, Wait for MFC R2
ALU
R3
Z register file
Step Action
4 Address_out=R3,
R_out MAR_in Step 4 and 5:
Read operand fetch
Address_out=R1,
R_out Y_in, Wait for Perform
MFC addition
6 MDR_out,
Z_in F_alu =
Store Result
“ADD”
7 Address_in=R1,
R_in Z_out, End
COA- Module 5
Execut [R1] M([R3]) +
[R1]
e
6. MDR_out, Decoder
Z_in F_alu = PC
“ADD” control
MAR
IR
memory bus
MDR register file
R0
Y
R1
R2
Q Why ALU
Z_in? R3
Z
Q) Who sets F_alu to
CPU bus ADD?
COA- Module 5
[R1] M([R3]) +
Execut [R1]
e
Step Action
4 Address_out=R3,
Step 4 and 5:
R_out MAR_in
operand fetch
Read
Address_out=R1,
Perform
R_out Y_in, Wait for
addition
MFC
6 MDR_out,
Z_in Store
F_alu = Result
7 “ADD”
Address_in=R1,
R_in Z_out, End
COA- Module 5
Execute
Decoder
7. R1_in PC
Z_out,
End control
MAR
IR
memory bus
MDR register file
R0
Y
R1
R2
ALU
R3
Z
1. Basic Processing
Cycle
1. Register Transfer
2. Types of 2. Fetch from Memory
Operations
3. Store to Memory
3. Control Mechanisms 4. Arithmetic/Logic Ops.
5. Execution of Complete
Instruction
6. Branching Ops.
6
2
COA- Module 5 62
2.6. Branching
Jump: PC+Offset
Step Action
1-3 <instruction fetch
as in previous
example>
PC_out,
Y_in
5 Offset-field-
IR_out F_alu =
“ADD” Z_in
6 PC_in
Z_out,
End
COA- Module 5 63
Branching
Decoder
PC_out, Y_in PC
control
MAR
IR
memory bus
MDR register file
R0
Y
R1
R2
ALU
R3
Z
CPU bus
CO-Unit VI-Basic Processor COA- Module 5 64
Unit
Branching
Step Action
1-3 <instruction fetch
as in previous
example>
PC_out,
Y_in
5 Offset-field-
IR_out F_alu =
“ADD” Z_in
6 PC_in
Z_out,
End
COA- Module 5 65
Branching
5. Offset-field- PC Decoder
IR_out F_alu =
“ADD” Z_in control
MAR
IR
memory bus
MDR
register file
R0
Y
R1
R2
ALU
R3
Z
CPU bus
CO-Unit VI-Basic Processor COA- Module 5 66
Unit
Branching
Step Action
1-3 <instruction fetch
as in previous
example>
PC_out,
Y_in
5 Offset-field-
IR_out F_alu =
“ADD” Z_in
6 PC_in
Z_out,
End
COA- Module 5
CO-Unit VI-Basic Processor
Branching
Decoder
6. PC_in PC
Z_out, control
End
MAR
IR
memory bus
MDR
R0
Y
R1
R2
ALU
R3
Z register file
CPU bus
COA- Module 5
Conditional branching
JN : PC+Offset
Step Action
1-3 <instruction fetch
as in previous
example>
PC_out, Y_in If not
If N=0 then Negative
End
5 Offset-field-
IR_out F_alu =
“ADD” Z_in
6 PC_in
Z_out,
End
COA- Module 5 69
2. Performing an Arithmetic or Logic
Operation2.
Ex. R3 R1+ Internal
bu
processor
R2
What is the sequence of Riin
s
operations ?
Ri
Step 1: Output of the register R1 and input
of the register Y are enabled, causing Riout
the contents of R1 to be transferred to Yin
Y.
Step 2: The multiplexer’s select signal is set Y
to select Y causing the multiplexer to gate Constant
the contents of register Y to input A of the 4
ALU.
R1out, Yin
Selec MUX
t
Step 3: The contents of Z are transferred A B
R2out, SelectY, Add,
to the destination register R3. ALU
Zin
Zin
Zout, R3in
Z
Zout
COA- Module 5 70
Ex. Move (R1),R2.
The sequence of steps
is:
1)R1out, MARin, Read ;desired address
Read is loaded into MAR &
command is issued
2) MDRinE, WMFC ;load MDR from memory bus & Wait for
MFC response from memory
3)MDRout R2in
,
;load R2 from MDR
where WMFC=control signal that
causes
processor's control circuitry to wait for
arrival of MFC signal
COA- Module 5
Control sequence for the
instruction
EX. Move (Rs),Rd
5)MDRinE, WMFC
COA- Module 5
Execution of a complete instruction
Consider the instruction Add
(R3),R1 Which adds he contents of
a memory- Location
pointed by R3 to register
R1.
Executing this instruction
requires the following
actions:
1)Fetch the instruction.
2)Fetch the first operand.
3)Perform the addition.
4)Load the result into R1.
COA- Module 5
Instruction
Execution
Instruction execution proceeds as follows: R1← R1 + [R3]
Step1:The instruction-fetch operation is initiated by loading contents
of PC into MAR & sending a Read request to memory. The Select
signal is set to Select4, which causes the Mux to select constant 4.
This value is added to
operand at input B (PC‟s content), and the result is stored in Z
Step2: Updated value in Z is moved to PC.
Step3: Fetched instruction is moved into MDR and then to IR.
Step4: Contents of R3 are loaded into MAR & a
memory read signal is issued.
Step5: Contents of R1 are transferred to Y
Step6: When Read operation is to
completed,memory-operand is available in MDR,
Prepare for addition.
addition
and the is performed.
Step7: Sum is stored in Z, then transferred to R1.
The End signal causes a new instruction fetch
cycle to begin by returning to step1.
COA- Module 5
Single Bus organization of the data path within a
CPU
COA- Module 5
Internal organization of a
Internal processor
processor bus
Control signals
PC
Instruction
Addres
decoder
s line
s MAR and control
logic
Memor
y bus
MDR
Dat
a IR
line
s
Y
Constant R0
4
Selec MUX
t
Ad
d A B
ALU Sub R n - 1
contr ALU
ol
lines Carry-
XOR in TEMP
Z
COA- Module 5
Execution of a Complete Instruction
COA- Module 5
Execution of a Complete Instruction
Add R2,
R1
R2out
COA- Module 5 78
Execution of Branch Instructions
A branch instruction replaces the contents of PC with
the branch target address, which is usually obtained
by adding an offset X given in the branch instruction.
The offset X is usually the difference between the
branch target address and the address immediately
following the branch instruction.
Unconditional branch
COA- Module 5
79
Execution of Branch Instructions
The processing starts, as usual, the fetch phase ends in step3.
In step 4, the offset-value is extracted from IR by instruction-decoding circuit.
Since the updated value of PC is already available in register Y, the offset X is
gated
onto the bus, and an addition operation is performed.
In step 5, the result, which is the branch-address, is loaded into the PC.
Step Action
4 C MDRout , IRin
5 Offset-field-of-IRout,
Add, Zin
Zout, PCin for
Fig. Control sequence , End
an unconditional branch
instruction.
Step Action
COA- Module 5
Exercise
COA- Module 5 86
The Processing Unit
1. Basic Processing
Cycle
2. Types of Operations
3. Control
Mechanisms 1. Hardwired
Q Who sets F_alu to
ADD? 2. Micro-
Programmed
8
7
COA- Module 5 87
Hardwired
Control
COA- Module 5
88
3 Control Mechanism- Overview
COA- Module 5 89
Hardwired vs Microprogrammed
Hardwired
Use gates to generate signals
Squeeze out the juice for performance(not flexible)
Different logic styles possible
Economical initially
Small changeredesign
Microprogrammed
Store the control signals in the sequence
Just read from the memory every clock cycle
Expensive initially
Additions done by simply changing the
microprogram in
control memory
Diagnostics routine can be made available in
memory
COA- Module 5
3.1 HARDWIRED APPROACH
CLK Control
Clock step
counter
Extern
al
inputs
Decode
IR
r/
encode Conditio
r n
codes
Control signals
[Link] unit
organization.
COA- Module 5
92
Hardwired Control -Separating
decoding/encoding
Clock Control
Rese
CLK
step
t
counter
Step decoder
Only one set
to 1 T_1
Ins_ T_n
1 Statu
s
IR Instruction Encoder Flag
decoder s
Conditio
Ins_
n
n
Codes
Ru
Z_in End
n
Q) Role of
COA- Module 5 Run ? 93
Decoder/encoder block is a combinational-circuit that
generates required control-outputs depending on state of
Step-decoder provides a separate signal line all
for its inputs.
each step
in the control sequence.
Similarly, output of instruction-decoder consists of a
separate line
for each machine instruction.
For any instruction loaded in IR, one of the output-lines INS1
through INSm is set to 1, And all other lines are set to
The input signals to encoder-block are combined to
generate the individual control- signals Yin, PCout, Add,
End and so on.
COA- Module 5 9
4
3.1. Hardwired Control -Generation of control
signals
AD BRanch
Z_in = T_1 + T_6 . ADD + T_4 . D T_6 T_4
BR
time
slot
T_1
Z_i
n
COA- Module 5 95
This signal is asserted during time-slot T1 for all
COA- Module 5 9
6
Generation End control
signal
End = T_7 . ADD + T_5 . BR +(T_5 . N + T_4 . /N) .BRN+ . .
..
COA- Module 5 97
3.1. Hardwired Control-Performance
COA- Module 5
Complete CPU
Instruction Intege
Intege Floating-
Floating-
Intege Floating-
r point
unit r r point
point
unit
unit unit
unit
unit unit
Instructio Data
n Cach
Cache e
Bus
Interfac Processor/
e CPU
System
Main Bus Input/
Memor Outpu
y t
COA- Module 5
A Complete Processor
This has separate processing-units to deal with integer data and
floating-point data.
A data-cache is inserted between these processing-units & main-
memory.
Instruction-unit fetches instructions
→ from an instruction-cache or
→ from main-memory when desired instructions are not already in
cache
Processor is connected to system-bus & hence to the rest of
the computer by means of a bus interface
Using separate caches for instructions & data is common
practice in
many processors today.
A processor may include several units of each type to
increase the potential for concurrent operations
COA- Module 5 10
1
Micro programmed
Control
COA- Module 5
3.2. Micro-programmed control
COA- Module 5
Microprogrammed Control
Address Microinstruction
0 PCout , MAR in , Read, Select4,Add,
1 Zin Zout , PCin , Yin , WMFC
2
MDRout , IRin
3 Branch to starting address of appropriate
microroutine
2. . . . . . . . If
. . N=0,
. . . . .then
. . . . branch
. . . . . .to
....................
.....................
5 microinstruction 0 Offset-field-of-
2
IRout , SelectY, Add, Zin Zout , PCin ,
6
End
2
Fig. Microroutine for the instruction
7
Branch<0.
COA- Module 5
107
Micro programme Unit for Conditional
Branching
Extern
al
inputs
Starting
branch Conditio
IR and n
generat
address codes
or
Clock PC
Contr
ol CW
store
Fig. Organization of the control unit to allow
conditional branching in the micro
program.
COA- Module 5
108
Conditional
Branching
In case of conditional branching, microinstructions specify
which of the external inputs, condition-codes should be
checked as a condition for branching to take place.
The starting and branch address generator block loads a
new
address into µPC when a microinstruction instructs it to do
so .
To allow implementation of a conditional branch, inputs
to this block consist of
→ external inputs and condition-codes
→ contents of IR
µPC is incremented every time a new microinstruction is
fetched from
microprogram memory except in following
situations
i) When a new instruction is loaded into IR, µPC is loaded
with starting-address of microroutine for that
instruction.
ii) When a Branch microinstruction
COA- Module 5is encountered and 10
9
Microinstructions
COA- Module 5
Microprogrammed control (contd..)
Microinstruction format
Examples:
COA- Module 5
3.2. Micro-Programmed
Control Structure micro-
instructions
Most simple organization: 1 bit per control signal
However,
Many bits needed (e.g., 80-120 bits)
For many signals, only one is needed per cycle; hence they can be
grouped
Coding is possible: e.g., an address instead of a single control bit
per
register
Alternative approach to reduce the length of the microinstruction:
• Enumerate the patterns of the required signals in all microinstructions.
• Assign each meaningful combination of active control signals a unique
code.
• Code represents the microinstruction .
• Grouping control signals into fields requires a little more hardware:
Decoding circuits are needed to decode patterns to individual control
signals.
Cost of the additional hardware is offset by reduced number of bits
in each microinstruction:
theReduces COA- Module 5
decoderthe size of the control 114
store.
3.2. Micro-Programmed
Control Forms of
organization
Little coding: horizontal
organization
Large words
Little decoding logic
Fast
Much coding: vertical organization
Small control store
Much decoding logic
Slower
Mixed organization
COA- Module 5
3.2. Micro-Programmed Control
Horizontal/Vertical
F0 F1 F2 F3
Horizont
al
R0 R1 R2
R3
F0 F1
Decoder
Vertic
al
R0 R1 R2
R3
COA- Module 5
3.2. Micro-Programmed
Control Sequencing
COA- Module 5
3.2. Micro-Programmed
Control Multi-way branching
COA- Module 5
3.2. Micro-Programmed
Control Example
branch
addres
s
xxx000 micro-
instruction
O
R
wyz part of
IR
xxxwyz
actual
branch
addres
s
COA- Module 5
Mapping of Instruction
Example
Mapping 3-bit operation code to 7-bit
address
ADD of 0000
OP-codes Instructions
AND 0001
LDA 0010 Control
memory
Mapping bits 0 xxx 00 Address
0 000 00 ADD Routine
COA- Module 5
3.2. Micro-Programmed
Control
Example microroutine (1)
ADD (Rsrc)+, Rdst
Mod
e
IR OP code 010 Rsrc Rdst
11 8 4 3 0
10 7
Instruction bit 8: direct/indirect
Format bit 9,10: indexed (11)
autodecrement(
10)
autoincrement(0
1) register(00)
COA- Module 5
3.2. Micro-Programmed Control
Example microroutine (2)
Address Micro-instruction
11 9 8 4 3
10 7 0
/IR10./
IR9.IR8
10
PL
A
1
0 0 1 0 1 0 0 0
1
12
1
COA- Module 5
3.2. Micro-Programmed
Control Micro branch
address
Mod
e
IR OP code 010 Rsrc Rdst
11 8 4 3
10 7 0
IR
8
17
0
PL
A
0 0 1 1 1 10 0
1
17
1
COA- Module 5
Microprogram sequencing-
COA- Module 5
Start of instruction fetch.
COA- Module 5
Microprogrammed control (contd..)
Start of instruction fetch.
ADD Rsrc, Rdst
COA- Module 5
Branch Address Modification Using Bit-ORing
COA- Module 5
Microprogrammed control (contd..)
Microinstructions with the next-address field.
COA- Module 5
Microprogrammed control (contd..)
Microinstructions with the next-address field.
COA- Module 5
Next-address field
(2)
Status IR Conditio
flags n
codes
Decoding
circuits
micro-AR
Control
Microinstruction
decoder
COA- Module 5
Next-address field
The microprogram discussed earlier requires several
branch microinstructions, which perform no useful
operation in the datapath.
A powerful alternative approach is to include an
address field as a part of every microinstruction to
indicate the location of the next microinstruction to
be fetched.
Pros: separate branch microinstructions are
virtually eliminated; few limitations in assigning
addresses to microinstructions.
Cons: additional bits for the address field
(around 1/6)
COA- Module 5 13
5
3.2. Micro-Programmed
Control Example
F0 F1 F2 F3 F4 F5 F6 F7 F8
Prefetchin
g
Emulation
COA- Module 5 13
9
Prefetching
Microprogrammed control leads to slower operating
speed because of the time it takes to fetch
microinstructions from the control store.
To achieve faster operation, the next microinstruction
can
be prefetched while the current one is being executed.
Execution time can be overlapped with the fetch time.
the next microinstruction is pre-fetched while the
current one is being executed.
Prefetching microinstructions presents some
difficulties:
Status flags and the results of the current microinstruction
that is being executed are necessary to determine the
address of the next microinstruction.
Straightforward prefetching may occassionally fetch a
wrong
instruction.
increased operation COA- Module 5 140
Fetch must be repeated.
speed.
Emulation
The main function of microprogrammed control is to provide a
means for simple, flexible and relatively inexpensive
execution of machine instruction.
Control offers the flexibility to add new instructions to the
instruction set of a processor.
New microroutines need to be added to implement
the new instructions.
Add to the instruction set of a given computer M1 an entirely new set
of instructions that is in fact the instruction set of a different
computer M2.
Programs written in the machine language of M2 can be run on
M1 .
M1 emulates M2.
Emulation allows transition to new computer systems with
minimal
E m udisruption.
l a t io n is easiest when the machines involved
ar ch i t e c t u re .
have similar
Emulation allows us to replace obsolete equipment with
COA- Module 5
more up-to-date
Implementation of the Microroutine
Addres Microinstructi
s on
(octal)
00 PC , MAR in
, Read, 4 , Add, in
out
0 Select Z
00
1 Z , PC , IR, Y , WMFC
00 MDR
out
out
in
in
in
2
00 Branch PC 101 (from Instruction
3 { decoder);
PC ]; PC [IR [IR 9 ] [IR
5,4 10,
8 ]} 10 ]
[IR 9
, Read, 3
Select4,
12 Rsrc out , MAR in
1 Add, Z
in
12 Z , Rsrc
out in
2
12 Branch { [IR 8 ]},
170; PC 0
3 PC WMFC
17 MDR out , MAR , Read,
0 WMFC
in
17 MDR ,Y
out in
1
17 Rds out , , Add, in
2 t SelectY Z
17 Z , ,
3 Rdst End
out in
COA- Module 5
bit-ORing
COA- Module 5