Download presentation
Presentation is loading. Please wait.
1
Guest Lecture by David Johnston
CprE 281: Digital Logic Guest Lecture by David Johnston
2
Moore Machines CprE 281: Digital Logic Iowa State University, Ames, IA
Copyright © 2013
3
The machine’s current state decides the current output.
Moore Machine Summary The machine’s current state and current input are used to decide which next state to transition into. The machine’s current state decides the current output.
4
Let’s finish implementing our previous example.
5
C: z = 1 Reset B: z = 0 A: z = 0 w = 1 We need to find both the next state logic and the output logic implied by this machine.
6
Next state Present Output state A B C z w = w = 1 C: z = 1 Reset
B: z = 0 A: z = 0 w = 1 Next state Present Output state z w = w = 1 A B C
7
Next state Present Output state A A B B A C C A C 1 z w = w = 1
Reset B: z = 0 A: z = 0 w = 1 Next state Present Output state z w = w = 1 A A B B A C C A C 1
8
Let’s use two flip flops to hold the state machine’s state.
9
Let Q(t) = y2y1 and Q(t+1) = Y2Y1.
w Next State Logic Output Logic z Y y 2 2 Clock
10
So, we need to find logic expressions for
Y1(w, y1, y2), Y2(w, y1, y2), and z(y1, y2). Y y 1 1 w Next State Logic Output Logic z Y y 2 2 Clock
11
Next state Present Output state z w = w = 1 A A B B A C C A C 1 Suppose we encoded our states in the same order in which they were labeled: A ~ 00 B ~ 01 C ~ 10
12
The finite state machine will never reach a state encoded as 11.
Next state Present Output state z w = w = 1 A A B B A C C A C 1 Next state Present Output state w = w = 1 z A 00 The finite state machine will never reach a state encoded as 11. B 01 C 10 11
13
Next state Present Output state A A B B A C C A C 1 z w = w = 1
w = 1 A A B B A C C A C 1 Present Next state state w = 1 Output y Y 2 z A 00 01 B 10 C 11 dd d We arbitrarily chose these as our state encodings. We could have used others.
14
Present Next state state w = 1 Output y Y 2 z 00 01 10 11 dd d
q(t) = y2y1 and q(t+1) = Y2Y1 w y2 y1 Y2 Y1 1 Present Next state state w = 1 Output y Y 2 z 00 01 10 11 dd d y2 y1 z 1
15
Y 1 y y w y2 y1 Y2 Y1 1 d 2 1 w 00 01 11 10 d 1 1 d Y 2 y y 2 1 w 00 01 11 10 d 1 1 d 1 y2 y1 z 1 d z y 1 y 2 1 1 1 d
16
Don’t care conditions simplify the combinatorial logic.
2 1 Ignoring don't cares Using don't cares w 00 01 11 10 d Y = wy y Y = wy y 1 1 2 1 1 2 1 1 d Y 2 y y 2 1 w 00 01 11 10 d Y = wy y + wy y Y = wy + wy 2 1 2 1 2 2 1 2 1 1 d 1 = w ( y + y ) 1 2 z y 1 y 2 1 z = y y z = y 1 2 2 1 1 d Don’t care conditions simplify the combinatorial logic.
18
Lastly, we add a reset signal, which forces the machine back to its start state, which is state 00 in this case.
19
Summary: Designing a Moore Machine
Obtain the circuit specification. Derive a state diagram. Derive the state table. Decide on a state encoding. Encode the state table. Derive the output logic and next-state logic. Add a reset signal.
20
An Alternative State Encoding
21
Our previous design decisions led us to:
Y 1 y y z 2 1 Y 2 y y y 2 1 1 y w 00 01 11 10 w 2 1 00 01 11 10 d d 1 1 d 1 1 d 1 1 d 1 Can we do better?
22
A Better State Encoding
Next state Present Output state z w = w = 1 A A B B A C C A C 1 Suppose we encoded our states another way: A ~ 00 B ~ 01 C ~ 11
23
A Better State Encoding
Next state Present Output state z w = w = 1 A A B B A C C A C 1 Next state Present Output state w = w = 1 A ~ 00 B ~ 01 C ~ 11 z
24
A Better State Encoding
Next state Present Output state z w = w = 1 A A B B A C C A C 1 Present Next state state w = 1 Output y 2 Y z A 00 01 B 11 C 10 dd d
25
What Are Our Logic Expressions?
Present Next state state w = 1 Output y 2 Y z A 00 01 B 11 C 10 dd d
26
What Are Our Logic Expressions?
Present Next state state w = 1 Output y 2 Y z A 00 01 B 11 C 10 dd d Warning: This table does not enumerate y2y1, in the standard way, so be careful when filling out the K-Map. Y2 y y Y1 y y z 2 1 2 1 y 1 w y w 00 01 11 10 00 01 11 10 2 1 1 1 1
27
What Are Our Logic Expressions?
Present Next state state w = 1 Output y 2 Y z A 00 01 B 11 C 10 dd d Warning: The present state variables, y1y2, do not follow our standard enumeration, so be careful when filling out the K-Map. Y2 Y1 y y y y z y 2 1 2 1 1 w y 2 00 01 11 10 w 00 01 11 10 1 d d 1 1 1 1 d 1 1 1 1 d d 1 Y2(w, y2, y1) = wy1 Y1(w, y2, y1) = w z(y2, y1) = y2
28
Original State Encodings
New State Encodings: Y1 Y 1 y y y y 2 1 2 1 w 00 01 11 10 w 00 01 11 10 d d 1 1 d 1 1 1 1 d Y2 Y 2 y y y y 2 1 2 1 w w 00 01 11 10 00 01 11 10 d d 1 1 1 d 1 1 1 d z y z y 1 1 y y 2 1 2 1 1 1 d 1 d 1
29
Improved Result Y1(w, y2, y1) = w Y2(w, y2, y1) = wy1 z(y2, y1) = y2 Y
Q z Y2(w, y2, y1) = wy1 Q z(y2, y1) = y2 Y y 1 1 w D Q Clock Q Resetn
30
Some may be better than others.
Main Idea Different state assignments of the same Moore machine generally lead to different circuits. Some may be better than others.
31
Another Moore Machine: Register Swap Controller
33
Design a Moore machine control circuit for swapping the contents of registers R1 and R2 by using R3 as a temporary.
34
If an output is not given, then assume that it is 0.
D: R 3 out 1 = in Done , w C: 2 B: A: No Transfer Reset If an output is not given, then assume that it is 0.
35
How many logic expressions do we need to find?
How many flip-flops are we going to use?
36
, D: R 3 1 = Done w C: 2 B: A: No Transfer Reset W Z Next State Logic
out 1 = in Done , w C: 2 B: A: No Transfer Reset W Z Next State Logic Q(t+1) Flip-Flop Array Q(t) Output Logic Clock
37
, D: R 3 1 = Done w C: 2 B: A: No Transfer Reset R1out w
in Done , w C: 2 B: A: No Transfer Reset R1out w Next State Logic Y[1:2] Flip-Flop Array y[1:2] Output Logic R1in R2out R2in R3out Clock R3in Done
38
Present Next state Outputs state w = 0 w = 1 A B C D , D: R 3 1 = Done
in Done , w C: 2 B: A: No Transfer Reset Present Next state Outputs state Done w = 0 w = 1 R1out R1in R2out R2in R3out R3in A B C D
39
Present Next state Outputs state w = 0 w = 1 A A B B C C 1 1 C D D 1 1
3 out 1 = in Done , w C: 2 B: A: No Transfer Reset Present Next state Outputs state w = 0 w = 1 R1out R1in R2out R2in R3out R3in Done A A B B C C 1 1 C D D 1 1 D A A 1 1 1
40
Consider two encoding schemes.
As we saw before, we can expect that some state encodings will be better than others. Consider two encoding schemes.
41
Present Next state Outputs state w = 0 w = 1 A A B B C C 1 1 C D D 1 1
Naïve State Encoding Present Next state Outputs state Done w = 0 w = 1 R1out R1in R2out R2in R3out R3in A A B B C C 1 1 C D D 1 1 D A A 1 1 1 Present Next state state Outputs A 00 1 B 01 10 C 11 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done
42
Present Next state state Outputs A 00 1 B 01 10 C 11 D w = 0 w = 1
1 B 01 10 C 11 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done w y2 y1 Y2 Y1 1
43
Present Next state state Outputs A 00 1 B 01 10 C 11 D w = 0 w = 1
1 B 01 10 C 11 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done w y2 y1 Y2 Y1 1
44
Present Next state state Outputs A 00 1 B 01 10 C 11 D w = 0 w = 1
1 B 01 10 C 11 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done
45
Alternative State Encoding
Present Next state Outputs state Done w = 0 w = 1 R1out R1in R2out R2in R3out R3in A A B B C C 1 1 C D D 1 1 D A A 1 1 1 Present Next state state Outputs A 00 1 B 01 11 C 10 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done
46
Present Next state state Outputs A 00 1 B 01 11 C 10 D Y Y y y y y w
1 B 01 11 C 10 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done Y Y 1 y y 2 y y 2 1 2 1 w w 00 01 11 10 00 01 11 10 1 1
47
Present Next state state Outputs A 00 1 B 01 11 C 10 D Y Y y y y y w
1 B 01 11 C 10 D w = 0 w = 1 y2y1 Y2Y1 Y2Y1 R1out R1in R2out R2in R3out R3in Done Y Y 1 y y 2 y y 2 1 2 1 w w 00 01 11 10 00 01 11 10 1 1 1 1 1 1 1 1 1 Y = y Y = wy + y y 1 2 1 2 2 1
48
One-Hot State Encoding
49
So far, we have been encoding states in a way that minimizes flip-flops.
But we can sometimes decrease the complexity of our combinational logic if we encode states more sparsely.
50
Vehicle Speed Controller
Next state Present Output state z w = w = 1 A A B B A C C A C 1 Let’s use three flip-flops and using the following one- hot state encoding scheme: A ~ 001 B ~ 010 C ~ 100
51
Vehicle Speed Controller
Next state Present Output state z w = w = 1 A A B B A C C A C 1 Next State Present state Output w = w = 1 z y y y 3 2 1 Y Y Y Y Y Y 3 2 1 3 2 1 A 001 B 010 C 100 1
52
Vehicle Speed Controller
Next state Present Output state z w = w = 1 A A B B A C C A C 1 Next State Present state Output w = w = 1 z y y y 3 2 1 Y Y Y Y Y Y 3 2 1 3 2 1 A 001 001 010 B 010 001 100 C 100 001 100 1
53
Next State Present state Output w = w = 1 z y y y Y Y Y Y Y Y 001 001
1 Next State Present state Output w = w = 1 z y y y 3 2 1 Y Y Y Y Y Y 3 2 1 3 2 1 001 001 010 010 001 100 100 001 100 1
54
Next State Present state Output w = w = 1 z y y y Y Y Y Y Y Y 001 001
d 1 Next State Present state Output w = w = 1 z y y y 3 2 1 Y Y Y Y Y Y 3 2 1 3 2 1 001 001 010 010 001 100 100 001 100 1
55
Next State Present state Output w = w = 1 z y y y Y Y Y Y Y Y 001 001
1 Next State Present state Output w = w = 1 z y y y 3 2 1 Y Y Y Y Y Y 3 2 1 3 2 1 001 001 010 010 001 100 100 001 100 1
56
w = y3 Y3 = wy1 Y2 = wy1 Y1 = w Next State Present state Output w = w
1 Next State Present state Output w = w = 1 z y y y 3 2 1 Y Y Y Y Y Y 3 2 1 3 2 1 001 001 010 010 001 100 100 001 100 1 w = y3 Y3 = wy1 Y2 = wy1 Y1 = w
57
Register Swap Controller
Present Next state Outputs state w = 0 w = 1 R1out R1in R2out R2in R3out R3in Done A A B B C C 1 1 C D D 1 1 D A A 1 1 1
58
Register Swap Controller
Present Next state Outputs state w = 0 w = 1 R1out R1in R2out R2in R3out R3in Done A A B B C C 1 1 C D D 1 1 D A A 1 1 1 Let’s use four flip-flops and the following one-hot state encoding scheme: A ~ 0001 B ~ 0010 C ~ 0100 D ~ 1000
59
Register Swap Controller
Present Next state Outputs state Done w = 0 w = 1 R1out R1in R2out R2in R3out R3in A A B B C C 1 1 C D D 1 1 D A A 1 1 1 Present Next State Outputs State w = 0 w = 1 y4y3y2y1 Y4Y3Y2Y1 Y4Y3Y2Y1 R1out R1in R2out R2in R3out R3in Done A 001 B 010 1 1 C 100 1 1 D 1 000 1 1 1
60
Register Swap Controller
Present Next state Outputs state w = 0 w = 1 R1out R1in R2out R2in R3out R3in Done A A B B C C 1 1 C D D 1 1 D A A 1 1 1 Present Next State Outputs State w = 0 w = 1 y4y3y2y1 Y4Y3Y2Y1 Y4Y3Y2Y1 R1out R1in R2out R2in R3out R3in Done A 001 0001 0010 B 010 0100 0100 1 1 C 100 1000 1000 1 1 D 1 000 0001 0001 1 1 1
61
What next state logic do we need?
Y4(w, y4, y3, y2, y1) Y3(w, y4, y3, y2, y1) Y2(w, y4, y3, y2, y1) Y1(w, y4, y3, y2, y1) Present Next State Outputs State w = 0 w = 1 y4y3y2y1 Y4Y3Y2Y1 Y4Y3Y2Y1 R1out R1in R2out R2in R3out R3in Done A 001 0001 0010 B 010 0100 0100 1 1 C 100 1000 1000 1 1 D 1 000 0001 0001 1 1 1
62
What output logic do we need?
R1out(y4, y3, y2, y1) R1in(y4, y3, y2, y1) R2out(y4, y3, y2, y1) R2in(y4, y3, y2, y1) R3out(y4, y3, y2, y1) R3in(y4, y3, y2, y1) Done(y4, y3, y2, y1) Present Next State Outputs State w = 0 w = 1 y4y3y2y1 Y4Y3Y2Y1 Y4Y3Y2Y1 R1out R1in R2out R2in R3out R3in Done A 001 0001 0010 B 010 0100 0100 1 1 C 100 1000 1000 1 1 D 1 000 0001 0001 1 1 1
63
Questions?
64
THE END
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.