Chapter 2 Lecture 2.3 Control Unit
Chapter 2 Lecture 2.3 Control Unit
and
Control Unit
1
BASIC COMPUTER INSTRUCTIONS CATEGORIES
• Instructions may be placed in several different kinds of categories based on
location of instructions.
— Register reference : - Referencing CPU registers for data processing.
— Memory reference : Referencing memory for data processing.
— I/O reference : program that interact with peripheral devices for data
processing.
Memory-Reference Instructions (OP-code = 000 ~ 110)
15 14 12 11 0
I Opcode Address
3x8
decoder
7 6543 210
D0 Control
I Combinational Signals
D7 Control
logic Read, write, load, inc, clear…..
T15
T0
15 14 . . . . 2 1 0
4 x 16
decoder
T0
T1
T2
T3
T4
D3
CLR 6
SC
TIMING AND CONTROL
Step1: Where do we fetch the next instruction from
at T0 (start time)?
T0 : AR = PC
Timing and Control
• Step 2: How do we obtain the instruction from
memory at T1?
– The data stored at the selected address is transferred onto the
Data Bus and then to the Instruction Register (DR) in the
CPU.
T1 : IR = M[AR] ,PC = PC + 1
Memory
Data bus
INC
M[AR] IR LD PC
CPU bus
AR LD
Address bus
Timing and Control
• Step 3: How do we decode the instruction intention (ie.
meaning, operational definition) at T2?
– The OpCode, Mode and Address field bits all serve as inputs
to the Control Logic Gates that select the specific instruction
semantics NOTE:
• Direct addressing All instructions share the steps
• Indirect addressing T0, T1 and T2.
• CPU register addressing However, depending on what
• Input each specific instruction
requires, the control logic for
• Output higher time steps is more
complicated, requiring more
inputs.
T2 : {D0,...,D7} = DEC( IR(12-14) ),
AR = IR(0-11),
I = IR(15)
INSTRUCTION CYCLE
10
Instruction Cycle
T1
S2
T0 S1 Bus
S0
Memory
7
unit
Address
Read
AR 1
LD
PC 2
INR
IR 5
LD Clock 11
Common bus
Instrction Cycle
T0
AR PC
T1
IR M[AR], PC PC + 1
T2
Decode Opcode in IR(12-14),
AR IR(0-11), I IR(15)
T3 T3 T3 T3
Execute Execute AR M[AR] Nothing
input-output register-reference
instruction instruction
SC 0 SC 0 Execute T4
memory-reference
instruction
SC 0
D'7IT3: AR M[AR]
D'7I'T3: Nothing
12
D7I'T3: Execute a register-reference instr.
D7IT3: Execute an input-output instr.
MR Instructions
AR = 135 135 21
136 Subroutine PC = 136 Subroutine
14
1 BUN 135 1 BUN 135
Memory Memory
Memory Reference Instructions
• Branch UNconditional instruction
– I = 0 :: Replace PC by address in IR(0-11)
– I = 1 :: Replace PC by the address found at the address in IR(0-11)
• That is :: PC = M[ M[ IR(0-11) ] ]
Operation Codes
Direct Indirect
I=0 I=1 Mnemonic RTL
4 C BUN AR = IR(0-11)
PC = AR
PC
IR
I=1 I=0
M
Data DR
Address bus
AR
MUX
Memory Reference Instructions
• Branch and SAve instruction
– Used for programming subroutine calls
Operation Codes
Direct Indirect
I=0 I=1 Mnemonic RTL
5 D BSA AR = IR(0-11)
M[AR] = PC , PC = AR + 1
M M
Return addr.
Subr. entry instr. Subr. entry instr.
Memory Reference Instructions
• Increment and Skip if Zero instruction
– Used to implement a counter based <do-while> construct
I=0 I=1 Mnemonic RTL
6 E ISZ AR = IR(0-11) , DR = M[AR]
AC = DR , AC = AC + 1 , DR = AC
M[AR] = DR , (AC=0) : PC = PC + 1
Memory-reference instruction
D0 T 4 D1 T 4 D2 T 4 D 3T 4
DR M[AR] DR M[AR] DR M[AR] M[AR] AC
SC 0
D0 T 5 D1 T 5 D2 T 5
AC AC DR AC AC + DR AC DR
SC 0 E Cout SC 0
SC 0
D4 T 4 D5 T 4 D6 T 4
PC AR M[AR] PC DR M[AR]
SC 0 AR AR + 1
D5 T 5 D6 T 5
PC AR DR DR + 1
SC 0
D6 T 6
M[AR] DR
If (DR = 0) 19
then (PC PC + 1)
SC 0