Design of a Mealy “ 1101” or “ 1011” Sequence Detector...
Transcript of Design of a Mealy “ 1101” or “ 1011” Sequence Detector...
Design of a Mealy “1101” or “1011”
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 81
Design of a Mealy “1101” or “1011” Sequence Detector, with Overlap.
Step 2: State Graph
Start the graph; do the 1011 sequence
Moore or Mealy? (We choose Mealy)
R0z=0 Mealy
Wait fora “1”
R1z=0
Wait for “0”
OutputGot “1”
Output 1 if x=1 Got “10”
x=1 x=0 x=1
Mealy output z=1 as soon as the last x=1 appears
R5z=x
1 0 1 1 0 1 0 1 10 1 10 1x
x
CLKFor Mealy Output
Output rises as the
- 0 0 1 0 1 0 0 00 1 10 1 0z
Step 1: Block diagram and waveforms
R2z=0
x=1
Got “101”Wait for “1”
1011XCLK
RST
Zor
1101
z
final “1” appears.
Next state depends on x
x=1 on state graph
the next clock edge.means x=1 just before
(the blue ovals )
Slide 19
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 82
1101 or 1011 Machine
1101 or 1011 Machine
This machine recognizes two sequences. The sequences may overlap, so the end of one sequence may be the start of another.
Step 1:
Sketch a typical input with various nonoverlapping and overlapping sequences. Sketch the Mealy output that rises as soon as the final 1 appears. It does not wait for the next clock edge. directly to one output with no fooling around.
The bit values like 0 0 1 ... given x and z, are the values near the end of the cycle.
Step2:
Draw the state graph. We will draw the graph for one sequence. Then do the other sequence. Then combine them.
The Mealy outputs are written in the bottom of the state circles.
Remember that the next state is determined by x just before the active clock edgeThe state changes after a clock edge. Only the Mealy output can change between clock edges.
The state names here were chosen to be short, but to also tell the sequence so far. Thus R2 means “Received 2” which in binary is “Received 10”The state names G2 etc. will be used for the other sequence.
Comment on Slide 19
Design of a Mealy “1101” or “1011”
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 83
A Mealy “1101” or “1011” Sequence Detector with Overlap
Do the 1011 sequence alone; temporarily forget 1101
Step 2: State Graph (Continued)
R0z=0
Wait for “1”
Output 1Got “10”
R5z=x
R2z=0
x=1Got “101”
R1z=0
Got “1”x=1
x=1
if x=1
R0z=0
R5z=x
R2z=0
x=1R1z=0
x=1 x=0
x=0
Got “1011”Last 1 may be start of a new sequence.
Got “1010” x=1
x=0
x=0Got “100”Nothing
Add anotherarrow
Add two morearrows
R0z=0
R5z=x
R2z=0
x=1R1z=0
x=1 x=0
x=0x=0
x=1x=0x=1
NothingGot “00”
Got “11”
Add last twoarrows.
That’s all, since
have 2 exitarrows.
now all states
Comment on Slide 1Slide 20
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 84
1101 or 1011 machine
Comment on Slide 20
1101 or 1011 machineThe 1011 sequence
There are two sequences to look for. We started by looking only for the 1011 sequence.
On the next page we will add more states to find the 1101 sequence.
a. Start by drawing the states for a 101 input.
b. Then continue trying to see what would happen for the last 1 of 1011.The output notation z = x applies to the x after one reaches the state. Thus in state R5, the output changes according to the values of x on the arrows leaving the state. Only the blue x=1 arrow is associated an output from R5.
c. Since x can have two values, there must be two arrows leaving each state.With two inputs there must be four arrows leaving each state.
R5z=x
R2z=0
x=1R1z=0
x=0
x=0x=1x=0
x=1
Got “1011”, send out 1 from state R5
Design of a Mealy “1101” or “1011”
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 85
A Mealy “1101” or “1011” Sequence Detector with Overlap
Do the 1101 sequence aloneStep 2: State Graph (Continued)
G1z=0
Got “1”
G3z=0Got “11”
Output 1G6z=x
Got “110”
G0z=0
Wait for “1”
x=1
x=1
x=0
G1z=0
G3z=0
G6z=x
G0z=0
x=0
x=0x=1
x=1
x=0
x=0
x=1
x=1
G1z=0
G3z=0
G6z=x
G0z=0
x=1
x=1
x=0
x=0
x=1
if x=1
Basic
Go
t “1
101”
Go
t “1
100”
No
thin
g
Go
t “0
0”N
oth
ing
Go
t “1
0”N
oth
ing
Go
t “1
11”
Add two Add other threetransitions transitions
Slide 21
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 86
1101 or 1011 machine
Comment on Slide 21
The 1101 sequence There are two sequences to look for. We started by looking only for the 1011 sequence.
On the next page we will add more states to find the 1101 sequence.
a. Start by drawing the states for a 110 input, which is the desired input.
b. Add the edge for the final 1 of 1101. The final 1 gives the output, but it also takes us to a next state with no ourput.rSince x can have two values
c. There must be two arrows leaving each state. Fill in all these arrows.
Design of a Mealy “1101” or “1011”
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 87
The Product State Graph for the Mealy “1101” or “1011” Sequence Detector
The two state graphs define the machine
Step 2: State Graph (Combining the two graphs))
G1z=0
G3z=0
G6z=x
G0z=0
10
0
1
1
00
1
R0z=0
R5z=x
R2z=0
R1z=0 0
0101
11
0
x
z
You can make a a working machine as shown.It will be much larger than needed.
The two graphs can be combined into a product graph (next slide)
• This is a large state graph.
• If not reduced it will lead to alarge machine.
• The product graph can oftenbe reduced. To less than the
• The reduced product graph can often give a smaller circuit.
two individual graphs.
START OF A “PRODUCT” GRAPH
Make two separate machines,and OR the outputs.
1011 machine
1101
mac
hin
e
Slide 22
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 88
1101 or 1011 machine
Comment on Slide 22
The Machine Made From Two Submachines.
1DC1R
1DC1R
Z
F
FG
G
G
X F
G
G
F
1DC1R
1DC1R
PQ
P
Q
X
X
One way to build the machine.It can be made smaller!
1011 machine
1101 machine
Design of a Mealy “1101” or “1011”
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 89
A Mealy “1101” or “1011” Sequence Detector with Overlap
The product state graph
R0z=0
Wait for “1”
G1z=0
Got “1”
Output 1Got “10”
R5z=x
R2z=0
x=1Got “101”
G3z=0
Got “11”
Output 1 if x=1
G6z=x
Got “110”
1011 is wanted
R1z=0
Got “1”x=1 x=0
x=0x=1
x=1x=0x=0
if x=1
G0z=0
Wait for “1”
x=0
x=0x=1
x=1
x=0
x=0
x=1
x=1
G0R0z=0
G1R0z=0
G3R0z=0
G6R0z=x
G0R1z=0
G1R1z=0
G3R1z=0
G6R1z=x
G0R2z=0
G1R2z=0
G3R2z=0
G6R2z=x
G0R5z=x
G1R5z=x
G3R5z=x
G6R5z=x
1 0
1
0
1
1
0
1101 is wanted
Only a few transitions are shown
0
0
Slide 23
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 90
1101 or 1011 machine
Comment on Slide 23
One Way to Combine the GraphsThe combined graph will be done on the slides using a product graph. The more intuitive way is shown below. It is explained in more detail later.
Combining the 1011 and the 1101 sequences on an X-Y type layout.When checking two sequences it is helpful to draw one sequence vertically and the other horizontally.Then the horizontal distance shows how far one is toward one sequence (1011), and the vertical (downward) distance how far one is toward the other (1101).
.
NamesThe original names like G5 means we got 101 (binary 5).
Here we give the state two names, thus G3R2 means we got 3 (binary 11) along the G (green) sequence, and 2 (binary 10) along the R (red) sequence, both simultaneously.
Wait fora “1”
Got “1”
Ou
tpu
t 1
if x
=1
x=1
x=0
Got “11” x=0
x=1
Output 1 if x=1
Got “110”
Recd “1” Recd “10” Recd “101”
Wait fora “1”
x=1
x=1
x=1
G0R0z=0
G1R1z=0
G0R2z=0
G1R5z=x
G3R2z=0
G6R2z=x
Recd “0”
Got “0”
Design of a Mealy “1101” or “1011”
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 91
First part of the product state graph
State Next State Output
x=0 x=1 z
G0 G0 G1 0
G0 G0 G1 0
G0 G0 G1 0
G0 G0 G1 0
G1 G0 G3 0
G1 G0 G3 0
G1 G0 G3 0
G1 G0 G3 0
G3 G6 G3 0
G3 G6 G3 0
G3 G6 G3 0
G3 G6 G3 0
G6 G0 G1 x
G6 G0 G1 x
G6 G0 G1 x
G6 G0 G1 x
G1z=0
G3z=0
G6z=x
G0z=0
x=0
x=0x=1
x=1
x=0
x=0
x=1
x=1
Make the state tablefor the 1101 machine.
Expand each state into 4 states 4 is the number of statesin the 1011 machine.
Expanded 1101 table
Slide 24
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 92
1101 or 1011 machine
Comment on Slide 24
The Product State TableThis is the first step in building the state table for the product machine combining both the 1101 and the 1011 machines.
There are 4 states in each machine. There will be 4x4 =16 states in the product machine. However a lot of them will not be used.
Design of a Mealy “1101” or “1011”
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 93
Second Part of the Product State Graph,
State Next State Output
x=0 x=1 z
R0 R0 R1 0
R1 R2 R1 0
R2 R0 R5 0
R5 R2 R1 x
R0 R0 R1 0
R1 R2 R1 0
R2 R0 R5 0
R5 R2 R1 x
R0 R0 R1 0
R1 R2 R1 0
R2 R0 R5 0
R5 R2 R1 x
R0 R0 R1 0
R1 R2 R1 0
R2 R0 R5 0
R5 R2 R1 x
R5z=x
R1z=0
R0z=0
0
1
0
11
10
0
R2z=0z=0z=0
R5z=x
R1z=0
R0z=0
0
1
0
11
10
0
R2z=0z=0z=0
R5z=x
R1z=0
R0z=0
0
1
0
11
10
0
R2z=0z=0
R5z=x
R1z=0
R0z=0
0
1
0
11
10
0
R2z=0z=0z=0
Make the state tablefor the 1011 machine.
4 is the number of statesin the 1101 machine.
Repeat the table 4 times
Expanded 1011 table
Slide 25
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 94
1101 or 1011 machine
Comment on Slide 25
The Product State TableThis is the second step in building the state table for the combined 1101 x 1011 product machine.
For the first (1101) table, we expanded each line 4 times.
For the second (1101) table we made four copies of the table, one below the other.
For the product table, shown on the next page, we placed the two expanded graphs side-by-side, and:
• Merged (concatenated) the first column in each table together, to make the first column of the product table.
• Merged the 2nd columns (the next-state for x=0 columns) together to make the new 2nd column.
• Merged the 3rd columns (the next-state for x=1 columns) together to make the new 3nd column.
• Merged, in this case ORed, the two output columns together to make the new output column.
Design of a Mealy “1101” or “1011”
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 95
Combining the Two Parts Into A Complete Product Graph
State Used
G0R0 √
G0R1
G0R2 √
G0R5
G1R0
G1R1 √
G1R2
G1R5 √
G3R0
G3R1 √
G3R2
G3R5 √
G6R0 √
G6R1
G6R2 √
G6R5
G1z=0
G3z=0
G6z=x
G0z=0
x=0
x=0x=1
x=1
x=0
x=0
x=1
x=1
R5z=x
R1z=0
R0z=0
0
1
0
11
10
0
R2z=0z=0z=0
R5z=x
R1z=0
R0z=0
0
1
0
11
10
0
R2z=0z=0z=0
R5z=x
R1z=0
R0z=0
0
1
0
11
10
0
R2z=0z=0z=0
R5z=x
R1z=0
R0z=0
0
1
0
11
10
0
R2z=0z=0z=0
State Next State Output
x=0 x=1 z
G0R0 G0R0 G1R1 0+0
G0R1 G0R2 G1R1 0+0
G0R2 G0R0 G1R5 0+0
G0R5 G0R2 G1R1 0+x
G1R0 G0R0 G3R1 0+0
G1R1 G0R2 G3R1 0+0
G1R2 G0R0 G3R5 0+0
G1R5 G0R2 G3R1 0+x
G3R0 G6R0 G3R1 0+0
G3R1 G6R2 G3R1 0+0
G3R2 G6R0 G3R5 0+0
G3R5 G6R2 G3R1 0+x
G6R0 G0R0 G1R1 x+0
G6R1 G0R2 G1R1 x+0
G6R2 G0R0 G1R5 x+0
G6R5 G0R2 G1R1 x+x
Cross outstates that can’t
be reached.
Reachable onlyfrom unreachablestates.
G0R2 G1R1
G0R2 G1R1
G0R0 G3R1
G0R0 G3R5
G6R0 G3R1
G6R0 G3R5
G0R2 G1R1
G0R2 G1R1
Slide 26
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 96
1101 or 1011 machine
Comment on Slide 26
How the product state graph is made from merging the expanded state graphs.
State Next State Output
x=0 x=1 z
R0 R0 R1 0
R1 R2 R1 0
R2 R0 R5 0
R5 R2 R1 x
R0 R0 R1 0
R1 R2 R1 0
R2 R0 R5 0
R5 R2 R1 x
R0 R0 R1 0
R1 R2 R1 0
R2 R0 R5 0
R5 R2 R1 x
R0 R0 R1 0
R1 R2 R1 0
R2 R0 R5 0
R5 R2 R1 x
State Next State Output
x=0 x=1 z
G0 G0 G1 0
G0 G0 G1 0
G0 G0 G1 0
G0 G0 G1 0
G1 G0 G3 0
G1 G0 G3 0
G1 G0 G3 0
G1 G0 G3 0
G3 G6 G3 0
G3 G6 G3 0
G3 G6 G3 0
G3 G6 G3 0
G6 G0 G1 x
G6 G0 G1 x
G6 G0 G1 x
G6 G0 G1 x
State Next State Output
x=0 x=1 z
G0R0 G0R0 G1R1 0+0
G0R1 G0R2 G1R1 0+0
G0R2 G0R0 G1R5 0+0
G0R5 G0R2 G1R1 0+x
G1R0 G0R0 G3R1 0+0
G1R1 G0R2 G3R1 0+0
G1R2 G0R0 G3R5 0+0
G1R5 G0R2 G3R1 0+x
G3R0 G6R0 G3R1 0+0
G3R1 G6R2 G3R1 0+0
G3R2 G6R0 G3R5 0+0
G3R5 G6R2 G3R1 0+x
G6R0 G0R0 G1R1 x+0
G6R1 G0R2 G1R1 x+0
G6R2 G0R0 G1R5 x+0
G6R5 G0R2 G1R1 x+x
Expanded 1101 table Expanded 1011 table Product state table
The Product “1101” X “1011” State Graph
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 97
The Product “1101” X “1011” State Graph
State Next State
x=0 x=1 z
G0R0 G0R0 G1R1 0
G0R2 G0R0 G1R5 0
G1R1 G0R2 G3R1 0
G1R5 G0R2 G3R1 x
G3R1 G6R2 G3R1 0
G3R5 G6R2 G3R1 x
G6R0 G0R0 G1R1 x
G6R2 G0R0 G1R5 x
R0z=0
G1z=0
R5z=x
R2z=0
x=1
G3z=0
G6z=x
R1z=0
x=1 x=0
x=0
x=1x=1x=0
x=0
G0z=0
G0R0z=0
G1R0z=0
G3R0z=0
G0R1z=0
G1R1z=0
G3R1z=0
G6R1z=x
G0R2z=0
G1R2z=0
G3R2z=0
G6R2z=x
G0R5z=x
G1R5z=x
G3R5z=x
G6R5z=x
1 0
1
0
1
1
0
0
01
1
0
0
0
0
G6R0z=x
0
0
1
1
1
1
Use the state table to construct the state graph
The unreachable states are shown lightly.The states reachable only from unreachable states are obvious.
Use this tableto construct the graph
The product statetable without the unreachable states.
Slide 27
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 98
1101 or 1011 machine
The Product State Graph and State TableThis machine is made of two independent machines running at the same time. These can be treated as a “product” of the two machines.1
One can also design the machine from first principles which is illustrated next. Use the method you find easier.
The product method has these advantages:
1. It gives the state table automatically, in fact one does not even have to do the state graph.
2. It is more mechanical, so it is easier to be sure you have all the connections between states. In the alternate method it is easy to leave some out.
The other method requires more thinking, but:
1. It can be used on any machine. It does not have to be two independent machines.
2. For machines in which most of the product states are unreachable, it may be easier.
21.• PROBLEMDesign the state table for a machine that detects the serial input sequences 101 or 1001
• With overlap
• The output appears immediately after the final 1 in either sequence appears.
22.• PROBLEM
Consider an overlapping Mealy machine to detect 111 followed by 010. There can be any sequence between the two. Thus 111010 would give one output as would 1110000110010 and 01111110010010. After giving an output, it would resume looking for 111 . . . 010.(a) Can one do this as a product machine? (See next page or so.)(b) Can there be any overlap? (c) Design the state graph.
1. In math, this is a Cartesian product.
Comment on Slide 27
The Product “1101” X “1011” State Graph
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 99
A Mealy “1101” or “1011” Sequence Detector
Wait fora “1”
Got “1”
x=1
x=0
Got “11” x=0
x=1
Output 1 if x=1
Got “110”
Recd “1” Recd“10” Recd “101”Wait for
a “1”
x=1
x=1
x=0
x=1
Final State Table
x=0
x=0x=0
Try following
like 10101101
G0R0z=0
G1R1z=0
G3R1z=0
G0R2z=0
G6R2z=x
G1R5z=x
a typical sequence
Output 1 if x=1
Slide 28
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 100
1101 or 1011 machine
23.• EXAMPLE (PARTIAL)Draw the state graph for an overlapping Moore machine to detect 1001 or 0101.
Help on “Problem” on page 98. Here one machine finishes before the other starts. The two sequences are not being considered simultaneously. Combining them into one product graph would not reduce the number of states. The product grid would reduce to the 7 states of the two original FSMs.
S0z=0
Wait fora “0”
G0R1z=0
Got “0”
x=1
x=0
G0R0z=0
G1R1z=0Got “01”
x=0x=1
Got “010”
Recd “1” Recd “10” Recd “100”Wait for
a “1”
x=1 x=1
Recd “1001”
Got “0101”
R2z=0
G1R9z=1
G5R1z=1
G2R2z=0
G0R4z=0
x=0
x=0 x=0
x=1
x=1
x=0x=0
x=1
x=1
x=0
x=0
x=1x=1
G2z=0
G6z=x
G0z=0
1 0
0
11
10
0
S0z=0
0
Note the starting (reset) statewhich is never used again.
G1z=0
R1z=0
S0z=0
G0R2z=0
R4z=0
R9z=1
1 0 0 11 0
1
No state table here.G1 with x=0 => G2 R9 with x=0 => R2
Hence G1R9 with x=0 => G2R2
Comment on Slide 28
Mealy 1101 or 1011 “Thinking” Detector
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 101
Mealy 1101 or 1011 “Thinking” Detector
1 0 1 1 0 1 0 1 10 1 10 1x
x
CLK
For Mealy OutputOutput rises as soon - 0 0 1 0 1 0 0 00 1 10 1 0z
Step 1: Block diagram and waveforms 1101XCLK
RST
Zor
1101
zas the final “1”
final “1” for eitherappears. This is the
sequence.
For next state determinationx=1 in a cycle means
before the next clock edge. x must be 1 just
Get Graph From First PrinciplesIgnore the Product Table
One must think;how is each state reached in the joint detector.
Start as before
Works on all machines.
Is simpler in some cases.
Slide 29
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 102
Mealy 1101 or 1011 “Thinking” Detector
Mealy 1101 or 1011 “Thinking” DetectorIt is you that does the thinking, not the detector.
Here one walks through the graph.At each state, one determines where one is in each sequence, and where the next input should take one.
It requires thinking about both sequences at once. This is much harder that doing it for one sequence at a time.
This will work for machines that are not made up of two independent machines.
For example: find sequence 1, and after you found it, look for sequence two.
Unlike in the product machine, here one finds the state graph before the state table.
Comment on Slide 29
Mealy 1101 or 1011 “Thinking” Detector
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 103
Design of a Mealy “1101” or “1011” Sequence Detector, with Overlap.
Step 2: State Graph
Start graph; do 1011 sequence
Moore or Mealy? (Given it is Mealy)
S0z=0 Mealy
Wait fora “1”
G1z=0
Wait for “0”
OutputGot “1”
Output 1 if x=1 Got “10”
x=1 x=0 x=1
The output is z=1 as soon as the 2nd x=1 appears
S5z=x
1 0 1 1 0 1 0 1 10 1 10 1x
CLK For Mealy OutputOutput rises as soon
- 0 0 1 0 1 0 0 00 1 10 1 0z
Step 1: Block diagram and waveforms
G2z=0
x=1
Got “101”Wait for “1”
1101XCLK
RST
Zor
1101
as the final “1”
final “1” for eitherappears. This is the
sequence.
Slide 30
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 104
Mealy 1101 or 1011 “Thinking” Detector
Deriving the State GraphStep 2: State Graph
As in the product machine, one derives the state machine for one sequence first.
Probably you should choose the longer one.
Go through the steps x goes 1,0,1,1 which is the desired sequence. Ignore the other inputs temporarily.
Comment on Slide 30
Mealy 1101 or 1011 “Thinking” Detector
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 105
A Mealy “1101” or “1011” Sequence Detector with Overlap
Add on the 1101 sequence
Step 2: State Graph Continued
S0z=0
Wait fora “1”
G1z=0
Got “1”Output 1 if x=1
Got “10”
x=1 x=0 x=1G5z=x
G2z=0
x=1
Got “101”
G3z=0
Got “11”x=0
x=1
Output 1 if x=1
G6z=x
Got “110”
1011 is wanted
1101 is wanted Part way toward both 1101 and 1011
Slide 31
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 106
Mealy 1101 or 1011 “Thinking” Detector
Deriving the State GraphNow try to merge in the second sequence.
Comment on Slide 31
Mealy 1101 or 1011 “Thinking” Detector
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 107
Placing Graph on an X-Y Grid MAY Help
Wait fora “1”
Got “1”
Ou
tpu
t 1
if x
=1
x=1
x=0
Got “11” x=0
x=1
Output 1 if x=1
Got “110”
Got “1” Got “10” Got “101”Wait for
a “1”
x=1
x=1
x=1
S0z=0
G1z=0
G5z=x
G2z=0
G3z=0
G6z=x
Place states ona grid.
X axis tells howfar we are toward1011
Y axis tells how farwe are toward1101
We may be partway toward both at once
Slide 32
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 108
Mealy 1101 or 1011 “Thinking” Detector
Placing the graph on a grid.If you have only two sequences, the grid (which looks like the product graph) is a help in keeping track of where you are.
If you have three sequences, the graph gets messy. A triple product state table will be much easier to follow.
Comment on Slide 32
Mealy 1101 or 1011 “Thinking” Detector
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 109
A Mealy “1101” or “1011” Sequence Detector
1011 is wanted
1101 is wanted
Wait fora “1”
Got “1”
Ou
tpu
t 1
if x
=1
x=1
x=0
Got “11” x=0
x=1
Output 1 if x=1 Got “110”
Got “1” Got “10” Got “101”Wait for
a “1”
x=1
x=1
x=1
S0z=0
G1z=0
G5z=x
G2z=0
G3z=0
G6z=x
x=0
Have “111”x=1
1011 is wanted
1101 is wantedHave “1101”
1101 has already been counted
Look at sequenceso far including
See what matches
the present input.
x=0
Have “1100”Have “1100”1011
1101
with the desiredsequence.
From this findthe row andcolumn for thenext state.
have
have
Thus if the inputhas been 110, thismatches 10 of 1011and 110 of 1101.This is the G6location
? ?
?
of 1011
Got nothing
of 1101
of 1101
Got nothing
have
have
have
nothing
nothing
Slide 33
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 110
Mealy 1101 or 1011 “Thinking” Detector
Mealy Sequence Detector for 1101 and 1011 with Overlap
Checking the Graph by Tracing a Typical PathTracing a path through the machine for 0101011.
S0z=0
Wait fora “1”
G1z=0Got “1”
x=1
x=0
G5z=x
G2z=0
G3z=0Got “11” x=0
x=1
Output 1 if x=1
G6x=zGot “110”
Got “1” Got “10” Got “101”Wait for
a “1”
x=1
x=0
x=1
x=1
x=0
x=1
x=0
0101011
x=0
Ou
tpu
t 1
if x
=1
Path for
10 0
10
1
1
Comment on Slide 33
Mealy 1101 or 1011 “Thinking” Detector
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 111
A Mealy “1101” or “1011” Sequence Detector
Wait fora “1”
Got “1”
Ou
tpu
t 1
if x
=1
x=1
x=0
Got “11” x=0
x=1
Output 1 if x=1
Got “110”
Got “1” Got “10” Got “101”Wait for
a “1”
x=1
x=1
S0z=0
G1z=0
G5z=x
G2z=0
G3z=0
G6z=x
x=0
x=1
Final Solution
x=0
x=1
x=0
x=0There must be two
Check the result:
arrows leavingeach state.
One for x=0, one for x=1
They can be the same arrow.
Try a typical
10101101
sequence.
See commentsbelow for thetrial sequence
Slide 34
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 112
Mealy 1101 or 1011 “Thinking” Detector
Shift Register Mealy Sequence Detector for 1101 and 1011 with Overlap
A Simple Solution
As an alternative to the previous design, a shift register can be used as an FSM to detect sequences. It works well where you need to identify several short sequences. It will not work for all FSMs.
24.• PROBLEM
State what sequence(s) this circuit will find, and explain how it works.
1DC1R
1DC1R
1DC1R
1DC1R
X
Shift-Register
A B C D
X = 1 0 0 1 0 1 1 1 0 0 A = 0 1 0 0 1 0 1 1 1 0 0 B = 0 0 1 0 0 1 0 1 1 1 0 0 C = 0 0 0 1 0 0 1 0 1 1 1 0 0 D = 0 0 0 0 1 0 0 1 0 1 1 1 0 0
Assume all flip-flops are resetat the start.
1DC1R
1DC1R
1DC1R
1DC1R
ZX
Shift-Register FSM
Comment on Slide 34
Design of an FSM from Word Description
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 113
Design of an FSM from Word Description
Sb
A One Pulse-Per-Push Circuit (OPP)
- may last many clock cycles.
A pulse which:
Specification
Step 1
Input X
- always overlaps at least one clock edge
OutputMealy output A
An output which:
- finishes at the next clock edge.
An output which:Moore output P
- starts when the input starts
- starts at the next clock edge- finishes one clock cycle later.
OPPX A(Mealy)
CLK
RST
P(Moore)
A(Mealy)
Block diagram, waveforms.
Step 2State graph
x=1Sb
A=0x=0
x=1x=0
Wait for XWait for X
SbSa Sb SaState
- Add state to waveforms- State changes only at clock edge- Mealy output may change when x changes
Machine With Mealy Output
B(Moore)
X
CLK
+V
pushbutton
SaA=x
if x; A=1if x; A=0
Slide 35
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 114
Mealy 1101 or 1011 “Thinking” Detector
Design of OPP1 Machine
At the Start of the Design, Choose Whether You Want Mealy or Moore Outputs Check Slide 38 for reasons, then choose.
Duration of output
The Moore output always lasts a full clock cycle.
The Mealy output can be much less than a clock cycle. Its length depends on how far along in the cycle the input X changed. If the input comes late, the Mealy output can be very short, maybe too short.2
1. In Ontario Canada, OPP stands for Ontario Provincial Police. There is no connection between them and this circuit.
2. In real circuits inputs are sent through a single flip-flop before being allowed to enter the OPP circuit. This is discussed in the next course, ELEC 3500, under the topic “Asynchronous Inputs to Synchronous Circuits.”
Comment on Slide 35
Design of the Mealy FSM
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 115
Design of the Mealy FSMA Mealy One Pulse-Per-Push Circuit
Step 4State Assignment
Step 5
State Table, State Next State Q+ D input output A
Q x=0 x=1 x=0 x=1 x=0 x=1
Sa=0 Sa=0 Sb=1 0 1 0 1
Sb=1 Sa=0 Sb=1 0 1 0 0
Q1
x
00 1
1Map
D = x
1DC1R
x Q AD
of D
A = Qx
Symbolic State Table State Next State Q+ output A
Q x=0 x=1 x=0 x=1
Sa Sa Sb 0 1
Sb Sa Sb 0 0
Step 3; State Table
x=1SbSa
if x; A=0if x; A=1 A=0
x=0
x=1x=0
Wait for X Wait for X
Q1
x
00 1
1Map of A1
Let Sa=0, Sb=1
Put Assignment in State TableMake K Maps
Derive equationsStep 6
Step 7
Draw CircuitD = x Qx
1DC1R
x QD AD = x A = Qx
Slide 36
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 116
Design of Mealy OPP Machine
Design of Mealy OPP MachineSymbolic State Table
This has only letters (symbols) for the states.
State Table (Complete)
This is made in Step 5 after the assignment of a bit pattern to each symbol. Here the bit pattern is just a single bit, since there are only two states.
Comment on Slide 36
Design of the Mealy FSM
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 117
Design Moore FSM from Word Description
Sp
P=1
Sp
A Moore One Pulse-Per-Push Circuit
Step 1X
B(Moore)
Block diagram.
Step 2State graph
Sw
P=0
x=0
x=0Wait for X
SpSw Sn SwState- Add state to waveforms- State changes only after clock edge
Sn
P=0
wait forgot X
x=1
Sw
x=1
x=0
x=1
Symbolic State Table State Nxt State Q+ output
Q x=0 x=1 P
Sw Sw Sp 0
Sp Sw Sn 1
Sn Sw Sn 0
Step 3; State Table
Step 4State Assignment
Step 5Let Sw=00, Sp=11, Sn=01
Put Assignment in State TableMake K Maps
State Table State Next State Q+U+ output
QU x=0 x=1 P
Sw=00 Sw=00 Sp=11 0
Sp=11 Sw=00 Sn=01 1
Sn=01 Sw=00 Sn=01 0
Must change to K-map order
Draw Moore waveforms.
OPPX
CLK
RST
P
send Pulse Not X
pulse pulse
Slide 37
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 118
Moore OPP
Moore OPP
Compare Moore With Mealy
• Moore has an extra state
• The extra state usually means slightly more hardware. Going from two states to three requires another flip-flop.
• Moore output is delayed till the next clock period after the Mealy output.
• Moore outputs are close to a full clock cycle wide.1
1. If there is a lot of logic in the output circuitry, this may be reduced, but it will be wider than a similar Mealy output.
Comment on Slide 37
Design of the Mealy FSM
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 119
A Moore One Pulse-Per-Push Circuit
Step 5Put state table in K-map order
Make K Maps
Derive equations
Step 6
Step 7
Draw circuit
State Table State Nxt St Q+U+=DQDP output
Q,U x=0 x=1 P
Sw=00 Sw=00 Sp=01 0
Sp=01 Sw=00 Sn=11 0
Sn=11 Sw=00 Sn=11 1
d
00011110
0 1X
QU
dQ
U
100d
000
DQ = x·P
0
0
0 1
01
0
1
1
1
d d0
0
0
00011110
0 1X
QU
dQ
U
111d
000
DP = x
00011110
QU
dQ
U100
P = Q
d d
1DC1R
x U
P1DC1R
Q xP
DP
DQ
Slide 38
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 120
Moore OPP
Moore OPP
Comment on Slide 38
Design of the Mealy FSM
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 121
Coupled FSMsAn Alternate CircuitStart with previous Mealy
OPPX A
CLK
RST
OUTCLK P
S0P=0
S1P=1
A=1
A=0
A=1A=0
S1
P(Moore)
S1S0 S0 S0State S0
Why does the branch A=1 from state S1 lead to a d?
Mealy Moore
x=1
x=0
x=1x=0
x
ADrive a Moore machine from Mealy
to get a Moore type output
OPP
Mea
lyM
oo
re
Sp
A=0Sa
A=x
d
1DC1R
x Q ADD = x Qx
Previous Mealy OPP graph
Moore Output for Mealy OPP
- What circuit goes to state 0 for a 0 inputSuppose the d is made to go to S1. Then:
- and state 1 for a 1 input?
Slide 39
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 122
Coupled Finite State Machines
Coupled Finite State MachinesCoupled state machines is a very common way to design.
The output of one machines feeds another.
For these coupled machines the 2nd machine looks at its input (the 1st machine’s output) just before the clock edge and transfers that input value to the output just after the clock edge.
This second machine’s state graph, when the “d” path is made to return to S1, is the graph of a D flip-flop.
25.• PROBLEM
Draw the circuit for the coupled OPP machine on the above slide (or the top graph on the right) with an internal Mealy output A and a Moore output P.
Product Graph for the Coupled Machine.The product graph is shown. Here it does nothing to help ones understanding. It is not any simpler. In fact it is a waste of time.
26.• SOLUTION TO PROBLEM 22.• PAGE 98 as a Mealy machine.
S0P=0
S1P=1
A=1
A=0
A=1A=0
x=1SbSa
A=x A=0x=0
x=1x=0
Coupled machines
D flip-flop
P=0
x=1
SbS0SaS0A=0
x=0
x=1
x=0
P=1
SaS1
x=0
P=0
SbS1A=0P=1
x=1
x=1x=0
A=x
A=x
Product Graph of Coupled machines
S0 G1z=x
R1G3x=1 x=1
G7x=1
R0x=0 x=1
x=0
x=0
x=0x=1
x=1
x=0x=0z=0 z=0 z=0 z=0 z=0
Got 1 Got 11 Got 111 Recd 0seq II
Recd 01seq II
Comment on Slide 39
Design of the Mealy FSM
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 123
Checking the 1011 1101 State Graph tor Unneeded States
S0z=0
Wait fora “1”
G1z=0
Got “1”Output 1 if x=1
Got “10”
x=1
x=0
x=1
G5
z = x
G2z=0
x=1
Got “101”
G3z=0
Got “11”
x=0
x=1
Output 1 if x=1
G6z = x
Got “110”
x=1
x=0
x=0
x=1
x=0
x=0
S0G1G2G5S4G6
S0G2S0G2G6S0
G1G3G5G3G3G5
0 000
0 00 10 00 1
G1
G2
G5
G3
G6
G2
S0
G2
G6
S0
G3
G5
G3
G3
G5
G1S0 G2 G5 G3
S0 G1
S0 G1
S0 G1
S0 G1
S0 G1
G2G3
G2G3
G2G3
G2G3S0 G5
G2 G3
G6 G3G6 G3G6 G3
G2 G3
S0 G5
S0 G5
S0 G5
G2 G3
G2 G3S0 G5 S0 G5S0 G5 S0 G5
G6 G3
No Mergers Possible
State NextState OutputsChecking for possible state mergers.
Don’t read this until you read the section on state merging. Normally done for a FSM design.
Slide 40
Printed; 18/03/05 Department of Electronics, Carleton UniversityModified; March 18, 2005 © John Knight Sequential Circuits p. 124
Coupled Finite State Machines
Comment on Slide 40