View
232
Download
0
Tags:
Embed Size (px)
Citation preview
CS 150 - Spring 2001 - Controller Implementation - 1
Overview
• Alternative controller FSM implementation approaches based on:– classical Moore and Mealy machines– jump counters– microprogramming (ROM) based approaches– branch sequencers– horizontal microcode– vertical microcode
CS 150 - Spring 2001 - Controller Implementation - 2
Alternative Ways to Implement Processor FSMs
• "Random Logic" based on Moore and Mealy Design– Classical Finite State Machine Design
• Divide and Conquer Approach: Time-State Method– Partition FSM into multiple communicating FSMs
• Exploit MSI Functionality: Jump Counters– Counters, Multiplexers, Decoders
• Microprogramming: ROM-based methods– Direct encoding of next states and outputs
CS 150 - Spring 2001 - Controller Implementation - 3
Random Logic
• Perhaps poor choice of terms for "classical" FSMs
• Contrast with structured logic: PAL/PLA, PGA, ROM
• Could just as easily construct Moore and Mealy machines with these components
CS 150 - Spring 2001 - Controller Implementation - 4
Moore MachineState Diagram
Note capture of MBRin these states
0 PC
Reset
Wait/
Wait/
Wait/
Wait/
Wait/
Wait/
=11=10
=0=1
BR0
BR1
IF3
OD
=00 =01
AD0ST0
ST1 AD1
Wait/Wait/
AD2
Wait/Wait/
LD0
LD1
LD2
Wait/
Wait/
PC MAR, PC + 1 PC
MAR Mem, 1 Read/Write,
1 Request, Mem MBR
MBR IR
IR MAR IR MAR
IR PC
MAR Mem,
1 Read/Write,
1 Request,
Mem MBR
MAR Mem,
0 Read/Write,
1 Request,
MBR Mem
MAR Mem,
1 Read/Write,
1 Request,
Mem MBR
MBR AC MBR + AC AC
IF2
IF1
IF0
RES
IR MAR,
AC MBR
CS 150 - Spring 2001 - Controller Implementation - 5
Memory-Register Interface Timing
Valid data latched on IF2 to IF3 transitionbecause data must be
valid before Wait can go low
CLK WAIT Mem Bus Latch MBR
IF1 IF2 IF2 IF2 IF3
Invalid Data Latched
Invalid Data Latched
Valid Data Latched
Data Valid
CS 150 - Spring 2001 - Controller Implementation - 6
Moore Machine Diagram
16 states, 4 bit state register
Next State Logic: 9 Inputs, 4 Outputs
Output Logic: 4 Inputs, 18 Outputs
These can be implemented via ROM or PAL/PLA
Next State: 512 x 4 bit ROMOutput: 16 x 18 bit ROM
Next State Logic
Clock State
Res
et
Wai
t IR
<15>
IR
<14>
A
C<1
5>
Output Logic
Rea
d/W
rite
R
eque
st
0
PC
P
C +
1
PC
P
C
AB
US
IR
A
BU
S
AB
US
M
AR
A
BU
S
PC
M
AR
M
emor
y A
ddre
ss B
us
Mem
ory
Dat
a B
us
MB
R
MB
R
Mem
ory
Dat
a B
us
MB
R
MB
US
M
BU
S
IR
M
BU
S
ALU
B
MB
US
A
C
RB
US
A
C
RB
US
M
BR
A
LU A
DD
CS 150 - Spring 2001 - Controller Implementation - 7
Moore Machine State Table
Reset WaitIR<15>IR<14>AC<15> Current State Next State Register Transfer Ops
1 X X X X X RES (0000)
0 X X X X RES (0000) IF0 (0001) 0 PC
0 X X X X IF0 (0001) IF1 (0001) PC MAR, PC + 1 PC
0 0 X X X IF1 (0010) IF1 (0010)
0 1 X X X IF1 (0010) IF2 (0011)
0 1 X X X IF2 (0011) IF2 (0011) MAR Mem, Read,
0 0 X X X IF2 (0011) IF3 (0100) Request, Mem MBR
0 0 X X X IF3 (0100) IF3 (0100) MBR IR
0 1 X X X IF3 (0100) OD (0101)
0 X 0 0 X OD (0101) LD0 (0110)
0 X 0 1 X OD (0101) ST0 (1001)
0 X 1 0 X OD (0101) AD0 (1011)
0 X 1 1 X OD (0101) BR0 (1110)
CS 150 - Spring 2001 - Controller Implementation - 8
Reset WaitIR<15>IR<14>AC<15> Current State Next State Register Transfer Ops
0 X X X X LD0 (0110) LD1 (0111) IR MAR
0 1 X X X LD1 (0111) LD1 (0111) MAR Mem, Read,
0 0 X X X LD1 (0111) LD2 (1000) Request, Mem MBR
0 X X X X LD2 (1000) IF0 (0001) MBR AC
0 X X X X ST0 (1001) ST1 (1010) IR MAR, AC MBR
0 1 X X X ST1 (1010) ST1 (1010) MAR Mem, Write,
0 0 X X X ST1 (1010) IF0 (0001) Request, MBR Mem
0 X X X X AD0 (1011) AD1 (1100) IR MAR
0 1 X X X AD1 (1100) AD1 (1100) MAR Mem, Read,
0 0 X X X AD1 (1100) AD2 (1101) Request, Mem MBR
0 X X X X AD2 (1101) IF0 (0001) MBR + AC AC
0 X X X 0 BR0 (1110) IF0 (0001)
0 X X X 1 BR0 (1110) BR1 (1111)
0 X X X X BR1 (1111) IF0 (0001) IR PC
Moore Machine State Table
CS 150 - Spring 2001 - Controller Implementation - 9
Moore Machine State Transition Table
• Observations:– Extensive use of Don't Cares– Inputs used only in a small number of state
e.g., AC<15> examined only in BR0 state IR<15:14> examined only in OD state
• Some outputs always asserted in a group• ROM-based implementations cannot take
advantage of don't cares• However, ROM-based implementation can
skip state assignment step
CS 150 - Spring 2001 - Controller Implementation - 10
Moore Machine Implementation
Assume PAL/PLA implementation style
First idea: run ESPRESSO with naive state assignment
.i 9
.o 4
.ilb reset wait ir15 ir14 ac15 q3 q2 q1 q0
.ob p3 p2 p1 p0
.p 261---- ---- 0000 0---- 0001 000100--- 0010 001001--- 0010 001101--- 0011 0011 00--- 0011 010000--- 0100 010001--- 0100 01010-00- 0101 01100-01- 0101 10010-10- 0101 10110-11- 0101 11100---- 0110 011101--- 0111 011100--- 0111 10000---- 1000 00010---- 1001 101001--- 1010 101000--- 1010 00010---- 1011 110001--- 1100 110000--- 1100 11010---- 1101 00010---0 1110 0001 0---1 1110 11110---- 1111 0001.e
.i 9
.o 4
.ilb reset wait ir15 ir14 ac15 q3 q2 q1 q0
.ob p3 p2 p1 p0
.p 210-00-0101 01100-01-0101 10010-11-0101 11100-10-0101 101101---1010 101000---0111 100000----011 01000----1000 00010---11110 111001---011- 01000----0001 000101---01-0 00010----1001 10100----1011 110000---1--0 00010----1100 11000----0-10 00100-----110 00010----11-1 00010----01-0 010001---0-1- 0011.e
21 product terms
Compare with 512product terms in ROMimplementation!
CS 150 - Spring 2001 - Controller Implementation - 11
Moore Machine ImplementationNOVA assignment does better
NOVA State Assignment SUMMARY
onehot_products = 22best_products = 18best_size = 414
states[0]:IF0 Best code: 0000states[1]:IF1 Best code: 1011states[2]:IF2 Best code: 1111states[3]:IF3 Best code: 1101states[4]:OD Best code: 0001states[5]:LD0 Best code: 0010states[6]:LD1 Best code: 0011states[7]:LD2 Best code: 0100states[8]:ST0 Best code: 0101states[9]:ST1 Best code: 0110states[10]:AD0 Best code: 0111states[11]:AD1 Best code: 1000states[12]:AD2 Best code: 1001states[13]:BR0 Best code: 1010states[14]:BR1 Best code: 1100states[15]:RES Best code: 1110
18 product termsimproves on 21!
CS 150 - Spring 2001 - Controller Implementation - 12
SynchronizerCircuitry atInputs and
Outputs
SynchronizerCircuitry atInputs and
OutputsOutput Logic
Output Logic
Output Logic
D
D
D
D
STATE STATE STATE
Q Q
Q
A A
A' A'
Q
ƒ
ƒ' ƒ
ƒ
ƒ'
A
Synchronous Mealy Machines
• Standard Mealy Machine has asynchronous outputs• These change in response to input changes, independent of
clock• Revise Mealy Machine design so outputs change only on
clock edges• One approach: non-overlapping clocks
CS 150 - Spring 2001 - Controller Implementation - 13
Synchronous Mealy Machines
Case I: Synchronizers at Inputs and Outputs
A asserted in Cycle 0, ƒ becomes asserted after 2 cycle delay!
This is clearly overkill!
cycle 0 cycle 1 cycle 2
CLK
A
A'
ƒ
ƒ'
S0
S1
S2
A/ƒ
CS 150 - Spring 2001 - Controller Implementation - 14
Synchronous Mealy Machine
Case II: Synchronizers on Inputs
A asserted in Cycle 0, ƒ follows in next cycle
Same as using delayed signal (A') in Cycle 1!
cycle 0 cycle 1 cycle 2
CLK
A
A'
ƒ
S0
S1
A/ƒ
S0
S1
A'/ƒ
CS 150 - Spring 2001 - Controller Implementation - 15
Synchronous Mealy Machines
Case III: Synchronized Outputs
A asserted during Cycle 0, ƒ' asserted in next cycle
Effect of ƒ delayed one cycle
cycle 0 cycle 1 cycle 2
CLK
A
ƒ
ƒ'
S0
S1
A/ƒ
CS 150 - Spring 2001 - Controller Implementation - 16
Synchronous Mealy Machines
• Implications for Processor FSM Already Derived• Consider inputs: Reset, Wait, IR<15:14>, AC<15>
– Latter two already come from registers, and are sync'd to clock
– Possible to load IR with new instruction in one state & perform multiway branch on opcode in next state
– Best solution for Reset and Wait: synchronized inputs» Place D flipflops between these external signals and the» control inputs to the processor FSM» Sync'd versions of Reset and Wait delayed by one clock cycle
CS 150 - Spring 2001 - Controller Implementation - 17
Time State Divide and Conquer
• Overview– Classical Approach: Monolithic Implementations– Alternative "Divide & Conquer" Approach:
» Decompose FSM into several simpler communicating FSMs
» Time state FSM (e.g., IFetch, Decode, Execute)» Instruction state FSM (e.g., LD, ST, ADD, BRN)» Condition state FSM (e.g., AC < 0, AC 0)
CS 150 - Spring 2001 - Controller Implementation - 18
Time State (Divide & Conquer)
Time State FSMMost instructions follow same basic sequence
Differ only in detailed execution sequence
Time State FSM can be parameterized by opcode and AC states
Instruction State:stored in IR<15:14>
Condition State:stored in AC<15>
T0
T1
T2
T3
T4
T5
T6
T7
Wait/
Wait/
Wait/
Wait/
Wait/
Wait/
BRN • AC 0/
(LD + ST + ADD) • Wait/
BRN + (ST • Wait)/
(LD + ADD) • Wait
IR
=11=10=01=00
LD ST ADD BRN
AC<15>=0
AC<15>=1
AC 0
AC < 0
CS 150 - Spring 2001 - Controller Implementation - 19
Time State (Divide & Conquer)
Generation of Microoperations
0 PC: Reset PC + 1 PC: T0 PC MAR: T0 MAR Memory Address Bus: T2 + T6 • (LD + ST + ADD) Memory Data Bus MBR: T2 + T6 • (LD + ADD) MBR Memory Data Bus: T6 • ST MBR IR: T4 MBR AC: T7 • LD AC MBR: T5 • ST AC + MBR AC: T7 • ADD IR<13:0> MAR: T5 • (LD + ST + ADD) IR<13:0> PC: T6 • BRN 1 Read/Write: T2 + T6 • (LD + ADD) 0 Read/Write: T6 • ST 1 Request: T2 + T6 • (LD + ST + ADD)
CS 150 - Spring 2001 - Controller Implementation - 20
Jump Counter
Concept
Implement FSM using MSI functionality: counters, mux, decoders
Pure jump counter: only one of four possible next states
Single "Jump State"function of the current
state
Hybrid jump counter:
Multiple "Jump States" — function of current state + inputs
HOLDN
LOAD
CLR CNT
0 N+1 XX
CS 150 - Spring 2001 - Controller Implementation - 21
Jump Counters
Pure Jump Counter
Logic blocks implemented via discrete logic, PALs/PLAs, ROMs
NOTE: No inputs tojump state logic
Inputs
Count, Load, Clear Logic
Jump State Logic
Synchronous Counter
State Register
ClearLoad
Count
CLOCK
CS 150 - Spring 2001 - Controller Implementation - 22
Jump CountersProblem with Pure Jump Counter
Difficult to implement multi-way branches
Logical State Diagram
Pure Jump CounterState Diagram
Extra States:
OD
LD0 ST0 AD0 BR0
OD0
OD1 BR0
OD2 AD0
LD0 ST0
4
5 8
6
7 10
9
CS 150 - Spring 2001 - Controller Implementation - 23
Jump Counters
Hybrid Jump Counter
Load inputs arefunction of stateand FSM inputs
Inputs
Count, Load, Clear Logic
Jump State Logic
Clear
LoadCount
Synchronous Counter
State RegisterCLOCK
CS 150 - Spring 2001 - Controller Implementation - 24
Jump Counters
Implementation Example
State assignmentattempts to take
advantage of sequential states
RESReset
IF0
IF1
OD
Wait/
Wait/
Wait/
Wait/
IF2
Wait/
Wait/
LD0
LD1
LD2
Wait/
Wait/
ST0
ST1Wait/
Wait/
AD0
AD1
AD2
Wait/
Wait/
BR05
6
7
8
9
10
11
12
13
1
2
3
4
0
CS 150 - Spring 2001 - Controller Implementation - 25
Jump Counters
Implementation Example, Continued
CNT = (s0 + s5 + s8 + s10) + Wait • (s1 + s3) + Wait • (s2 + s6 + s9 + s11)
CNT = Wait • (s1 + s3) + Wait • (s2 + s6 + s9 + s11)
CLR = Reset + s7 + s12 + s13 + (s9 • Wait)
CLR = Reset • s7 • s12 • s13 • (s9 + Wait)
LD = s4
Address00011011
Contents (Symbolic State)0101 (LD0)1000 (ST0)1010 (AD0)1101 (BR0)
Contents of Jump State ROM
CS 150 - Spring 2001 - Controller Implementation - 26
Jump Counters
Implementation Example, continued
Implement CNTusing active lo
PAL
NOTE: Active looutputs from
decoderImplement CLR
01
01
Wait /S11 /S9 /S6 /S3 /S2 /S1
Wait S11 S9 S6 S3 S2 S1
Cnt PAL
CNT
Jump State
IR<15> IR<14>
3 2 1 0
IR15
IR14
7 102
6 5 4 3
9
1
P T
CLK
D C B A
LOAD
CLR
RCO
QD QC QB QA
15
11 12 13 14
163
154
19 18
20 21 22 23
15 14 13 12 11 10
9 8 7 6 5 4 3 2 1 0
17 16 15 14 13 11 10 9 8 7 6 5 4 3 2 1
/S15 /S14 /S13 /S12 /S11 /S10 /S9 /S8 /S7 /S6 /S5 /S4 /S3 /S2 /S1 /S0
G2 G1
D C B A
/Reset
/WaitWait
/S4/Reset/S7
/S12/S13
/S9
Wait
HOLD
ANDOR
CS 150 - Spring 2001 - Controller Implementation - 27
Jump Counter
CLR, CNT, LDimplemented via Mux Logic
Active Lo outputs:hi input inverted at
the output
Note that CNT isactive hi on counter
so invert MUX inputs!
CLR = CLRm + Reset
CLR = CLRm + Reset/CLR
+
+ +
163
154
150150150
/CLRm/Reset /CLR
CNT
Jump State
IR<15>
IR14
IR15
IR<14>
3 2 1 0
P T
CLKD C B A
RCO
QD QC QB QA
LOAD
CLR
/LDReset
Wait
/Reset
/Wait
1 0
1 0
G2 G1
D C B A
Wait/Wait
EOUT EOUT EOUT
/Wait
CNT
10
/CLRm /LD
151413121110
9876543210
\S13\S12\S11\S10\S9\S8\S7\S6\S5\S4\S3\S2\S1\S0
E15E14E13E12E11E10E9E8E7E6E5E4E3E2E1E0
G
S3 S2 S1 S0
E15E14E13E12E11E10E9E8E7E6E5E4E3E2E1E0
G
S3 S2 S1 S0
E15E14E13E12E11E10E9E8E7E6E5E4E3E2E1E0
G
S3 S2 S1 S0
CS 150 - Spring 2001 - Controller Implementation - 28
Jump Counters
Microoperation implementation 0 PC = Reset PC + 1 PC = S0 PC MAR = S0 MAR Memory Address Bus = Wait•(S1 + S2 + S5 + S6 + S8 + S9 + S11 + S12) Memory Data Bus MBR = Wait•(S2 + S6 + S11) MBR Memory Data Bus = Wait•(S8 + S9) MBR IR = Wait•S3 MBR AC = Wait•S7 AC MBR = IR15•IR14•S4 AC + MBR AC = Wait•S12 IR<13:0> MAR = (IR15•IR14 + IR15•IR14 + IR15•IR14)•S4 IR<13:0> PC = AC15•S13 1 Read/Write = Wait•(S1 + S2 + S5 + S6 + S11 + S12) 0 Read/Write = Wait•(S8 + S9) 1 Request = Wait•(S1 + S2 + S5 + S6 + S8 + S9 + S11 + S12)
Jump Counters: CNT, CLR, LD function of current state + WaitWhy not store these as outputs of the Jump State ROM?Make Wait and Current State part of ROM address32 x as many words, 7 bits wide
CS 150 - Spring 2001 - Controller Implementation - 29
Branch Sequencers
ConceptImplement Next State Logic via ROM
Address ROM with current state and inputs
Problem: ROM doubles in size for each additional input
Note: Jump counter trades off ROM size vs. external logic Only jump states kept in ROM Even in hybrid approach, state + input subset form ROM address
Branch Sequencer: between the extremes Next State stored in ROM Each state limited to small number of next states Always a power of 2
Observe: only a small set of inputs are examined in any state
CS 150 - Spring 2001 - Controller Implementation - 30
Branch Sequencers
4 Way Branch Sequencer
Current State selects two inputs to form part of ROM address
These select one of four possible next states (and output sets)
Every state has exactly four possible next states
MuxMuxI
n p u t s
64 Word ROM
state
x11 x10 x01 x00
Z Y X W
C o n t r o l
S i g n a l s
a0 a1
a2 a3a4a5
N
W X Y Z
CS 150 - Spring 2001 - Controller Implementation - 31
Branch Sequencer
Processor CPU Design Example
Alpha, Beta multiplexer input setup
+ +
EOUT EOUT
s<3> s<2> s<1> s<0>
AC<15>
IR<15>
Wait
AC<15>
IR<14>
Wait
\
150 150
\
E15E14E13E12E11E10E9E8E7E6E5E4E3E2E1E0
G
S3 S2 S1 S0
E15E14E13E12E11E10E9E8E7E6E5E4E3E2E1E0
G
S3 S2 S1 S0
CS 150 - Spring 2001 - Controller Implementation - 32
Example Processor FSM
ROM ADDRESS ROM CONTENTS
(Reset, Current State, a, b) Next State Register Transfer Operations
RES 0 0000 X X 0001 (IF0) PC MAR, PC + 1 PC
IF0 0 0001 0 0 0001 (IF0)
0 0001 1 1 0010 (IF1) MAR Mem, Read, Request
IF1 0 0010 0 0 0011 (IF2) MAR Mem, Read, Request
0 0010 1 1 0010 (IF1) Mem MBR
IF2 0 0011 0 0 0011 (IF2)
0 0011 1 1 0100 (OD) MBR IR
OD 0 0100 0 0 0101 (LD0)IR MAR
0 0100 0 1 1000 (ST0)IR MAR, AC MBR
0 0100 1 0 1001 (AD0) IR MAR
0 0100 1 1 1101 (BR0) IR MAR
CS 150 - Spring 2001 - Controller Implementation - 33
Example Processor FSM
ROM ADDRESS ROM CONTENTS
(Reset, Current State, a, b) Next State Register Transfer Operations
LD0 0 0101 X X 0110 (LD1)MAR Mem, Read, Request
LD1 0 0110 0 0 0111 (LD2)Mem MBR
0 0110 1 1 0110 (LD1)MAR Mem, Read, Request
LD2 0 0111 X X 0000 (RES)MBR AC
ST0 0 1000 X X 1001 (ST1)MAR Mem, Write, Request, MBR Mem
ST1 0 1001 0 0 0000 (RES)
0 1001 1 1 1001 (ST1)MAR Mem, Write, Request, MBR Mem
AD0 0 1010 X X 1011 (AD1) MAR Mem, Read, Request
AD1 0 1011 0 0 1100 (AD2)
0 1011 1 1 1011 (AD1) MAR Mem, Read, Request
AD2 0 1100 X X 0000 (RES)MBR + AC AC
BR0 0 1101 0 0 0000 (RES)
0 1101 1 1 0000 (RES)IR PC
CS 150 - Spring 2001 - Controller Implementation - 34
Branch Sequencers
AlternativeHorizontalImplementation
Input MUX controlled by encoded signals, not stateMuch fewer inputs than unique states!In example FSM, input MUX can be 2:1!
Adding length to ROM word saves on bits vs. doubling wordsVertical format: (14 + 4) x 64 = 1152 ROM bitsHorizontal format: (14 + 4 x 4 + 2) x 16 = 512 ROM bits
M U X
and MUX Control
Datapath Control Signals
n bit state register
4:1 MUX
A0 A1 A2 A3
M U X
I N P U T S
0
1
1 0n-1 1 0n-1 1 0n-1 1 0n-1
. . .
bit 0bit 1bit n-1
0 1 2 34:1 MUX0 1 2 3
CS 150 - Spring 2001 - Controller Implementation - 35
MicroprogrammingHow to organize the control signals
Implement control signals by storing 1's and 0's in a ROM
Horizontal vs. vertical microprogramming
Horizontal: 1 ROM output for each control signal
Vertical: encoded control signals in ROM, decoded externally some mutually exclusive signals can be combined helps reduce ROM length
CS 150 - Spring 2001 - Controller Implementation - 36
Microprogramming
Register Transfer/Microoperations
14 Register Transfer operations become 22 Microoperations:
PC ABUS IR ABUS MBR ABUS RBUS AC AC ALU A MBUS ALU B ALU ADD ALU PASS B MAR Address Bus MBR Data Bus ABUS IR
ABUS MAR Data Bus MBR RBUS MBR MBR MBUS 0 PC PC + 1 PC ABUS PC Read/Write Request AC RBUS ALU Result RBUS
CS 150 - Spring 2001 - Controller Implementation - 37
Horizontal Microprogramming
Horizontal Branch Sequencer
Mux bits4 x 4 Next State bits22 Control operation bits
40 bits total
Next States
A0 A1 A2 A3
m
ux
m
ux
ALU
PA
SS
B
MA
R
Add
res
s B
us
MB
R
Da
ta B
us
AB
US
I
R
AB
US
M
AR
Dat
a B
us
M
BR
RB
US
M
BR
MB
R
MB
US
PC
A
BU
S
IR
AB
US
MB
R
AB
US
RB
US
A
C
AC
A
LU A
MB
US
A
LU B
A
LU A
DD
0
PC
PC
+ 1
P
C
AB
US
P
C
Rea
d/W
rite
R
equ
es
t
AC
R
BU
S
ALU
Re
su
lt
RB
US
CS 150 - Spring 2001 - Controller Implementation - 38
Horizontal Microprogramming
Moore Processor ROM
Alpha inputs: 0 = Wait, 1 = IR<15>Beta inputs: 0 = AC<15>, 1 = IR<14>
Current State (Address) RES (0000) IF0 (0001) IF1 (0010) IF2 (0011) IF3 (0100) OD (0101) LD0 (0110) LD1 (0111) LD2 (1000) ST0 (1001) ST1 (1010) AD0 (1011) AD1 (1100) AD2 (1101) BR0 (1110) BR1 (1111)
AB
US
I
R
AB
US
M
AR
Dat
a B
us
MB
R
RB
US
M
BR
MB
R
MB
US
0
PC
PC
+ 1
P
C
AB
US
P
C
Rea
d/W
rite
R
eque
st
AC
R
BU
S
ALU
Res
ult
R
BU
S
0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0001 0010 0010 0100 0100 0110 0111 1000 0001 1010 0001 1100 1101 0001 0001 0001
0001 0010 0010 0100 0100 1001 0111 1000 0001 1010 0001 1100 1101 0001 1111 0001
0001 0010 0011 0011 0101 1011 0111 0111 0001 1010 1010 1100 1100 0001 0001 0001
0001 0010 0011 0011 0101 1110 0111 0111 0001 1010 1010 1100 1100 0001 1111 0001
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 1 0 0 1 0 1 0 0 0 1
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 0 0 1 0 0 1 0 1 0 0 0 0
0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 0 1 0 0 0 0 1 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0
0 0 0 1 0 0 0 1 0 0 1 0 1 0 0 0
0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0
Next StatesA0 A1 A2 A3
mux
m
ux
0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
ALU
AD
D
ALU
PA
SS
B
MA
R
Add
ress
Bus
MB
R
Dat
a B
us
PC
A
BU
S
IR
AB
US
MB
R
AB
US
RB
US
A
C
AC
A
LU A
MB
US
A
LU B
CS 150 - Spring 2001 - Controller Implementation - 39
Horizontal MicroprogrammingAdvantages: most flexibility -- complete parallel access to datapath control points
Disadvantages: very long control words -- 100+ bits for real processors
Output Encodings:
Group mutually exclusive signalsUse external logic to decode
NOTE: Not all microoperation combinations make sense!
Example: 0 PC, PC + 1 PC, ABUS PC mutually exclusive
Save ROM bit with external 2:4 Decoder
CS 150 - Spring 2001 - Controller Implementation - 40
Horizontal Microprogramming
Partially EncodedControl Outputs
ALU ADD ALU PASS B
MAR Address Bus
MBR Data Bus
ABUS MAR
RBUS MBR Read/Write Request
AC RBUS
C O N T R O L R O M
RBUS AC
AC ALU A
MBUS ALU B
MBR MBUS
ALU Result RBUS
MBR ABUS
ABUS IR
0 PC
PC + 1 PC
ABUS PC
PC ABUS
IR ABUS
Data Bus MBR
2:4 DEC
2:4 DEC
01 10 11
01 10 11
2
2
CS 150 - Spring 2001 - Controller Implementation - 41
More extensive encoding to reduce ROM word length
• Typically use multiple microword formats:– Horizontal microcode -- next state + control bits
in same word– Separate formats for control outputs and
"branch jumps"– may require several microwords in a sequence
to implement same function as single horizontal word
• In the extreme, very much like assembly language programming
Vertical Microprogramming
CS 150 - Spring 2001 - Controller Implementation - 42
Vertical MicroprogrammingBranch JumpCompare indicatedsignal to 0 or 1
Register TransferSource,
Destination,Operation
10 ROM Bits
000: NO OP
001: PC ABUS
010: IR ABUS
011: MBR MBUS
100: MAR M
101: AC RBUS
110: ALU Res RBUS
Condition SelectCondition Compare
Branch Jump Format
Type
Next Address1 2 1 61
00 = Wait 01 = AC<15> 10 = IR<15> 11 = IR<14>
Register Transfer Format
0 Source Destination Operation1 3 3 3
000: NO OP
001: RBUS AC
010: MBUS IR
011: ABUS MAR
100: M MBR
101: RBUS MBR
110: ABUS PC
111: MBR M
000: NO OP 001: ALU ADD 010: ALU PASS B
011: 0 PC
100: PC + 1 PC 101: Read 110: Write
CS 150 - Spring 2001 - Controller Implementation - 43
Vertical Microprogramming
ROM ADDRESS SYMBOLIC CONTENTS BINARY CONTENTS
000000 RES RT PC MAR, PC +1 PC 0 001 011 100
000001 IF0 RT MAR M, Read 0 100 000 101
000010 BJ Wait=0, IF0 1 000 000 001
000011 IF1 RT MAR M, M MBR, Read 0 100 100 101
000100 BJ Wait=1, IF1 1 001 000 011
000101 IF2 RT MBR IR 0 011 010 000
000110 BJ Wait=0, IF2 1 000 000 101
000111 RT IR MAR 0 010 011 000
001000 OD BJ IR<15>=1, OD1 1 101 010 101
001001 BJ IR<14>=1, ST0 1 111 010 000
001010 LD0 RT MAR M, Read 0 100 000 101
001011 LD1 RT MAR M, M MBR, Read 0 100 100 101
001100 BJ Wait=1, LD1 1 001 001 011
001101 LD2 RT MBR AC 0 110 001 010
001110 BJ Wait=0, RES 1 000 000 000
001111 BJ Wait=1, RES 1 001 000 000
CS 150 - Spring 2001 - Controller Implementation - 44
Vertical Microprogramming
ROM ADDRESS SYMBOLIC CONTENTS BINARY CONTENTS
010000 ST0 RT AC MBR 0 101 101 000
010001 RT MAR M, MBR M, Write 0 100 111 110
010010 ST1 RT MAR M, MBR M, Write 0 100 111 110
010011 BJ Wait=0, RES 1 000 000 000
010100 BJ Wait=1, ST1 1 001 010 010
010101 OD1 BJ IR<14>=1, BR0 1 111 011 101
010110 AD0 RT MAR M, Read 0 100 000 101
010111 AD1 RT MAR M, M MBR, Read 0 100 100 101
011000 BJ Wait=1, AD1 1 001 010 111
011001 AD2 RT AC + MBR AC 0 110 001 001
011010 BJ Wait=0, RES 1 000 000 000
011011 BJ Wait=1, RES 1 000 000 000
011100 BR0 BJ AC<15>=0, RES 1 010 000 000
011101 RT IR PC 0 010 110 000
011110 BJ AC<15>=1, RES 1 011 000 000
31 words x 10 ROM bits = 310 bits total versus 16 x 38 = 608 bits horizontal
CS 150 - Spring 2001 - Controller Implementation - 45
Vertical Programming
Controller BlockDiagram
RBUS AC
ABUS IR
ABUS MAR
M MBR
RBUS MBR
ABUS PC
MBR M
PC ABUS
IR ABUS
MBR ABUS
MAR M
AC RBUS
ALU Res RBUS
3:8 DEC
3:8 DEC
0 1 2 3 4 5 6 7
0 1 2 3 4 5 6 7
Enb
Enb
LD CLR
CNT
Wait AC<15> IR<15> IR<14>
Reset
ClkCond Logic
PC
Reset
ALU ADD ALU PASS B 0 PC
Read/Write Request
PC + 1 PC Read Write
3:8 DEC
0 1 2 3 4 5 6 7Enb
T SRC DST OPAddress
ROM
CS 150 - Spring 2001 - Controller Implementation - 46
Vertical Microprogramming
Condition LogicCondition Selector
Condition Comparator
Microinstruction Type
LD
CNTMicroinstruction Type
Wait AC<15> IR<15> IR<14>
4:1 MUX
CS 150 - Spring 2001 - Controller Implementation - 47
Vertical Microprogramming
• Writeable Control Store– Part of control store addresses map into RAM
» Allows assembly language programmer to implement own instructions
» Extend "native" instruction set with application specific instructions
» Requires considerable sophistication to write microcode
» Not a popular approach with today's processors
– Make the native instruction set simple and fast– Write "higher level" functions as assembly
language sequences
CS 150 - Spring 2001 - Controller Implementation - 48
Controller Implementation Summary
• Control Unit Organization– Register transfer operation– Classical Moore and Mealy machines– Time State Approach– Jump Counter– Branch Sequencers– Horizontal and Vertical Microprogramming