

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
•CHAPTER VIII
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- STATE MACHINES
-INTRODUCTION
From the previous chapter we can make simple memory elements.•
Latches as well as latches with control signals
Flip-flops
Registers
The goal now is to use the memory elements to hold the running state ofthe machine.•
The state of the machine can be used to perform sequential operations.
This chapter will discuss how to represent the state of the machine fordesign and communication purposes.
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- STATE MACHINES
-INTRODUCTION-MEALY & MOORE MACH.
Synchronous sequential system •
Behaviour depends on the inputs and outputs at discrete instants of time.
Flip-flops, registers, and latches that are enabled/controlled with a signalderived from clock form a synchronous sequential system.
Asynchronous sequential system •
Behaviour depends on inputs at any instant of time.
Latches without control signals behave in an asynchronous manner.
The state machines discussed in this chapter will be synchronoussequential systems (i.e. controlled by a clock) •
This allows us to form timed Boolean functions such as
where
is the next state of a D flip-flop
t ( )
A
t
A
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- STATE MACHINES
-INTRODUCTION-MEALY & MOORE MACH.-SYNC. & ASYNC SYSTEMS
A state diagram represents a finite state machine (FSM) and contains •
Circles
: represent the machine states
Labelled with a binary encoded number or
reflecting state.
Directed arcs
: represent the transitions between states
Labelled with input/output for that state transition.
k
k
j
State
Input/Output
a/
p
b/
q
x t
a b
Input:
z t
p q
Output:
s t
k
j
State:
s 0
k
Initial state:
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- STATE MACHINES - STATE DIAGRAMS
-ELEMENTS OF DIAGRAMS-PROPERTIES
The following is a simple example. What does this state machine do?
Here is a simplified way of forming the above state machine. •
S An input of 0 or 1 causes the transition with output 1 and 0, respectively.
0
1
x t
Input:
z t
Output:
s t
0
1
State:
s 0
0
Initial state:
0
1
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- STATE DIAGRAMS
-ELEMENTS OF DIAGRAMS-PROPERTIES-STATE DIAGRAM EX.
Consider the simple bit flipper looked at the in previous chapter. Howwould a state diagram be formed? •
Below is one possible way of drawing the state diagram for the bit flipper.
Since the bit flipper is a Moore machine, the state diagram can also be
0
1
0
1
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- STATE DIAGRAMS
-STATE DIAGRAM EX.-BIT FLIPPER EX.-PATTERN DETECT EX.
The following state diagram gives the behaviour of the desired 1101 patterndetector. •
Consider
to be the initial state,
when first symbol detected (
when subpattern
detected, and
when subpattern
detected.
0
1
2
3
0
1
2
3
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- STATE DIAGRAMS
-STATE DIAGRAM EX.-BIT FLIPPER EX.-PATTERN DETECT EX.
State tables also express a systems behaviour and consists of •
Present state
The present state of the system, typically given in binary encodedform or with
. So, a state of
in our state diagram with 10
states would be represented as 0101 since we require 4 bits.
Inputs
Whatever external inputs used to cause the state transitions.
Next state
The next state, generally in binary encoded form.
Outputs
Whatever outputs, other then the state, for the system. Note thatthere would be no outputs in a Moore machine.
k
5
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- STATE DIAGRAMS - STATE TABLES
-INTRODUCTION-BIT FLIPPER EX.
From a state diagram, a state table is fairly easy to obtain. •
Determine the number of states in the state diagram.
If there are
states and
1-bit inputs, then there will be
rows in
the state table.
Example: If there are 3 states and 2 1-bit inputs, each state willhave
possible inputs, for a total of 3*4=12 rows.
Write out for each state, the
possible input rows.
For each state/input pair, follow the directed arc in the state diagram todetermine the next state and the output.
m
n
m
n
(^2)
n
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- STATE TABLES
-INTRODUCTION-BIT FLIPPER EX.-TRANSLATE DIAGRAM
If we consider the pattern detection example previously discussed, thefollowing would be the state table.
Present State
Next State
Input
Output
0
or
1
0
0
or
1
or
1
or
2
or
2
or
3
or
3
or
0
or
1
or
0
or
2
or
3
or
2
or
0
or
1
or
1
0
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- STATE TABLES
-TRANSLATE DIAGRAM-PATTERN DETECT EX.-TRANSLATE TO DIAGRAM
With the descriptions of a FSM as a state diagram and a state table, thenext question is how to develop a sequential circuit, or logic diagram fromthe FSM.
Effectively, we wish to form a circuit as follows.
Inputs
Combinational
Network
State
Outputs
(Mealy machine)
Outputs
(Moore machine)
φ
1
φ
2
φ
1
φ
2
Present State
Next State
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- STATE TABLES - SEQUENTIAL CIRCUITS
-INTRODUCTION
The procedure for developing a logic circuit from a state table is the sameas with a regular truth table. •
Generate Boolean functions for
each external outputs using external inputs and present state bits
each next state bit using external inputs and present state bits
Use Boolean algebra, Karnaugh maps, etc. as normal to simplify.
Draw a register for each state bit.
Draw logic diagram components connecting external outputs to externalinputs and outputs of state bit registers (which have the present state).
Draw logic diagram components connecting inputs of state bits (for nextstate) to the external inputs and outputs of state bit registers (which havethe present state).
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- SEQUENTIAL CIRCUITS
-INTRODUCTION-DEVEL. LOGIC CIRCUITS-PATTERN DETECT EX.
Notice that the previous Boolean functions can also be expressed with timeas follows.
An important thing to note in these equations is the relation between thepresent states P and the next states N.
1
t ( )
1
t
t ( )
1
t ( )
t ( )
1
t ( )
0
t ( )
0
t ( )
0
t
t ( )
1
t ( )
0
t ( )
t ( )
1
t ( )
0
t ( )
t ( )
1
t ( )
0
t ( )
t ( )
1
t ( )
0
t ( )
t ( )
1
t ( )
0
t ( )
t ( )
1
t ( )
0
t ( )
INTRO. TO COMP. ENG.
CHAPTER VIII-
FINITE STATE MACHINES
- SEQUENTIAL CIRCUITS
-INTRODUCTION-DEVEL. LOGIC CIRCUITS-PATTERN DETECT EX.
The following logic circuit implements the pattern detect example.
1
φ
1
φ
0
φ
1
φ
2
1
N
0