Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Spring 2012
EECS150 - Lec17-fsm
Page 1
Behavior is represented by
State Transition Diagram:
traverse one edge per clock
cycle.
Spring 2012
EECS150 - Lec17-FSM
Page 2
FSM Implementation
EECS150 - Lec17-FSM
Page 3
EECS150 - Lec17-FSM
Page 4
Spring 2012
EECS150 - Lec17-FSM
Page 5
0
0
1
1
0
1
0
1
EVEN
ODD
ODD
EVEN
EECS150 - Lec17-FSM
Circuit Diagram:
XOR gate for NS calculation
DFF to hold present state
no logic needed for output in
this example.
Spring 2012
EECS150 - Lec17-FSM
ps
ns
Page 7
Spring 2012
EECS150 - Lec17-FSM
Page 8
EECS150 - Lec17-FSM
Page 9
EECS150 - Lec17-FSM
Page 10
ENTER
0
1
1
0
1
1
*
0
1
*
*
Spring 2012
EECS150 - Lec17-FSM
Page 11
Encoded ST Table
Assign states:
START=000, OK1=001, OK2=011
BAD1=100, BAD2=101
Spring 2012
NS1
NS0
Page 12
State Encoding
In general:
# of possible FSM state = 2# of Flip-flops
Example:
state1 = 01, state2 = 11, state3 = 10, state4 = 00
EECS150 - Lec17-FSM
Page 13
State Encoding
Spring 2012
EECS150 - Lec17-FSM
Page 14
Circuit generated
through direct
inspection of the STD.
In General:
Spring 2012
EECS150 - Lec17-FSM
Page 15
Spring 2012
EECS150 - Lec17-FSM
Page 16
EECS150 - Lec17-FSM
Page 17
IN
FSM
OUT
EECS150 - Lec17-FSM
Page 18
IN
0
ZERO
1
0
CHANGE
1
0
ONE
1
Spring 2012
EECS150 - Lec17-FSM
PS
00
00
01
01
11
11
NS
00
01
00
11
00
11
OUT
0
0
1
1
0
0
Page 19
Spring 2012
PS
00
00
01
01
11
11
NS
00
01
00
11
00
11
OUT
0
0
1
1
0
0
EECS150 - Lec17-FSM
Page 20
Solution B
Output depends not only on PS but also on input, IN
Let ZERO=0,
ONE=1
IN PS NS OUT
0 0
0
0
0 1
0
0
1 0
1
1
1 1
1
0
NS = IN, OUT = IN PS
EECS150 - Lec17-FSM
Page 21
EECS150 - Lec17-FSM
Page 22
FSM Comparison
Solution A
Moore Machine
output function only of PS
maybe more states (why?)
synchronous outputs
no glitches
one cycle delay
full cycle of stable output
Solution B
Mealy Machine
output function of both PS & input
maybe fewer states
asynchronous outputs
if input glitches, so does output
output immediately available
output may not be stable long
enough to be useful (below):
If output of Mealy FSM
goes through combinational
logic before being
registered, the CL might
delay the signal and it could
be missed by the clock edge.
Spring 2012
EECS150 - Lec17-FSM
Page 23
FSM Recap
Moore Machine
Mealy Machine
EECS150 - Lec17-FSM
Page 24
Spring 2012
EECS150 - Lec17-FSM
Page 25
EECS150 - Lec17-FSM
Page 26
FSMs in Verilog
Mealy Machine
Moore Machine
Spring 2012
EECS150 - Lec17-FSM
Page 27