Lecture 8 Control Unit

Download Report

Transcript Lecture 8 Control Unit

Lecture 9
Control Unit
CS311-Computer Organization
Control Unit
Lecture 9- 1
Lecture 9:
Control Unit
In this lecture, we will study
•
•
•
•
•
•
Instruction cycles
– 6-step instruction cycle
Micro-operation
– Micro-action
– Control Point and Independent Control Point
– Micro Cycle Time
Major State(Major Cycle, Machine Cycle) and Timing State
– FETCH, INDIRECT, EXECUTE, INTERRUPT
Control Data
Control Rules
Control Unit Implementations
CS311-Computer Organization
Control Unit
Lecture 9- 2
Instruction Execution Control
CPU: A Sequential Machine (K, S, d)
K: A set of finite number of States that CPU can assume
- Machine States
S: A finite set of symbols that can be considered as the inputs
- Control Data
d: A finite set of state transition functions
- Micro-operations
Program Execution in a CPU
– A sequence of changes of contents in registers
– Registers consist of FFs
– A program execution is a sequence of state changes of FFs in
CPU and micro-operations cause these changes
CS311-Computer Organization
Control Unit
Lecture 9- 3
6-Step Instruction Cycle
Memory
Access time
[1]
[2]
[3]
Memory
Access time
[4]
[5]
[6]
CS311-Computer Organization
MAR
PC(address), M
R(control)
…
...
IR
MBR(OP-code)
Decode instruction
Control Signal Generator
IR,
Address Processor
MBR(address)
MAR
Effective Address, M
R/W
…
...
Data path activation to do operation
Decide final PC by this time,
go to [1] for the next instruction
Control Unit
Lecture 9- 4
Micro-Operation
Rd:
Rs1, Rs2:
Destination Register
Source Register
CPU data path
Micro-operation
Rd
Register
File
f(Rs1, Rs2)
Simple data move:
Unary operations:
Binary operations:
Rd
Rd
Rd
ALU
f
fI(Rs1, f)
fu(Rs1, f)
fb(Rs1, Rs2)
A Micro-operation generates a finite set of Control Signals at the
proper time according to the Machine State and the Control Data to
activate the Micro-actions and to update the Control Data Structure.
CS311-Computer Organization
Control Unit
Lecture 9- 5
Micro-Action/Micro-Operation
Micro-action
Register
ALU
f
- An Activation of a part of data path
File
Bus
Register Output
Register Input
Bus
- Selection of a function of the Functional Unit(ALU), Memory
ALU:
ADD, OR, SHR, etc
Memory: R(read), W(write)
Micro-operation
- A micro-operation can be described in terms of a sequence of
micro-actions
Rd
fADD(Rs1, Rs2)
Input Bus 1
Rs1
Input Bus 2
Rs2
ADD
Rd
Output Bus
CS311-Computer Organization
Control Unit
Lecture 9- 6
Activation of Micro-action:
An Example
Rd
fADD(Rs1, Rs2)
Input Bus 1
Rs1
Input Bus 2
Rs2
ADD
Rd
Output Bus
Input Bus 1
Input Bus 2
Rs1
ADD
SUB
Rs2
ALU
...
Rd
AND
Output Bus
CS311-Computer Organization
Control Unit
Lecture 9- 7
Control Point
Control Point:
Hardware locations(gates) to which control signals
are applied to achieve the intended set of functions
(a sequence of micro-operations, each of which
may also be a sequence of micro-actions)
• Register In-Gates
• Register Out-Gates
• ALU function selection terminals
• Memory read/write control signal terminal
CS311-Computer Organization
Control Unit
Lecture 9- 8
Control Points:
Register In-Gate and Out-Gate
Load R1
R1
…
Q
...
R2
…
Q
...
R3
…
Q
...
Send R1
Send R2
Send R3
…
D
Load R3
…
D
...
…
D
...
Bus
Register Out Gates
CS311-Computer Organization
R1
Load R2
...
R2
R3
Register In-Gates
Control Unit
Lecture 9- 9
Control Points:
ALU Function Selection Points
X
Y
Cc
A
PS
C
DI
C0
Cm
Logic
Unit
Adder
AN
AO
Cr
Ri
Li
Ro
Lo
Shifter
NS
LS
RS
SE
Z
CS311-Computer Organization
Control Unit
Lecture 9- 10
Independent Control Point
Example:
32-bit machine with 8 registers
ALU has 4 different functions in 32-bit data in parallel
Memory has 1 terminal for R/W
No. of Control Points:
(32 x 8 x 2) + (32 x 4) + 1 = 641
No. of Independent Control Points
(8 x 2) + 4 + 1 = 21
During an instruction execution, usually a group of bits are
transferred together as an information
Instruction: OP-code, Register Address, Memory Address
Floating point numbers: Sign bit, Exponent, Mantissa
Others: A number, A character or a character string
Each of these groups actually need an identical control signal for
each bit within the group
-> Each
group is associated with one Independent Control Point
CS311-Computer Organization
Control Unit
Lecture 9- 11
Independent Control Points:
Around MBR
MBR
BUS
BUS
MBR(OP )
BUS
MBR(A)
MBR
MBR(O)
MBR(A)
15
...
BUS
BUS
5
MBR(O)
To ALU
6
MBR
BUS
5
MBR
...
M
0
...
M
0
...
MBR
BUS
Memory Bus
From ALU
15
... ...
...
M
CS311-Computer Organization
MBR MBR M
BUS
Control Unit
M
MBR M
... ...
BUS
MBR(A)
Lecture 9- 12
Micro-Operation Timing
•
Execution Time of a Micro-Operation - Micro-Cycle
Time required to change the information in a set of registers
•
CPU Clock is the most basic timing signal used for the reliable
operation of CPU and CPU Clock Cycle is equal to the Micro-Cycle
•
Information need to be stored in a register at the end of each
micro-cycle, otherwise, information will be lost
•
Micro-Cycle is determined by the characteristics of FF’s(setup
time, hold time, delay) used in registers and the propagation delay
of the circuits (ALU) in between the source and destination
registers
– Micro-Cycle may vary depending on the micro-operation
» Signal path, Type of ALU operation
CS311-Computer Organization
Control Unit
Lecture 9- 13
Micro-Cycle
•
•
Synchronous Fixed: There is only one Micro-Cycle, i.e., all microoperations’ execution times are assumed to be identical
Synchronous Variable: Certain long micro-operations are allowed to
take multiple cycles without causing a state transition, i.e., different
micro-cycle lengths are allowed
– e.g. Consider the different time requirements by R <- fI(R) and R <- fb(R, R)
•
Asynchronous:
No clock or external mechanism that determines a
state transition. Hardly used to control the execution of instructions
Micro-Cycle Time
It can be broken down into Control Time and Data Path Time
– Control Time
» Time to decode control data and generate control signals
– Data Path Time
» Time to transmit control signals and transfer data
– Control Time and Data Path Time are partially overlapped in some
high performance machines
CS311-Computer Organization
Control Unit
Lecture 9- 14
Time Out
• 질투심이 강한 어느 부인이 자기의 초상화를 그려두어야겠다고 생
각하고 화가에게 부탁했다.
• “내 초상화에 다이아몬드 귀고리와 다이아몬드 목걸이, 그리고 에
메랄드 팔찌, 루비 펜던트를 그려 넣어 주세요.”
• “하지만 부인은 그런 것들을 달고 있지 않은데요.”
• “그건 사실이지만 내가 남편보다 먼저 죽는 경우에 대비해서 그러
는 거예요. 내가 먼저 죽으면 그이는 금방 재혼할거에요. 그러면
그 여자가 그 보석들을 보고 남편을 들볶아댈 거 아니겠어요?”
CS311-Computer Organization
Control Unit
Lecture 9- 15
Generation of Control Signals
Control Data
Machine State
Control Rule
Control Signal
Timing
Microprogram or
Combinational logic circuit
E.g. In state(Machine Cycle) S1, at time(timing state) t1: R1
f(R2, R3)
Clock
IBus1
R2, IBus2
R1
R3
f
OBus
S1
Machine Cycle
Timing State
CS311-Computer Organization
t1
Control Unit
Lecture 9- 16
Intra-Instruction Sequencing
Instruction
Fetch
Instruction
OP-code
Decode
Instruction
Address
Decision
CS311-Computer Organization
Operand
Store
Operand
Fetch
Operation
Specified
Operand
Address
Compute
Control Unit
Operand
Address
compute
Lecture 9- 17
RISC-S Architecture
IBus1
IBus2
IR
Memory
MAR
PC
MBR
Register
File
ALU
+4
OBus
Instruction =4 bytes
Rd
fu(Rs1)
Rd
Rs1
PC
MBR
MBR
PC
MAR
R
IR
R
CS311-Computer Organization
Rd
Rd
MAR
PC
R
fb(Rs1, Rs2)
Rs1, Rs2
(R, R)
(R, IR(addr))
(PC, IR(addr))
Control Unit
f
Numerical Calculation
Logical Calculation
Shifts
+4
Lecture 9- 18
Instruction Set - RISC-S
Instruction
ADD
SUB
AND
OR
SLL
LD
ST
JMP
CALL
RET
Operand
Rs1, Rs2(S2), Rd
Rs1, Rs2(S2), Rd
Rs1, Rs2(S2), Rd
Rs1, Rs2(S2), Rd
Rs1, Rd
S2(Rs1), Rd
S2(Rs1), Rd
COND, S2(Rs1)
Rd, S2(Rs1)
S2(Rs1)
Operation
Rd
Rs1 + Rs2
Rd
Rs1 - Rs2
Rd
Rs1 ^ Rs2
Rd
Rs1 v Rs2
Rd
logical Shift Left(Rs1)
Rd
M[Rs1 + S2]
M[Rs1 + S2]
Rd
(COND=1): PC
Rs1 + S2
Rd
PC, next PC
Rs1 + S2
PC
Rs1 + S2
Representative Instructions
ADD
SLL
LD
JMP
Rs1, Rs2, Rd
Rs1, Rd
S2(Rs1), Rd
COND, S2(Rs1)
CS311-Computer Organization
Integer Addition
Logical Shift Left 1 bit
Load a word
Conditional Branch
Control Unit
Lecture 9- 19
Micro-Operations For RISC-S
[1]
[2]
[3]
[4]
[5]
ADD
MAR
PC, R;
PC
PC + 4;
IR
MBR;
Decode IR;
Rd
Rs1 + Rs2;
[6]
CS311-Computer Organization
SLL
MAR
PC, R;
PC
PC + 4;
IR
MBR;
Decode IR;
Rd
shl Rs1;
LD
MAR
PC, R;
PC
PC + 4;
IR
MBR;
Decode IR;
MAR
Rs1 + S2, R;
Rd
Control Unit
JMP
MAR
PC, R;
PC
PC + 4;
IR
MBR;
Decode IR;
T/F(test condition),
T: PC
Rs1 + S2;
MBR;
Lecture 9- 20
Major State - Machine Cycle
During a Major State, a memory reference is made, i.e. a Machine Cycle
includes a Memory Cycle
FETCH:
Read an instruction from memory specified by the address in
PC, and whatever left to do before making transition to FETCH,
EXECUTE, or INDIRECT machine cycle
EXECUTE: For the instructions with an operand in memory, read operand
to perform operation specified in the instruction, and make a
transition to FETCH machine cycle
INDIRECT: Read effective address from memory, and make a transition to
FETCH or EXECUTE machine cycle - not happen in RISC
2g-address instruction:
R
f(R, R)
When does the operation(f) take place ?
(1+X)- or (1+g+X)-address instruction:
When does the address calculation take place?
CS311-Computer Organization
Control Unit
Lecture 9- 21
Machine Cycles
R-to-R, JMP(direct address)
FETCH
Memory Reference
EXECUTE
Memory Reference(Indirect address)
JMP Indirect
INDIRECT
RISC-S does not have
Indirect Machine Cycle
INTERRUPT
Interrupt
CS311-Computer Organization
Control Unit
Lecture 9- 22
Machine State Register
(Major State Register)
Major State
Q1 Q0
FETCH
0 0
INDIRECT
0 1
EXECUTE
1 0
INTERRUPT 1 1
Q0
Q1
FET←INT
INT←FET
INT←EXE
EXE←FET
INT←FET
FET←INT
FET←EXE
FET←FET
FET←EXE
EXE←FET
INT←EXE
FET←FET
t3
J
Q0
FF0
K
Q0'
J
Q1
FF1
K
Q 1'
FET
IND
Clock
EXE
INT
CS311-Computer Organization
Control Unit
Lecture 9- 23
Timing State
Timing State Counter - A counter that advances for each CPU clock pulse
- Counter advances in the period of Micro-cycle
- Counter resets at the maximum count, i.e., at the
beginning of each Machine Cycle
CPU Clock
Machine Cycle
t0
t1
t2
t3
Memory Cycle
(Memory Active)
Memory Access time
(Read Data available)
A timing state counter counts from 0 to 3
CS311-Computer Organization
Control Unit
Lecture 9- 24
Machine Cycle:
Various Addressing Modes in AC Machines
[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]
[11]
[12]
t0
t1
t2
t3
t0
t1
t2
t3
t0
t1
t2
t3
Immediate Address
ADD #X
MAR
PC, R;
PC
PC + 4;
IR
MBR, decode;
AC
AC + MBR(A);
PC Relative Address Direct Address
Indirect Address
ADD $X
ADD X
ADD @X
MAR
PC, R;
MAR
PC, R;
MAR PC, R;
PC
PC + 4;
PC
PC + 4;
PC PC + 4;
IR
MBR, decode;
IR
MBR, decode; IR MBR, decode;
MBR
PC + MBR(A); MBR
MBR(A); MBR
MBR(A);
MAR
MBR, R;
MAR
MBR, R; MAR
MBR, R;
AC
AC + MBR;
AC
AC + MBR; MAR MBR, R;
AC AC + MBR;
FETCH; INDIRECT; EXECUTE
Notice that memory cycle is 4 times slower than the micro-cycle(3 micro-cycle Access
Time), and that 4 micro-cycle machine cycle is possible with a faster memory.
CS311-Computer Organization
Control Unit
Lecture 9- 25
Machine Cycle - RISC-S
t0
t1
t2
t3
ADD
MAR
PC, R;
PC
PC + 4;
IR
MBR, Decode;
Rd
Rs1 + Rs2,
SLL
MAR
PC, R;
PC
PC + 4;
IR
MBR, Decode;
Rd
shl Rs1,
RI: INTERRUPT,
RI’: FETCH;
RI: INTERRUPT,
RI’: FETCH;
t0
t1
t2
t3
LD
JMP
MAR
PC, R;
MAR
PC, R;
PC
PC + 4;
PC
PC + 4;
IR
MBR, Decode; IR
MBR, Decode;
MAR
Rs1 + S2, T/F(test condition),
T: PC
Rs1 + S2,
RI: INTERRUPT,
RI’: FETCH;
R;
Rd
MBR;
RI: INTERRUPT,
RI’: FETCH;
FETCH; EXECUTE
ALU Control
CS311-Computer Organization
Control Unit
Lecture 9- 26
ALU Control
X
Y
Cc
A
PS
C
DI
C0
Cm
Logic
Unit
Adder
AN
AO
Cr
Ri
Li
Ro
Lo
Shifter
NS
LS
RS
SE
Z
CS311-Computer Organization
Control Unit
Lecture 9- 27
ALU Control Micro-Actions
ICPs
Add
Increment
1’s Compl Add
2’s Compl Add
AND
OR
Compl AC
Left Shift
Right Shift
Pass
Clear AC
Clear C
Compl C
CS311-Computer Organization
C0
0
1
0
1
d
d
0
0
0
d
d
d
d
Cm
0
0
1
1
d
d
1
d
d
d
d
d
d
A
1
1
1
1
0
0
1
0
0
0
0
0
0
DI
0
1
0
0
d
d
1
d
d
d
d
d
d
Cc
0
0
0
0
0
0
0
0
0
0
0
0
1
Cr
0
0
0
0
0
0
0
0
0
0
0
1
0
Control Unit
AN
d
d
d
d
1
0
d
d
d
d
d
d
d
AO
0
0
0
0
1
1
0
0
0
0
0
0
0
PS
0
0
0
0
0
0
0
1
1
1
0
0
0
NS
1
1
1
1
1
1
1
0
0
1
0
0
0
LS
0
0
0
0
0
0
0
1
0
0
0
0
0
RS
0
0
0
0
0
0
0
0
0
0
0
0
0
SE
1
1
1
1
1
1
1
1
1
1
0
0
0
Lecture 9- 28
Constraints on Concurrency
Micro-operation concurrency
– Hardware resource conflict
MAR
AC
MBR(addr)
AC + MBR
AC
MAR
AC’
MBR(addr) + IX
Bus conflict
– Register dependency
R2
R1
SHL(R1) These are not concurrent micro-operations
R2 + R3 even if Adder and shifter are independent units.
– However, multiple fan-out of registers may be OK
R2
R4
CS311-Computer Organization
SHL(R1) These are concurrent micro-operations if Adder
R1 + R3 and shifter are independent units.
Control Unit
Lecture 9- 29
Instruction and Machine Cycles
Number of
Machine Cycles
1
2
3
4
5
6
Instruction
Stack Computer: Functional
AC Computer:
Unary Functional, Control not with Indirect Addr
GPR Computer: R-R instructions, Control not with Indirect Addr
Transfer and Control Instructions not with Indirect Address
AC Computer:
Functional
GPR Computer: R-M Instruction not with Indirect Address
Transfer Instruction with Indirect Address
AC Computer:
Functional with Indirect Address
GPR Computer: R-M Instruction with Indirect Address
M-M Instruction not with Indirect Address
M-M Instruction with 1 Indirect Address
M-M Instruction with 2 Indirect Address
CS311-Computer Organization
Control Unit
Lecture 9- 30
Control Rules for RISC-S
State
FET.t0
FET.t1
FET.t2
FET.t3
Micro-Operations
MAR
PC, R;
PC
PC + 4;
IR
MBR, Decode;
(FU. XF’.CT’.IO’): Rd
f(Rs1, Rs2),
(FU’.XF. CT’.IO’): MAR
f(Rs1, S2),
(FU’.XF’.CT. IO’)^(T): PC f(Rs1, S2),
(FU’.XF’.CT’.IO): -;
EXE.t0
EXE.t1
EXE.t2
EXE.t3
(XF.LD): R, (XF.LD’): W;
(XF.LD’): MBR
Rd;
(XF.LD): Rd
MBR;
RI: INT, RI’: FET,
EXE,
RI: INT, RI’: FET,
RI: INT, RI’: FET,
Instruction Decode;
Functional: FU, Transfer: XF(Load: LD, Store: LD’), Control: CT, I/O: IO
Interrupt Request;
RI
CS311-Computer Organization
Control Unit
Lecture 9- 31
Implementation Of CU
- Hardwired Implementation -
Major State
Rs1
SCC
Timing State
Rs2
S2(imm)
Rd
Control Data
Control Logic Circuit
Control Unit
CS311-Computer Organization
Control Unit
Independent Control Points
Cond
...
OP-code
IR
Flag
Control Data
CPU
Lecture 9- 32
Microprogrammed
Control Unit
CS311-Computer Organization
Control Unit
Lecture 9- 33
Microprogrammed Control Unit
In this topic, we will study
– Micro-instruction
» Data path control and Sequence control information
» Vertical micro-instruction and Horizontal micro-instruction
– Microprogramming RISC-S
»
»
»
»
RISC-S Architecture and Instruction Set
Vertical micro-instruction format
Microprogramming with Vertical micro-instruction
Horizontal micro-instruction format
– Microprogram control unit
– Advantages and Disadvantages of microprogram
CS311-Computer Organization
Control Unit
Lecture 9- 34
Microprogrammed Control Unit
Micro-instruction
IR
Control Point
Control
Storage
Decoder
CSAR
U-program
Control
Unit
Flag
Status
of CPU
Branch Address
CPU
Control Unit
CS311-Computer Organization
Control Unit
Lecture 9- 35
Micro-Instruction
•
Micro-instruction should contain
– Data Path Control information
» Information needed to generate control signals required to activate the data
path in the CPU to execute intended micro-operation(s)
» Representation of the data path control information
> Horizontal Micro-instruction - Direct micro-instruction
> Vertical Micro-instruction - Encoded micro-instruction
– Sequence Control information
» A part of information needed to generate the next micro-instruction address
» e.g., Branch address
•
•
One micro-instruction may contain both information,
Or, Two types of micro-instructions
– Data path control micro-instruction
– Sequence control micro-instruction
CS311-Computer Organization
Control Unit
Lecture 9- 36
Horizontal Micro-Instruction
Each of the bits in the data path control information is directly connected to an
independent control point, i.e., each bit is associated with a micro-action
–
–
–
–
–
Data path control information field is very long
Decoder is not needed to generate control signals, decoding delay is absent
Very fast to execute a micro-instruction
Concurrent micro-operation can be specified if there are multiple data paths
However, in an ordinary machine, micro-instruction bit utilization is poor, thus
control storage utilization is inefficient
– Very high performance machines can only afford to have HM
0 1 2 3
n-1
Sequence Control
Control Points
CPU
CS311-Computer Organization
Control Unit
Lecture 9- 37
Vertical Micro-Instruction
Data path control information is represented by a set of fields,
each of which represents a set of micro-actions associated
with a similar hardware resources, e.g: INBUS1, OUTBUS, ALU,
Registers, Memory, etc
– Information in each field is encoded to reduce the microinstruction length, thus micro-instruction length is short
– Decoder is needed for each encoded field
– Concurrency is low, but micro-instruction bit utilization is
good, thus control storage utilization is efficient
– Generation of control signal is slow due to decoding delay
– Easy to make symbolic micro-instructions
– Most of commercially available machines employ VM
CS311-Computer Organization
Control Unit
Lecture 9- 38
Encoding Control Information
• Direct Encoding
...
...
...
Sequence Control
...
...
• Indirect Encoding
...
Sequence Control
...
...
...
CS311-Computer Organization
Control Unit
Lecture 9- 39
Time Out
• 시험을 치루기 위하여 학생들이 강의실에 들어갔다.
• 교수가 사정이 있어 시험을 연기한다고 발표하자 한 학생이 일어
나서 그렇게 되면 다른 과목들을 공부할 스케줄이 엉망이 된다고
불평했다.
• “학생 이름이 뭐지요?” 교수가 물었다.
• “론 애덤스입니다.” 학생이 조용히 대답했다.
• “좋아요 론” 그 학생을 향하여 이름을 기록할 준비를 하면서 교수
가 말했다. “자기 주장을 당당하게 내세우는 용기를 높이 사서 학
생에게는 A학점을 주고, 이번 시험은 면제해 주겠어요.”
• 그 학생이 다시 말했다. “그렇게 하신다면 교수님, 제 이름은 론 애
덤스가 아니고 존 윌슨입니다.”
CS311-Computer Organization
Control Unit
Lecture 9- 40
Micro-Action
• Micro-action that activates a data path
– Selection of a register whose content can be sent to a bus
» INBUS1
R2
– Selection of a register that stores the information on a bus
» R3
OUTBUS
• Micro-action that makes the selection of ALU function
– For 2’complement ADD
» A, C0, Cm, DI’, Cc’, Cr’, AO’, NS, SE
• Micro-action that activates the memory control
– Memory Read(R) and Write(W) control
» R(R) or R’(W)
CS311-Computer Organization
Control Unit
Lecture 9- 41
Example - Architecture:
RISC-S
INBUS2
INBUS1
IR
MAR
Memory
PC
Register
File
MBR
ALU
Flag
+4
OUTBUS
CS311-Computer Organization
Control Unit
Lecture 9- 42
Example - Instruction Set:
RISC-S
0
1
Cond
Op-code
31
OP-code
0 00 0000
0 00 0001
0 00 0100
0 00 0101
0 00 1000
1 01 0000
1 01 0001
0 10 0000
0 10 0001
0 10 0010
SCC
24 23
Symbol
ADD
SUB
AND
OR
SLL
LD
ST
JMP
CALL
RET
Rd
Rs1
19 18
Rs2
imm13
S2
13 12
Operands
Rs1,Rs2,Rd
Rs1,Rs2,Rd
Rs1,Rs2,Rd
Rs1,Rs2,Rd
Rs1,Rd
S2,Rd
Rd,S2
CD,S2
Rd,S2
S2
0
Operation
Rd
Rs1 +Rs2
Rd
Rs1 - Rs2
Rd
Rs1 ^ Rs2
Rd
Rs1 v Rs2
Rd
logical shift left Rs1
Rd
M[PC+S2]
M[PC+S2]
Rd
(COND=1):PC←PC+S2
Rd
PC, next PC←PC+S2
PC←PC+S2
F: Represents the Function of the instruction
T: Represents the Type of the instruction
000: Functional, 101: Transfer, 010: Sequencing
CS311-Computer Organization
Control Unit
Lecture 9- 43
Vertical Micro-Instruction for RISC-S:
Data Path Control
• Memory Control Field(M: 2 bits)
– Memory is either Read or Write, or No-operation, i.e. needs to
represent 3 kinds
M
00
01
10
11
NOP
Not used
W(Memory
MBR)
R(MBR
Memory)
• Arithmetic Function Control Field(AF: 2 bits)
– ADD, 2’ Complement ADD, Pass, Disable - needs to represent 4 kinds
AF
00
01
10
11
Disable
Pass
ADD(Rd
Rs1 + Rs2)
2’ complement ADD(Rd
CS311-Computer Organization
Control Unit
Rs1-Rs2)
Lecture 9- 44
Vertical Micro-Instruction for RISC-S:
Data Path Control
• Logical Function Control Field(LF: 2 bits)
– AND, OR, Disable - needs to represent 3 kinds
LF
00
01
10
11
Disable
Not used
OR(Rd
Rs1 V Rs2)
AND(Rd
Rs1 ^ Rs2)
• Shift Function Control Field(S: 1 bit)
– Either shift left or pass the shifter - needs to represent 2 kinds
S
0
Pass
1
Shift left(Rd
SLL(Rs1))
CS311-Computer Organization
Control Unit
Lecture 9- 45
Vertical Micro-Instruction for RISC-S:
Data Path Control
• Input Bus - INBUS1(IN1: 2 bits)
– MBR, PC, R(Rs1), Disable - needs to represent 4 kinds
IN1
00
01
10
11
INBUS2
INBUS1
Disable
INBUS1
INBUS1
INBUS1
PC
Rs1
MBR
• Input Bus - INBUS2(IN2: 2 bits)
IR
MAR
Memory
PC
MBR
Register
File
ALU
Flag
+4
OUTBUS
– R(Rs2), IR[imm13(S2)], IR[Rs2(S2)], Disable - needs to represent 3 kinds
IN2
00
01
10
11
Disable
Not used
INBUS2
INBUS2
CS311-Computer Organization
IR(imm13)
Rs2
Control Unit
Lecture 9- 46
Vertical Micro-Instruction for RISC-S:
Data Path Control
• Output Bus - OUTBUS(OUT: 3 bits)
– MAR, MBR, PC, IR, R(Rd), Disable - needs to represent 6 kinds
OUT
000
Disable
001
MAR
OUTBUS
INBUS2
INBUS1
010
MBR
OUTBUS
IR
011
PC
OUTBUS
MAR
PC
100
IR
OUTBUS
Register
Memory
File
MBR
101
Rd
OUTBUS
+4
110,111 Not used
• PC Control Field(P: 1 bit)
ALU
Flag
OUTBUS
– PC increment, Disable increment - needs to represent 2 kinds
P
0
Disable
1
PC
PC + 4
CS311-Computer Organization
Control Unit
Lecture 9- 47
Vertical Micro-Instruction for RISC-S:
Sequence Control
•
Branch set
Data Path Control
•
xx
xx
00
01
10
11
Next address
uPC(repeat)
uPC + 1
uPC + 2
uPC + 3
Branch set with condition codes
– Least significant m bits of address are replaced by the m conditions codes
Data Path Control
•
Cond
Branch Address
Cond
C-value
Complete conditional branch
Data Path Control
Branch Address
– If CC specified by Cond field is equal to the C-value, address specified in
the micro-instruction is the branch address
CS311-Computer Organization
Control Unit
Lecture 9- 48
Vertical Micro-Instruction for RISC-S:
Sequence Control
•
Conditions in RISC-S
– CPU Flags: C, Z, S, O
– Machine language instruction OP-code field: T(t0t1t2) and F(f0f1f2f3)
•
Branch types: FLG(3 bits)
FLG
000
001
010
011
100
101
110,111
Not branching
Unconditional branch
Conditional branch on CPU flags(COND field in machine instruction)
Not used
Conditional branch on T flags
Conditional branch on F flags
Not used
• Conditional branch micro-instruction must specify Branch Type(FLG: 3
bits) and Values of the specified Flags(FVAL: 4 bits)
– Maximum number of flags to be tested against the values is 4(CPU
flags, F flags)
Data Path control
25
CS311-Computer Organization
FLG FVAL
3
Control Unit
4
address
8
Lecture 9- 49
Vertical Micro-Instruction
for RISC-S
Vertical micro-instruction formats for RISC-S
0
1 2 3
4 5
6 7 8
9 10 11 12
14 15
17 18
M P AF LF S IN1 IN2 OUT FLG
21 22
FVAL
31
Branch Address
Data path control micro-instruction for RISC-S
0 1
0
2 3 4
M
5 6
7 8 9
10 11
12 13
15
P AF LF S IN1 IN2 OUT
Sequence control micro-instruction for RISC-S
0 1
34
7 8
1 FLG FVAL
CS311-Computer Organization
15
Branch Address
Control Unit
Lecture 9- 50
Time Out
•
어느 대학 화학과 연구실에 15년이 넘은 낡은 소형 냉장고 안에 휘발성이
강한 유기화학물질을 보관하고 있었다.
•
교수들이 몇 번씩이나 새 냉장고의 구매요구를 했으나 매 번 거절되었다.
•
“번번이 거절되는 이유는 경리과에서 생각하기에는 아마 냉장고가 학생
들의 음료수나 간식을 넣어 두는데 사용한다고 생각했기 때문일거야.” 교
수가 추측하였다.
•
그 교수는 새로운 구매 요구서에 ‘냉장고’라는 단어 대신에 ‘자동 저온유
지장치’라고 써서 보냈다.
•
몇일 후 새 냉장고가 배달되었다.
CS311-Computer Organization
Control Unit
Lecture 9- 51
Microprogram Model
FETCH
Routine
Instruction 1
Execution
Routine
CS311-Computer Organization
Instruction 2
Execution
Routine
Control Unit
Instruction n
Execution
Routine
Lecture 9- 52
FETCH Routine
• Instruction Fetch
– Read Instruction from memory to store in IR
• Decode Instruction
– Separate instruction fields and store them in buffers
T
Rd
I(31-29), F
I(28-25), SC
I(24), COND
I(23-19), Ss1
I(18-14), Ss2
I(4-0), D
I(22-19),
I(12-0)
– Extend the displacement of the operand’s address into a 32-bit
displacement
S2
(I(12))19#D (sign extension)
– Fetch operands from registers
Rs1
Rs2
Reg[Ss1]
Reg[Ss2]
CS311-Computer Organization
Control Unit
Lecture 9- 53
FETCH Routine
F
IR
MAR
PC, R
PC
PC + 4
MBR, Decode
T=0?
OP-code(I31-I25): T(t0t1t2), F(f0f1f2f3)
T: Instruction Type
F: Function Type
Instruction Decoding can be done either by hardware or microprogram.
We assume that decoding hardware does as follows;
n
y
T=5?
y
n
T=2?
n
y
T=3?
n
Illegal OP-code
Interrupt
y
FC
CS311-Computer Organization
XF
SQ
Control Unit
IO
Lecture 9- 54
Execution Routine - Functional
FC
F=0?
n
F=1?
y
Rd
Rs1 + Rs2
Rd
n
y
F=4?
n
y
Rs1 - Rs2
Rd
F=5?
Rs1 ^ Rs2
n
y
F=8?
Rd
Rs1 v Rs2
y
Rd
shl Rs1
Illegal OP-code
F
CS311-Computer Organization
n
Control Unit
Lecture 9- 55
Execution Routine - Transfer
XF
F=0?
n
y
F=1?
n
y
MAR
Rd
Rs1 + S2, R
MBR
MAR
MBR
Illegal
OP-code
Rs1 + S2, R
Rd
F
CS311-Computer Organization
Control Unit
Lecture 9- 56
Execution Routine - Sequencing
SQ
F=1?
n
y
Rd
PC
n
F=0?
y
PC
Rs1 + S2
COND=1?
y
F=3?
n
Illegal
OP-code
y
n
PC
Rs1 + S2
F
CS311-Computer Organization
Control Unit
Lecture 9- 57
Symbolic Microprogram
for RISC-S
FETCH:
FUN:
ADDR:
SUBR:
ANDR:
Rs1 v Rs2, goto FETCH;
shl Rs1, goto FETCH;
MAR
PC, R;
PC
PC + 4;
IR
MBR, decode;
if T=Func goto FUN;
if T=Trans goto XFR;
if T=Seq goto SEQ;
goto IO;
if F=ADD goto ADDR;
if F=SUB goto SUBR;
if F=AND goto ANDR;
if F=OR goto ORR;
if F=SLL goto SHFTR;
goto OTHERFUN;
ORR:
SHFTR:
Rd
Rd
XFR:
if F=LD goto LOAD;
if F=ST goto STORE;
goto OTHERXFR;
Rd
M[Rs1+S2], goto FETCH;
M[Rs1+S2]
Rd, goto FETCH;
Rd
Rd
Rd
JUMP:
LOAD:
STORE:
SEQ:
Rs1 + Rs2, goto FETCH;
Rs1 - Rs2, goto FETCH;
Rs1 ^ Rs2, goto FETCH;
CS311-Computer Organization
if F=JMP goto JUMP;
if F=CALL goto CALL;
if F=RET goto RETURN;
goto OTHERSEQ;
if COND=true goto RETURN;
goto FETCH;
CALL:
Rd
PC;
RETURN: PC
Rs1 + S2, goto FETCH;
Control Unit
Lecture 9- 58
Decoding Micro-Instruction
in RISC-S
X
Y
Cc
A
C
DI
C0
Cm
Cr
Ri
Li
Ro
Lo
Logic
Unit
Adder
S
L
Shifter
PS
AN
AO
NS
LS
RS
SE
Z
CS311-Computer Organization
Control Unit
Lecture 9- 59
Decoding Micro-Instruction
in RISC-S
AF field
AF=ADD
AF=SUB
AF=Pass
AF=Disa
A
1
1
0
0
C0
0
1
d
d
Cm
0
1
0
d
DI
0
0
1
d
Cc
0
0
0
0
Cr
0
0
0
0
AO
0
0
0
0
AN
d
d
d
d
PS
0
0
1
0
NS
1
1
1
d
LS
0
0
0
d
RS
0
0
0
d
SE
1
1
1
0
LF field
LF=OR
0
LF=AND 0
LF=Disa 0
LF=unusedd
d
d
d
d
d
d
d
d
d
d
d
d
0
0
0
d
0
0
0
d
1
1
0
0
0
1
0
d
0
0
0
d
1
1
1
d
0
0
0
d
0
0
0
d
1
1
1
d
S field
S=Disa
S=left
d
0
d
0
0
0
0
0
0
0
0
0
d
d
0
0
1
0
0
1
0
0
1
1
d
1
CS311-Computer Organization
Control Unit
Lecture 9- 60
Horizontal Micro-Instruction
for RISC-S
Decoded form of control information in the micro-instruction
M0 M1 P C0 Cm A DI Cc Cr AN AO PS NS LS RS SE
2
1
1
1
1
1
1
1
1
1
FVAL
address
4
n
CS311-Computer Organization
1
1
1
Control Unit
1
1
IN1
IN2
OUT
2
2
3
FLG
3
Lecture 9- 61
Microprogram Control Unit
• In-line execution
– We know it is simple if we have a uPC
• Repeat execution
– Disable incrementing uPC
• Conditional and Unconditional branch
– Target address or a part of the target address in the micro-instruction
– Branch conditions: CPU flags, Instruction’s T and F flags
• Loop
– We need a conditional branch and an iteration counter
– Loop counter(LCTR, and LZ flag that represents the state of LCTR, LZ
is set to 1 when LCTR represents 0
• Micro-routine call and return
– We know it is simple if we have a stack
– PUSH the return address when CALL, and POP for indirect branch
CS311-Computer Organization
Control Unit
Lecture 9- 62
Redefining FLG Field
Definition of FLG field
FLG
Micro-instruction execution sequence
0000
In-line sequencing
0001
Unconditional branch
0010
Repeat
0011
Beginning of loop
0101
CALL
0110
RETURN
1000
Conditional branch on T
1001
Conditional branch on F
1100
Conditional branch on CPU flags
1101
Conditional branch on LZ flag
0100, 0111, 1010, 1011, 1110, 1111 are not used
Next micro-instruction
uPC
address
uPC
uPC
address
Stack
address
address
address
address
We need a address MUX at the
input of CSAR
CS311-Computer Organization
Control Unit
Lecture 9- 63
Address MUX and
Loop Counter
SP
S0
S1
Stack
AMUX
uPC
LZ
=0
CSAR
PSH POP
+1
DPC
LCTR
Control Storage
AMUX Control
S0
0
0
1
1
S1
0
1
0
1
Address
Not used
uPC
address
stack
Micro-instruction
C
CS311-Computer Organization
Control Unit
address
Lecture 9- 64
Decoding Flag Field
S1
CPU
FVAL
Z
S
C
O
Z 1 1 1
S 1 1 1
C 1 1 1
O 1 1 1
T0 T1 T2 1
F0 F1 F2 F3
LZ 1 1 1
S0
=
PSH
Compare
(0010+
0101)
1ddd
FMUX
0110
0000
En
DPC
0d1d
0d01
FLGD
0110
POP
FLG
CS311-Computer Organization
FVAL
Control Unit
Lecture 9- 65
Advantages of
Microprogram
•
•
•
•
•
•
Flexibility and adaptability are high
Makes the development time shorter
Convenient for developing a computer family design
Easy to develop ICs
Maintenance and error detection/correction cost is lower
Development of Universal host
CS311-Computer Organization
Control Unit
Lecture 9- 66
Disadvantages
of Microprogramming
• Inherently slow
• Not economic for a simple low cost machines
CS311-Computer Organization
Control Unit
Lecture 9- 67