Control unit-COA
Control unit-COA
RCA104
Microprogrammed Control
MICROPROGRAMMED CONTROL
• Control Memory
• Sequencing Microinstructions
• Microprogram Example
• Microinstruction Format
Control Data
Memory IR Status F/Fs
Microprogram
M Control Data
e
m
o IR Status F/Fs
r
y
C Control C
Next Address Storage C
S S D P CPU
Generation A (-program D
Logic s
R memory) R }
Microprogrammed Control
TERMINOLOGY
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
TERMINOLOGY
- In-line Sequencing
- Branch
- Conditional Branch
- Subroutine
- Loop
- Instruction OP-code mapping
Microprogrammed Control Sequencing
MICROINSTRUCTION SEQUENCING
Instruction code
Mapping
logic
Status MUX Multiplexers
bits Branchselect
logic
Subroutine
register
Control address register (SBR)
(CAR)
Incrementer
select a status
bit
Microoperations
Branch address
CONDITIONAL BRANCH
Load address
Control address register
Increment
MUX
Control memory
...
Status bits
(condition)
Next address
Conditional Branch
MAPPING OF INSTRUCTIONS
Direct Mapping Address
OP-codes of Instructions 0000 ADD Routine
0001 AND Routine
ADD 0000 0010
. LDA Routine
AND 0001 . 0011 STA Routine
LDA 0010 . 0100 BUN Routine
STA 0011 Control
BUN 0100 Storage
Mapping
10 xxxx 010
Bits Address
10 0000 010 ADD Routine
Mapping bits 0 x x x x 0 0
Microinstruction
address 0 1 0 1 1 0 0
Mapping memory
(ROM or PLA)
Control Memory
Microprogrammed Control Microprogram
MICROPROGRAM EXAMPLE
Computer Configuration
MUX
10 0
AR
Address Memory
10 0 2048 x 16
PC
MUX
15 0
6 0 6 0 DR
SBR CAR
Microinstruction Format
3 3 3 2 2 7
F1 F2 F3 CD BR AD
F3 Microoperation Symbol
000 None NOP
001 AC AC DR XOR
010 AC AC’ COM
011 AC shl AC SHL
100 AC shr AC SHR
101 PC PC + 1 INCPC
110 PC AR ARTPC
111 Reserved
Microprogrammed Control Microprogram
BR Symbol Function
00 JMP CAR AD if condition = 1
CAR CAR + 1 if condition = 0
01 CALL CAR AD, SBR CAR + 1 if condition = 1
CAR CAR + 1 if condition = 0
10 RET CAR SBR (Return from subroutine)
11 MAP CAR(2-5) DR(11-14), CAR(0,1,6) 0
Microprogrammed Control Microprogram
SYMBOLIC MICROINSTRUCTIONS
• Symbols are used in microinstructions as in assembly language
• A symbolic microprogram can be translated into its binary equivalent by a
microprogram assembler.
Sample Format
five fields: label; micro-ops; CD; BR; AD
SYMBOLIC MICROPROGRAM
• Control Storage: 128 20-bit words
• The first 64 words: Routines for the 16 machine instructions
• The last 64 words: Used for other purpose (e.g., fetch routine and other subroutines)
• Mapping: OP-code XXXX into 0XXXX00, the first address for the 16 routines are
0(0 0000 00), 4(0 0001 00), 8, 12, 16, 20, ..., 60
ORG 4
BRANCH: NOP S JMP OVER
NOP U JMP FETCH
OVER: NOP I CALL INDRCT
ARTPC U JMP FETCH
ORG 8
STORE: NOP I CALL INDRCT
ACTDR U JMP NEXT
WRITE U JMP FETCH
ORG 12
Microprogrammed Control Microprogram
BINARY MICROPROGRAM
Address Binary Microinstruction
Micro Routine Decimal Binary F1 F2 F3 CD BR AD
ADD 0 0000000 000 000 000 01 01 1000011
1 0000001 000 100 000 00 00 0000010
2 0000010 001 000 000 00 00 1000000
3 0000011 000 000 000 00 00 1000000
BRANCH 4 0000100 000 000 000 10 00 0000110
5 0000101 000 000 000 00 00 1000000
6 0000110 000 000 000 01 01 1000011
7 0000111 000 000 110 00 00 1000000
STORE 8 0001000 000 000 000 01 01 1000011
9 0001001 000 101 000 00 00 0001010
10 0001010 111 000 000 00 00 1000000
11 0001011 000 000 000 00 00 1000000
EXCHANGE 12 0001100 000 000 000 01 01 1000011
13 0001101 001 000 000 00 00 0001110
14 0001110 100 101 000 00 00 0001111
15 0001111 111 000 000 00 00 1000000
microoperation fields
F1 F2 F3
AND
ADD AC
Arithmetic
logic and
DRTAC shift unit DR
From From
PCTAR
DRTAR
PC DR(0-10) Load
AC
Select 0 1
Multiplexers
Load Clock
AR
Clock CAR
Control Storage
MUX-1 selects an address from one of four sources and routes it into a CAR
Input Logic
I1I0T Meaning Source of Address S1S0 L
MICROPROGRAM SEQUENCER
External
(MAP)
L
I0 3 2 1 0
Input Load
I1 S1 MUX1 SBR
logic
T S0
1 Incrementer
I MUX2 Test
S
Z Select
Clock CAR
Control memory
Microops CD BR AD
... ...
Microprogrammed Control Microinstruction Format
MICROINSTRUCTION FORMAT
Information in a Microinstruction
- Control Information
- Sequencing Information
- Constant
Information which is useful when feeding into the system
Field Encoding
Field A Field B
Field A Field B
2 bits 6 bits
2 bits 3 bits
2x4 6 x 64
2x4 3x8 Decoder Decoder
Decoder Decoder
Decoder and
1 of 4 1 of 8 selection logic
Microprogrammed Control Control Storage Hierarchy
Two-level microprogram
First level
-Vertical format Microprogram
Second level
-Horizontal format Nanoprogram
- Interprets the microinstruction fields, thus converts a vertical
microinstruction format into a horizontal
nanoinstruction format.
11 bits
Control memory
2048 x 8
Microinstruction (8 bits)
Nanomemory address
Nanomemory
256 x 200
Overview
Fundamental Concepts
• Processor fetches one instruction at a time and perform
the operation specified.
• Instructions are fetched from successive memory
locations until a branch or a jump instruction is
encountered.
• Processor keeps track of the address of the memory
location containing the next instruction to be fetched
using Program Counter (PC).
• Instruction Register (IR)
Central Processing Unit
Executing an Instruction
• Fetch the contents of the memory location pointed to by
the PC. The contents of this location are loaded into the
IR (fetch phase).
IR ← [[PC]]
• Assuming that the memory is byte addressable,
increment the contents of the PC by 4 (fetch phase).
PC ← [PC] + 4
• Carry out the actions specified by the instruction in the IR
(execution phase).
Central Processing Unit
Internal processor
bus
Processor Organization
Control signals
PC
Instruction
Address
decoder and
lines
MAR control logic
Memory
bus
MDR
Data
lines IR
Y
Constant 4 R0
Select MUX
Add
A B
ALU Sub R n - 1
control ALU
lines
Carry -in
XOR TEMP
Datapath
Executing an Instruction
Register Transfers
Internal processor
bus
Riin
Ri
Riout
Yin
Constant 4
Select MUX
A B
ALU
Zin
Zout
Figure 7.2. Input and output gating for the registers in Figure 7.1.
Central Processing Unit
Bus
Ri in
Clock
D Q
Figure 7.3. Input and output gating for one register bit.
Central Processing Unit
MDR inE
MDR
MDRout
MDRin
Internal processor
bus
Timing
MAR ← [R1]
Assume MAR
is always available
on the address lines
of the memory bus. Start a Read operation on the memory bus
Execution of a Complete
Instruction
• Add (R3), R1
• Fetch the instruction
• Fetch the first operand (the contents of the
memory location pointed to by R3)
• Perform the addition
• Load the result into R1
Central Processing Unit
Architecture
Internal processor
bus
Riin
Ri
Riout
Yin
Constant 4
Select MUX
A B
ALU
Zin
Zout
Figure 7.2. Input and output gating for the registers in Figure 7.1.
Central Processing Unit
Internal processor
bus
Execution of a Complete
Control signals
PC
Instruction
Address
decoder and
lines
MAR control logic
Memory
bus
MDR
Data
lines IR
Step Action Y
Constant 4 R0
7 Zout , R1 in , End
Instruction
Figure 7.6. Control sequencefor executionof the instruction Add (R3),R1.
Add (R3), R1
Central Processing Unit
Step Action
Multiple-Bus Organization
Bus A Bus B Bus C
Incrementer
PC
Register
f ile
Constant 4
MUX
A
ALU R
Instruction
decoder
IR
MDR
MAR
Multiple-Bus Organization
• Add R4, R5, R6
Step Action
PC
Quiz
Instruction
Address
decoder and
lines
MAR control logic
Memory
bus
MDR
Data
lines IR
Y
Constant 4 R0
Select MUX
Add
A B
ALU Sub R n - 1
control ALU
lines
Carry -in
XOR TEMP
External
inputs
Decoder/
IR
encoder
Condition
codes
Control signals
Step decoder
T 1 T2 Tn
Run End
Control signals
Generating Zin
• Zin = T1 + T6 • ADD + T4 • BR + …
Branch Add
T T
4 6
T
1
Figure 7.12. Generation of the Zin control signal for the processor in Figure 7.1.
Central Processing Unit
Generating End
Branch<0
Add Branch
N N
T7 T5 T4 T5
End
A Complete Processor
Instruction Data
cache cache
Bus interface
Processor
Sy stem us
b
Main Input/
memory Output
Overview
MDRout
WMFC
MAR in
Select
Read
PCout
R1out
R3out
Micro -
End
PCin
R1in
Add
Z out
IRin
Yin
Zin
instruction
1 0 1 1 1 0 0 0 1 1 1 0 0 0 0 0 0
2 1 0 0 0 0 0 1 0 0 0 1 0 0 0 1 0
3 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0
•
4 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0
programs.
• Control Word (CW); microroutine; microinstruction
Microprogrammed Control
Step
1
2
3
4
5
6
7
Action
Overview
generator
Clock PC
Control
store CW
• Control store
One function
cannot be carried
out by this simple
organization.
Microprogrammed Control
Overview
• The previous organization cannot handle the situation when the control unit is
required to check the status of the condition codes or external inputs to
choose between alternative courses of action.
• Use conditional branch microinstruction.
Address Microinstruction
Overview
External
inputs
Starting and
branch address Condition
IR codes
generator
Clock PC
Control
store CW
Microinstructions
F1 F2 F3 F4 F5
0000: No transf er 000: No transf er000: No transf er 0000: Add 00: No action
0001: PCout 001: PCin 001: MARin 0001: Sub 01: Read
0010: MDRout 010: IRin 010: MDRin 10: Write
0011: Zout 011: Zin 011: TEMPin
0100: R0out 100: R0in 100: Yin 1111: XOR
0101: R1out 101: R1in
0110: R2 110: R2in 16 ALU
out f unctions
0111: R3out 111: R3in
1010: TEMPout
1011: Of f set
out
F6 F7 F8
Microinstructions
Further Improvement
Microprogram Sequencing
• If all microprograms require only straightforward
sequential execution of microinstructions except for
branches, letting a μPC governs the sequencing would be
efficient.
• However, two disadvantages:
Having a separate microroutine for each machine instruction results in a
large total number of microinstructions and a large control store.
Longer execution time because it takes more time to carry out the
required branches.
• Example: Add src, Rdst
• Four addressing modes: register, autoincrement,
autodecrement, and indexed (with indirect forms).
Microprogrammed Control
- Bit-ORing
- Wide-Branch Addressing
- WMFC
Microprogrammed Control
Mode
Contents of IR OP code 0 1 0 Rsrc Rdst
1110 87 43 0
Address Microinstruction
(octal)
External Condition
Decoding circuits
A R
Control store
Next address I R
Microinstruction decoder
Control signals
Address Field
Microprogrammed Control
Microprogrammed Control
Octal
address F0 F1 F2 F3 F4 F5 F6 F7 F8 F9 F10
Implementation of the
000 0 0 0 0 0 0 0 1 0 0 1 01 1 0 0 1 0 0 0 0 01 1 0 0 0 0
001 0 0 0 0 0 0 1 0 0 1 1 00 1 1 0 0 0 0 0 0 00 0 1 0 0 0
002 0 0 0 0 0 0 1 1 0 1 0 01 0 0 0 0 0 0 0 0 00 0 0 0 0 0
003 0 0 0 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 00 0 0 1 1 0
121 0 1 0 1 0 0 1 0 1 0 0 01 1 0 0 1 0 0 0 0 01 1 0 0 0 0
122 0 1 1 1 1 0 0 0 0 1 1 10 0 0 0 0 0 0 0 0 00 0 1 0 0 1
170 0 1 1 1 1 0 0 1 0 1 0 00 0 0 0 1 0 0 0 0 01 0 1 0 0 0
171 0 1 1 1 1 0 1 0 0 1 0 00 0 1 0 0 0 0 0 0 00 0 0 0 0 0
172 0 1 1 1 1 0 1 1 1 0 1 01 1 0 0 0 0 0 0 0 00 0 0 0 0 0
173 0 0 0 0 0 0 0 0 0 1 1 10 1 0 0 0 0 0 0 0 00 0 0 0 0 0
Microroutine
Rdstin
Microinstruction
decoder
Rsrcout
Microprogrammed Control
Rsrcin
bit-ORing