Intro. To Comp. Eng. Chapter Viii-1 Finite State Machines
Intro. To Comp. Eng. Chapter Viii-1 Finite State Machines
Intro. To Comp. Eng. Chapter Viii-1 Finite State Machines
•CHAPTER VIII
CHAPTER VIII-1
FINITE STATE MACHINES
CHAPTER VIII
• Mealy machine
• Sequential system where Sequential System
output depends on current Input Output
Combinational
input and state. Logic
Memory
(state)
• Moore machine
• Sequential system where Sequential System
output depends only on Input
Combinational
current state. Logic
Memory Output
(state)
a /p Input: x ( t ) ∈ { a, b }
Output: z ( t ) ∈ { p, q }
Sk Sj State: s ( t ) ∈ { S k, S j }
Initial state: s ( 0 ) = Sk
State
b /q
Input/Output
• The following is a simple example. What does this state machine do?
0/1 0/0 Input: x ( t ) ∈ { 0, 1 }
Output: z ( t ) ∈ { 0, 1 }
S0 S1 1/0 State: s ( t ) ∈ { S 0, S 1 }
Initial state: s ( 0 ) = S0
1/0
• Consider the simple bit flipper looked at the in previous chapter. How
would a state diagram be formed?
• Below is one possible way of drawing the state diagram for the bit flipper.
-/1
S0 S1
-/0
• Since the bit flipper is a Moore machine, the state diagram can also be
-
S0 ⁄ 0 S1 ⁄ 1
1 if x ( t – 3, t ) = 1101
Function: z(t) =
0 otherwise
• Effectively, the system should output a 1 when the last set of four inputs
have been 1101.
• For instance, the following output z(t) is obtained for the input x(t)
t 0123456789...
x(t) 100100100100110101101101001101001
z(t) ???000000000000100001001000001000
• The following state diagram gives the behaviour of the desired 1101 pattern
detector.
• Consider S 0 to be the initial state, S 1 when first symbol detected (1), S 2
S0 S1 1/0 S2 0/0 S3
0/0
1/1
0/0
-
S0 ⁄ 0 S1 ⁄ 1
S 0 or 0 0 0 S 0 or 0 0 0
S 0 or 0 0 1 S 1 or 0 1 0
S 1 or 0 1 0 S 0 or 0 0 0
S 1 or 0 1 1 S 2 or 1 0 0
S 2 or 1 0 0 S 3 or 1 1 0
S 2 or 1 0 1 S 2 or 1 0 0
S 3 or 1 1 0 S 0 or 0 0 0
S 3 or 1 1 1 S 1 or 0 1 1
• With the descriptions of a FSM as a state diagram and a state table, the
next question is how to develop a sequential circuit, or logic diagram from
the FSM.
• Effectively, we wish to form a circuit as follows.
Inputs
Combinational Outputs
Network (Mealy machine)
State
FF
Present State φ 1φ 2 Next State
FF Outputs
φ 1φ 2 (Moore machine)
• The procedure for developing a logic circuit from a state table is the same
as 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 external
inputs and outputs of state bit registers (which have the present state).
• Draw logic diagram components connecting inputs of state bits (for next
state) to the external inputs and outputs of state bit registers (which have
the present state).
N 1 = XP 1 + XP 1 P 0
N 0 = XP 1 P 0 + XP 1 P 0 + XP 1 P 0 = XP 1 P 0 + X ( P 1 ⊕ P 0 )
Z = XP 1 P 0
• Notice that the previous Boolean functions can also be expressed with time
as follows.
N1 ( t ) = P1 ( t + 1 ) = X ( t ) ⋅ P1 ( t ) + X ( t ) ⋅ P1 ( t ) ⋅ P0 ( t )
N0 ( t ) = P0 ( t + 1 ) = X ( t ) ⋅ P1 ( t ) ⋅ P0 ( t ) + X ( t ) ⋅ P1 ( t ) ⋅ P0 ( t )
+ X ( t ) ⋅ P1 ( t ) ⋅ P0 ( t )
= X ( t ) ⋅ P1 ( t ) ⋅ P0 ( t ) + X ( t ) ⋅ P1 ( t ) ⊕ P0 ( t )
Z ( t ) = X ⋅ P1 ( t ) ⋅ P0 ( t )
N0 P0
φ1 φ2
N1 P1
φ1 φ2
Z
X
S EE ⁄ p S EO ⁄ q S OO ⁄ p S OE ⁄ p
• Finally, for each state, consider the effect for each possible input.
• For instance, starting with state S EE , the next state for the three input a,
b, and c are determined as follows.
S EE ⁄ p b S EO ⁄ q S OO ⁄ p S OE ⁄ p
c
b a b
b a b
c S EE ⁄ p S EO ⁄ q S OO ⁄ p S OE ⁄ p c
c c
• A state table can also be formed for this state diagram as follows.
• First, assign a binary number to each state
• S EE = 00 , S EO = 01 , S OO = 10 , S OE = 11
• Assign a binary number to each input
• a = 00, b = 01, c = 10
• Assign a binary number to each output
• p = 0, q = 1
• Then for each state, find the next state for each input. In this case there
are three possible input values, so, three possible state transitions from
each state.
• The state table on the following slide shows the results for this example.
• The Boolean function for the output can be determined from a Karnaugh
map as follows.
• Note that an input of 11 is not possible since we only have three inputs
that we have assigned to 00, 01, and 10. We can therefore use don’t
cares for this possible input.
P1P0
X1X0 00 01 11 10
00 0 1 0 0
01 0 1 0 0 Z = P1 P0
11 X X X X
10 0 1 0 0
• The Boolean function for the next state bit can also be determined from
Karnaugh maps as follows.
P1P0 P1P0
X1X0 00 01 11 10 X1X0 00 01 11 10
00 1 1 0 0 00 1 0 0 1
01 0 0 1 1 01 1 0 0 1
11 X X X X 11 X X X X
10 0 0 1 1 10 0 1 1 0
N1 = P1 ⊕ X1 ⊕ X0 N0 = P0 X1 + P0 X1 = P0 ⊕ X1
• The following logic circuit can be made with these Boolean functions.
N1 = P1 ⊕ X1 ⊕ X0
N0 = P0 ⊕ X1
Z = P1 P0
N0 P0
X1 φ1 φ2
X0
Z
N1 P1
φ1 φ2
• N2 = X ( P 1 ⊕ P0 ) + X ( P1 ⊕ P0 )
• N1 = P2
• N0 = P1
• Z = XP 1 P 2
• Derive the state table.
• Derive the state diagram.
1/0
1/0
S0 0/0 S1 0/0 S2 S3
S4 S5 S6 S7
1/0 1/1
0/0
0/0