Mealy Machine

Mealy Machine
Example 1
Design an error detector for the following sequential circuit. The circuit has a single
input x and a single output z. Data arrive serially on x synchronized with the clock. The
output z (an error) should be “1” whenever two consecutive zeroes or three consecutive
ones appear on line x. Implement the circuit using D, JK, RS and T flip-flops.
Error
Error
Detecting
Circuit
X
CLK
Z
Reset
R t
Examples of input/output
x
z
clk
0
0
0
1
1
0
1
0
1
1
1
1
1
1
0
0
0
1
0
1
1
0
1
0
1
1
0
0
State Diagram:
1/0
q0
q2
1/0
q3
1/0
1/0
1/1
0/0
0/0
q1
0/1
Page 1 of 5
State assignment
Assign the following state arbitrary:
q0=00
q1=01
q2=10
q3=11
Mealy Machine
0
1
1
0
State Transition Table :
Present
state
y1 y0
00
01
10
11
Next state, output
x=0
x=1
y1 y0 / z y1 y0 / z
0 1,
0 1 0, 0
0 1,
1 1 0, 0
0 1,
0 1 1, 0
0 1,
0 1 1, 1
error = z = y1 y0 x + y1 y0 x
D, JK, T, RS Transition Table:
presentÆnext
state
D
0Æ0
0
0Æ1
1
1Æ0
0
1Æ1
1
J
store
reset
set
invert
reset
invert
store
set
0
0
1
1
0
1
0
1
K
0
1
x
x
0
1
0
1
1
1
0
0
T
x
0
x
1
1
1
0
0
R
store
reset
set
set
reset
reset
store
set
State transition table of the circuit to design
Present
Next state
state
x=0
x=1
y1 y0
y1 y0
y1 y0
00
01
10
01
01
10
10
01
11
11
01
11
1. D-FF implementation
x
y1 y0
00
01
11
10
0
1
0
0
0
0
1
1
1
1
x
y1 y0
00
01
11
10
0
1
1
1
1
1
0
0
1
1
y1+ = D1 = x
y 0+ = D 0 = x + y
Page 2 of 5
Mealy Machine
0
1
0
0
1
1
0
0
S
x
0
1
0
0
0
1
1
0
0
0
1
0
1
0
x
Circuit Diagram of implementation with a D-Flip Flop
D
SET
CLR
x
Q
Q
z
FF 1
D
SET
Q
Clk
CLR
Q
FF 0
OR: Directly from Specification:
Xt =Present Input, Xt-1 Previous input, Xt-2 two clock passed previous input
xt-1
xt
x
D
SET
Clk
CLR
FF 0
Page 3 of 5
Q
Q
D
xt-2
SET
CLR
Q
Q
FF 1
z
Mealy Machine
2. JK-implementation
x
y1 y0
00
01
11
10
0
1
0
0
x
x
1
1
x
x
x
y1 y0
00
01
11
10
Jy = x
1
x
x
1
1
x
x
0
0
Ky = x
1
x
y1 y0
00
01
11
10
0
1
0
1
1
x
x
1
0
x
x
1
x
y1 y0
00
01
11
10
J y = x + y1
0
1
x
0
0
x
x
1
0
x
K y = xy1
0
0
Circuit Implementation
J
x
K
SET
CLR
Q
Q
FF 1
J
K
Clk
Page 4 of 5
SET
CLR
z
Q
Q
FF 0
Mealy Machine
3. T-implementation
x
y1 y0
00
01
11
10
0
1
0
0
1
1
1
1
0
0
T1 = xy1 + xy0
x
y1 y0
00
01
11
10
0
1
0
0
1
1
0
1
1
0
T0 = xy0 + xy0 = x y0
Circuit Implementation
x
TT
T
FF1
TT
T
Clk
FF0
Page 5 of 5
Mealy Machine