Finite State Machine Design
Finite State Machine Design
Finite State Machine Design
Motivation
CSCI 3301
Chapter Overview
CSCI 3301
Memory Element
Basic Design Approach
Six Step Design Process
Memory Elements
CSCI 3301
Sequential Networks
Simple Circuits with Feedback
R-S Latch
J-K Flipflop
Edge-Triggered Flipflops
Realizing Circuits with Flipflops
Choosing a FF Type
Characteristic Equations
CSCI 3301
7474
D
Clk
Positiv e edge-triggered
f lip-f lop
7476
D
C
Clk
Lev el-s ens itiv e
latch
Bubble here
for negative
edge triggered
device
Clk
Q
Q
7474
7476
CSCI 3301
CSCI 3301
N
Coin
Sensor D
Res et
Vending
Machine
FSM
Open
Gum
Release
Mechanism
Clk
CSCI 3301
Re set
S0
N
Inputs: N, D, reset
Output: open
S2
S4
S5
S6
[ope n]
[ope n]
[ope n]
S3
S7
S8
[ope n]
[ope n]
CSCI 3301
Reset
0
0
N
5
D
5
N
10
D
N, D
10
15
[open]
15
reuse states
whenever
possible
Inputs
D N
0
0
1
1
0
0
1
1
0
0
1
1
X
0
1
0
1
0
1
0
1
0
1
0
1
X
Next
State
Output
Open
0
5
10
X
5
10
15
X
10
15
15
X
15
0
0
0
X
0
0
0
X
0
0
0
X
1
CSCI 3301
0
0
1
1
0
0
1
1
0
0
1
1
0
0
1
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
0
1
Next State
D1 D0
Output
Open
0
0
0
1
1
0
X X
0
1
1
0
1
1
X X
1
0
1
1
1
1
X X
1
1
1
1
1
1
X
X
0
0
0
X
0
0
0
X
0
0
0
X
1
1
1
X
CSCI 3301
Q1
D
Q0
N
D1 D
CLK
R
Q1
\ Q1
D1 = Q1 + D + Q0 N
\reset
N
\ Q0
Q0
\N
Q1
N
Q1
D
OPEN
D0 D
CLK
Q
R
\reset
D0 = N Q0 + Q0 N + Q1 N + Q1 D
OPEN = Q1 Q0
Q0
Q \ Q0
8 Gates
Transparency No. 8-11
CSCI 3301
J-K FF
Pres ent State Inputs
Q1 Q0
D N
0
0
0
0
0
1
1
0
1
1
0
1
0
0
0
1
1
0
1
1
1
0
0
0
0
1
1
0
1
1
1
1
0
0
0
1
1
0
1
1
Next State J1
D 1 D0
0
0
1
X
0
1
1
X
1
1
1
X
1
1
1
X
0
1
0
X
1
0
1
X
0
1
1
X
1
1
1
X
0
0
1
X
0
1
1
X
X
X
X
X
X
X
X
X
K1
J0 K 0
X
X
X
X
X
X
X
X
0
0
0
X
0
0
0
X
0
1
0
X
X
X
X
X
0
1
1
X
X
X
X
X
X
X
X
X
0
1
0
X
X
X
X
X
0
0
0
X
CSCI 3301
Implementation:
J1 = D + Q0 N
K1 = 0
J0 = Q0 N + Q1 D
K0 = Q1 N
N
Q0
D
\ Q0
J
CLK
K RQ
Q1
\ Q1
N
OPEN
Q1
D
CLK
\ Q1
KR Q
Q0
\ Q0
\reset
7 Gates
CSCI 3301
Mealy Machine
Xi
Inputs
Zk
Outputs
Combinational
Logic for
Outputs a nd
Ne xt State
State Regis te r
Clock
Outputs depend on
state AND inputs
Input change causes
an immediate output
change
State
Fe edback
Asynchronous signals
State
Re giste r
Xi
Inputs
Moore Machine
Comb.
Logic for
Outputs
Combinational
Logic for
Ne xt State
(Flip-flop
Inputs )
Zk
Outputs
Cloc k
state
feedbac k
CSCI 3301
Moore
Machine
N D + Reset
(N D + Reset)/0
Reset/0
Reset
0
Mealy
Machine
[0]
Reset/0
Reset
N/0
5
N D/0
D/0
ND
D
[0]
N
N/0
10
10
D
D/1
N D/0
N+ D/1
[0]
N+ D
ND
15
15
Reset/1
[1]
Reset
CSCI 3301
0
[0]
Different # of states
1/0
0/0
1
1/1
[0]
1
2
[1]
CSCI 3301
CSCI 3301
A finite string recognizer has one input (X) and one output (Z).
The output is asserted whenever the input sequence 010
has been observed, as long as the sequence 100 has never been
seen.
Step 1. Understanding the problem statement
Sample input/output behavior:
X: 00101010010
Z: 00010101000
X: 11011010010
Z: 00000001000
CSCI 3301
Outputs 1
Loops in State
CSCI 3301
CSCI 3301
CSCI 3301
CSCI 3301
CSCI 3301
Current State
000
001
010
110
111
101
110
CSCI 3301
CSCI 3301
CSCI 3301
Fa rmroad
C
HL
FL
Highw ay
Highw ay
HL
FL
C
Fa rmroad
CSCI 3301
Description
place FSM in initial state
detect vehicle on farmroad
short time interval expired
long time interval expired
Output Signal
HG, HY, HR
FG, FY, FR
ST
Description
assert green/yellow/red highway lights
assert green/yellow/red farmroad lights
start timing a short or long interval
Description
Highway green (farmroad red)
Highway yellow (farmroad red)
Farmroad green (highway red)
Farmroad yellow (highway red)
CSCI 3301
S0: HG
S0
TLC/ST
S1: HY
TS /ST
TS
S1
S2: FG
S3
TS
TS /ST
S3: FY
TL + C/ST
S2
TL C
CSCI 3301
"3 bit serial lock controls entry to locked room. Inputs are RESET,
ENTER, 2 position switch for bit of key data. Locks generates an
UNLOCK signal when key matches internal combination. ERROR
light illuminated if key does not match combination. Sequence is:
(1) Press RESET, (2) enter key bit, (3) Press ENTER, (4) repeat (2) &
(3) two more times."
Problem specification is incomplete:
how do you set the internal combination?
CSCI 3301
Operator Data
ENTER
UNLOCK
KEY-IN
Combination
Lock F SM ERR OR
Internal
Combination
Inputs:
Reset
Enter
Key-In
L0, L1, L2
L0
L1
L2
Outputs:
Unlock
Error
CSCI 3301
Re set + E nter
Re set
Start
Re set Enter
Comp0
KI = L0
KI L0
Ente r
Ente r
Idle0
Idle0'
Ente r
Ente r
Comp1
KI = L1
Error1
KI L1
Ente r
Ente r
Idle1
Idle1'
Ente r
Ente r
Comp2
KI = L2
Re set
Done
[Unloc k]
Re set
Start
Error2
KI L2
Error3
[Error]
Re set
Re set
Start