Representing a Finite State Machine

Digital Logic
Design
Dr. Oliver Faust
Finite state
machines
Floyd, Digital Fundamentals, 10th ed
2008
Pearson
© 2009 Pearson Education, ©
Upper
Saddle
River, NJ 07458. All Rights Reserved
Outline
In this lecture we cover:
• Introduction to Finite State Machines (FSMs)
• Mod-4 Counter example
Floyd, Digital Fundamentals, 10th ed
© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved
Finite State Machines
vs.
Combinational Logic Units

Combinational logic units are a type of logic
circuit whose output is a pure function of the
present input only.

Finite State Machines, used in sequential logic,
have outputs that depend on both the present
input as well as the history of the input.
A Finite State Machine

A sequential logic unit which
 Takes
an input and a current state
 Produces
an output and a new state

It is called a Finite State Machine because it
can have, at most, a finite number of states.

It is composed of a combinational logic unit
and flip-flops placed in such a way as to
maintain state information.
Finite state machine block diagram
PREVIOUS STATE
STATE MEMORY
D
SET
Q
OUTPUTS
NEXT STATE
LOGIC
CLR
Q
...
INPUTS
NEXT
STATE
D
SET
CLR
OUTPUT LOGIC
Q
Q
CLK

State memory: Set of n flip-flops that hold the
state of the machine (up to 2^n distinct states)

Next state logic: Combinational circuit that
determines the next state as a function of the
current state and the input

Output logic: Combinational circuit that
determines the output as a function of the current
state and the input
STATE MEMORY
D
SET
OUTPUTS
INPUTS
COMBINATIONAL
LOGIC
NEXT
STATE
CLR
D
SET
CLR
Moore machine: The
output depends only on
the current state
 State
= output state
machine: A Moore type
FSM where the current
state is the output
OUTPUT LOGIC
Q
Q
CLK
PREVIOUS STATE
STATE MEMORY
D
SET
Q
OUTPUTS
INPUTS
COMBINATIONAL
LOGIC
NEXT
STATE
Q
CLR
OUTPUT LOGIC
...

Mealy machine: The
output depends on the
current state and input
Q
D
SET
CLR
Q
Q
CLK
PREVIOUS STATE
STATE MEMORY
D
INPUTS
COMBINATIONAL
LOGIC
NEXT
STATE
SET
CLR
D
SET
CLR
CLK
Q
Q
...

Q
...
Finite State Machine
types
PREVIOUS STATE
Q
Q
OUTPUTS
Representing a Finite State Machine

It can be represented using a state transition table which shows
the current state, input, any outputs, and the next state.
Input
Input0
Input1
….
Inputn
Current State
State0
State1
….
Staten
Next State / Output
….
….
….
….
….
….
….
Next State / Output
….
….
….
Representing a Finite State Machine

It can also be represented using a state diagram
which has the same information as the state
transition diagram.
Input / Output
State0
State1
Input / Output
Example 1:
A Modulo-4 Synchronous Counter

Counts from 0 to 3 and then repeats.

It has a clock input (CLK) and a RESET input.

Outputs appear as a sequence of values (q1 and
q0) at time steps corresponding to the clock.

As the outputs are generated, a new state (s1s0)
is generated which takes on values of 00, 01, 10,
and 11 and are fed back to the input.
The Mod-4 Counter
•
•
Requires four states, encoded in binary, with at
least two bits for them to be encoded uniquely.
▫
A = 00
▫
B = 01
▫
C = 10
▫
D = 11
The input requires only a single bit.
▫
0|1
State Transition
Diagram for
the Mod-4 Counter
State Table for the Mod-4 Counter
State Assignment for the Mod-4 Counter
Truth Table for the Mod-4 Counter
Logic Design for Mod-4 Counter
Outlook
Next lecture covers:
• Advanced FSM examples:
• Sequence detector example
• Vending machine example
Floyd, Digital Fundamentals, 10th ed
© 2009 Pearson Education, Upper Saddle River, NJ 07458. All Rights Reserved