Mealy & Moore Sequential Calculations
Mealy & Moore Sequential Calculations
Analysis of Clocked Sequential Circuits COE 202 – Digital Logic Design © Muhamed Mudawar – slide 21
Mealy Machine
! The outputs are a function of the present state and Inputs
! The outputs may change if inputs change during the clock cycle
! The correct outputs are present just before the edge of the clock
Analysis of Clocked Sequential Circuits COE 202 – Digital Logic Design © Muhamed Mudawar – slide 22
Mealy State Diagram
! An example of a Mealy state
diagram is shown on the right
Cycle 0 1 2 3 4 5 6 7 8
Input x 0 1 1 0 1 1 1 1 0
Present ? 0 0 1 0 0 1 1 1
State A B ? 0 1 0 0 1 0 0 0
Output z 0 0 0 0 0 0 1 1 0
Negative edge-triggered
A
Analysis of Clocked Sequential Circuits COE 202 – Digital Logic Design © Muhamed Mudawar – slide 25
Moore Machine
! The outputs are a function of the Flip-Flop outputs only
Analysis of Clocked Sequential Circuits COE 202 – Digital Logic Design © Muhamed Mudawar – slide 26
Moore State Diagram
0
! An example of a Moore state
0
diagram is shown on the right
00 1 01
0 0
! Arcs are labeled with input only
0 0 1
! The output is shown inside the
state: (State / Output)
11 10
! The output depends on the 1 1 0
current state only
1
Analysis of Clocked Sequential Circuits COE 202 – Digital Logic Design © Muhamed Mudawar – slide 27
Tracing a Moore State Diagram
! When the circuit is powered, the initial 0
state (AB) and output are unknown 0
Cycle 0 1 2 3 4 5 6 7 8 0 0 1
Input x 0 1 1 0 1 1 1 1 0
11 10
Present ? 0 0 1 0 0 1 1 1 1 1 0
State A B ? 0 1 0 0 1 0 1 1
1
Output z ? 0 0 0 0 0 0 1 1
Analysis of Clocked Sequential Circuits COE 202 – Digital Logic Design © Muhamed Mudawar – slide 28
Timing Diagram of a Moore Machine
Cycle 0 1 2 3 4 5 6 7 8
The output is
Input x 0 1 1 0 1 1 1 1 0
synchronized with the
Present ? 0 0 1 0 0 1 1 1
clock. No false output
State A B ? 0 1 0 0 1 0 1 1
(or glitch) can appear.
Output z ? 0 0 0 0 0 0 1 1
Negative edge-triggered
A
Analysis of Clocked Sequential Circuits COE 202 – Digital Logic Design © Muhamed Mudawar – slide 29
The Design Procedure
Given a Description (or Specification) of the Problem
2. Assign binary codes to the states and fill the state table
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 3
The State Diagram
! A state is an abstraction of memory
! Examples:
" State S2 represents the fact that the last two-input sequence is "11"
! The output is also a bit stream: One output bit " each cycle
! Sequence "
Detector
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 5
State Diagram for a Sequence Detector
! Example: Design a circuit that detects the input sequence "111"
! Begin in an initial state: call it S0
S0 indicates that a 1 is NOT detected yet
As long as the input # is 0, remain in the initial state S0
! Add a state (call it S1) that detects the first 1 in the input
! Add a state (call it S2) that detects the input sequence "11"
! Add a state (call it S3) that detects the input sequence "111"
0
1 1 1
S0 S1 S2 S3
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 6
Complete the State Diagram
Moore Design: Assign Output to States
The output in S0, S1, and S2 should be 0 0
0
The output in S3 should be 1
S0 1 S1
0 0
Now complete the state diagram:
Add transitions from S1, S2, S3 0 0 1
back to S0 if the input is 0
Add transition from S3 to itself if S3 S2
1 1 0
the input is 1 to detect sequences
longer than three 1's
1
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 7
State Assignment
! Each state must be assigned a unique binary code
! In our example, there are four states: S0, S1, S2, and S3
clock
2. Output Logic
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 10
Derive Next State an Output Equations
# 0. # 0/
Present Next State Output -. -/ 0 1 -. -/ 0 1
State ! = 0 ! = 1 " 00 0 0 00 0 1
00 00 01 0 01 0 1 01 0 0
01 00 10 0 11 0 1 11 0 1
10 00 11 0
10 0 1 10 0 1
11 00 11 1
-. # + -/ # -. # + -/2 #
Two D-type Flips-Flops
Present State = Flip-Flop Outputs -. and -/
Next State = Flip-Flop Inputs 0. and 0/
Next State equations: 0. = -. # + -/ # and 0/ = -. # + -/2 #
Output equation: 3 = -. -/ (from the state diagram)
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 11
Draw the Moore Sequence Detector Circuit
0. = -. # + -/ # , 0/ = -. # + -/2 # 3 = -. -/
0. -.
-.2
0/ -/
-/2
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 12
Mealy Type Sequence Detector
! Let us redesign a Mealy type "111" sequence detector
! The initial state S0 indicates that a 1 is NOT detected yet
As long as the input ! is 0, remain in the initial state S0
Notice that input / output is written on the arc (Mealy type)
! Add a state (call it S1) that detects the first 1 in the input
! Add a state (call it S2) that detects the input sequence "11"
0/0
S0 1/0 S1 1/0 S2
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 13
Complete the Mealy State Diagram
! State S2 is reached after detecting the input sequence "11"
! At S2, if the next input is 1 then the output should be 1
Make a transition from S2 back to itself labeled 1 / 1
No need for state S3, because output is on the arc
! Now complete the state diagram
Add transitions from S1 and S2 back to S0 when input is 0
0/0
0/0 1/1 Mealy Machines
0/0 typically use
1/0 1/0 less states than
S0 S1 S2
Moore Machines
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 14
State Assignment and State Table
Three States # Minimum number of state bits (Flip-Flops) = 2
Assign: S0 = 00, S1 = 01, and S2 = 10 (State 11 is Unused)
0/0
0/0 1/1
0/0
S0 1/0 S1 1/0 S2
Present Next State Output " Present Next State Output "
State ! = 0 ! = 1 ! = 0 ! = 1 State ! = 0 ! = 1 ! = 0 ! = 1
S0 S0 S1 0 0 00 00 01 0 0
S1 S0 S2 0 0 01 00 10 0 0
S2 S0 S2 0 1 10 00 10 0 1
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 15
Derive Next State and Output Equations
0. 0/ 3
# # #
Present Next State Output " -. -/ 0 1 -. -/ 0 1 -. -/ 0 1
State ! = 0 ! = 1 ! = 0 ! = 1 00 0 0 00 0 1 00 0 0
00 00 01 0 0 01 0 1 01 0 0 01 0 0
01 00 10 0 0 11 X X 11 X X 11 X X
10 00 10 0 1
10 0 1 10 0 0 10 0 1
11 XX XX X X
-. # + -/ # -.2 -/2 # -. #
0. = -. # + -/ # 0/ = -.2 -/2 # 3 = -. #
Output Logic
Next State
Next State
Logic
Logic
-. -/
0. 0/
-.2 -/2
Reset
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 17
Mealy versus Moore Sequence Detector
Mealy Sequence Detector Moore
Sequence
0/0 0
0/0 1/1 Detector
0/0 0
1/0 1/0
S0 1 S1
S0 S1 S2
0 0
0/0
0/0 1/1
Reset input
0/0
forces initial
state to be S0 reset S0 1/0 S1 1/0 S2
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 20
Verifying the Mealy Sequence Detector
0/0
0/0 1/1
0/0
z 0 0 0 0 0 0 0 0 1 1
Sequential Circuit Design COE 202 – Digital Logic Design © Muhamed Mudawar – slide 21