Finite State Machine
Based on Pong P. Chu Slides
Outline
1. Overview
2. FSM representation
3. Timing and performance of an FSM
4. Moore machine versus Mealy machine
5. VHDL description of FSMs
6. State assignment
7. Moore output buffering
8. FSM design examples
COEN313 - 2
1. Overview on FSM
• Contain “random” logic in next-state logic
• Used mainly used as a controller in a large
system
• Mealy vs Moore output
COEN313 - 3
2. Representation of FSM
• State diagram
COEN313 - 4
• E.g.
a memory
controller
COEN313 - 5
• ASM (algorithmic state machine) chart
– Flowchart-like diagram
– Provide the same info as an FSM
– More descriptive, better for complex description
– ASM block
• One state box
• One ore more optional decision boxes: with T or F exit path
• One or more conditional output boxes: for Mealy output
COEN313 - 6
COEN313 - 7
State diagram and ASM chart
conversion
• E.g. 1.
COEN313 - 8
• E.g. 2.
COEN313 - 9
• E.g. 3.
COEN313 - 10
• E.g. 4.
COEN313 - 11
• E.g. 6.
COEN313 - 12
• Difference between a regular flowchart and ASM
chart:
– Transition governed by clock
– Transition done between ASM blocks
• Basic rules:
– For a given input combination, there is one unique exit
path from the current ASM block
– The exit path of an ASM block must always lead to a
state box. The state box can be the state box of the
current ASM block or a state box of another ASM block.
COEN313 - 13
• Incorrect ASM charts:
COEN313 - 14
COEN313 - 15
COEN313 - 16
4. Moore vs Mealy output
• Moore machine:
– output is a function of state
• Mealy machine:
– output function of state and output
• From theoretical point of view
– Both machines have similar “computation
capability”
• Implication of FSM as a controller?
COEN313 - 17
• E.g., edge detection circuit
– A circuit to detect the rising edge of a slow “strobe”
input and generate a “short”
(about 1-clock period) output pulse.
COEN313 - 18
• Three designs:
COEN313 - 19
COEN313 - 20
• Comparison
– Mealy machine uses fewer states
– Mealy machine responds faster
– Mealy machine may be transparent to glitches
• Which one is better?
• Types of control signal
– Edge sensitive
• E.g., enable signal of counter
• Both can be used but Mealy is faster
– Level sensitive
• E.g., write enable signal of SRAM
• Moore is preferred
COEN313 - 21
VHDL Description of FSM
• Follow the basic block diagram
• Code the next-state/output logic
according to the state diagram/ASM
chart
• Use enumerate data type for states
COEN313 - 22
• E.g. 6.
COEN313 - 23
COEN313 - 24
COEN313 - 25
COEN313 - 26
COEN313 - 27