WEBVTT
00:00:01.270 --> 00:00:03.190
PROFESSOR: This truth
table represents
00:00:03.190 --> 00:00:07.240
a five-state finite
state machine, or FSM,
00:00:07.240 --> 00:00:11.530
with a one-bit input, IN,
and a two-bit output, OUT.
00:00:11.530 --> 00:00:14.210
This FSM is a Mealy machine.
00:00:14.210 --> 00:00:16.210
That means that its
outputs are a function
00:00:16.210 --> 00:00:20.040
of both the current state
and the current input.
00:00:20.040 --> 00:00:23.040
When this FSM is initialized,
its starting state
00:00:23.040 --> 00:00:27.060
is state B. We are given
a partially filled state
00:00:27.060 --> 00:00:29.820
transition diagram shown here.
00:00:29.820 --> 00:00:32.880
Our job is to fill in the
missing state and transition
00:00:32.880 --> 00:00:33.930
labels.
00:00:33.930 --> 00:00:37.080
In other words, S1
through S4 should
00:00:37.080 --> 00:00:41.850
be replaced with the states A
through E. And T1 through T7
00:00:41.850 --> 00:00:45.780
should be replaced with a
IN/OUT transition corresponding
00:00:45.780 --> 00:00:46.680
to that arrow.
00:00:49.420 --> 00:00:53.320
In order to do this, we begin
by looking at the truth table,
00:00:53.320 --> 00:00:54.820
beginning with
the starting state
00:00:54.820 --> 00:00:59.560
B. The truth table shows
us that when IN equals 0,
00:00:59.560 --> 00:01:04.480
our next state is state C.
Since the 0 input transition out
00:01:04.480 --> 00:01:07.300
of state B is already
labeled for us,
00:01:07.300 --> 00:01:14.170
we know that state S2 equals
C. This also tells us that T2
00:01:14.170 --> 00:01:17.150
corresponds to IN equals 1.
00:01:17.150 --> 00:01:23.425
So S4 is equal to D.
And T2 is equal to 1/00.
00:01:26.110 --> 00:01:30.190
From state D, we have
the one input transition
00:01:30.190 --> 00:01:31.840
already labeled.
00:01:31.840 --> 00:01:36.400
So T3 corresponds
to IN equals 0.
00:01:36.400 --> 00:01:40.360
Looking at the truth
table, that means that S3
00:01:40.360 --> 00:01:47.330
equals E and T3 equals 0/01.
00:01:47.330 --> 00:01:51.260
The truth table then shows
us that from state E,
00:01:51.260 --> 00:01:54.730
a 1 input takes you
back to state B.
00:01:54.730 --> 00:02:04.130
So T4 equals 1/01, which in
turn means that T5 equals 0/10.
00:02:04.130 --> 00:02:07.520
And state S1 equals A.
00:02:07.520 --> 00:02:11.030
From state A, the
0 input transition
00:02:11.030 --> 00:02:13.250
is already filled in.
00:02:13.250 --> 00:02:17.750
So T1 equals 1/11.
00:02:17.750 --> 00:02:22.490
From state C, a 1
input goes to state B.
00:02:22.490 --> 00:02:31.055
So T6 equals 1/01, which in
turn means that T7 equals 0/10.
00:02:34.860 --> 00:02:38.600
Now that we have a complete
state diagram for our FSM,
00:02:38.600 --> 00:02:42.230
the next thing we want to figure
out is what sequence of outputs
00:02:42.230 --> 00:02:48.620
is produced if we begin in state
B and receive inputs 1, 0, 0.
00:02:48.620 --> 00:02:51.860
Since our state transition
diagram is now filled,
00:02:51.860 --> 00:02:56.450
we see that from state B, a
1 input takes us to state D
00:02:56.450 --> 00:03:00.600
and produces a 00 output.
00:03:00.600 --> 00:03:06.970
From state D, a 0 input moves
us to state E and outputs 01.
00:03:06.970 --> 00:03:11.505
Finally, from state E, a 0
input moves us to state A
00:03:11.505 --> 00:03:15.030
and produces a 10 output.
00:03:15.030 --> 00:03:15.900
OK.
00:03:15.900 --> 00:03:18.420
Now let's try to find
a sequence of inputs
00:03:18.420 --> 00:03:22.260
that is guaranteed to
leave the FSM in state E,
00:03:22.260 --> 00:03:25.440
regardless of the state it
is in before the sequence is
00:03:25.440 --> 00:03:27.000
processed.
00:03:27.000 --> 00:03:30.750
To answer this question, we take
a look at our filled-in state
00:03:30.750 --> 00:03:33.990
diagram and determine
what sequence of inputs
00:03:33.990 --> 00:03:37.530
takes us from each
state X to state E.
00:03:37.530 --> 00:03:41.230
We begin with state
A. From state A,
00:03:41.230 --> 00:03:45.300
the shortest sequence of inputs
required to get to state E
00:03:45.300 --> 00:03:47.760
is 1, 1, 0.
00:03:47.760 --> 00:03:52.960
This takes you from A
to B to D to E. Next,
00:03:52.960 --> 00:03:58.090
we examine state B. We see that
the sequence 1, 0 will take us
00:03:58.090 --> 00:04:01.690
from B to D to E.
Since we are looking
00:04:01.690 --> 00:04:04.930
for a single sequence that
will work from all states,
00:04:04.930 --> 00:04:08.830
we want to see if 1,
1, 0 would also work.
00:04:08.830 --> 00:04:12.190
Taking a closer look
at state D shows us
00:04:12.190 --> 00:04:14.890
that the sequence
1, 1, 0 will also
00:04:14.890 --> 00:04:19.390
get us from B to E because the
extra 1 just keeps you in state
00:04:19.390 --> 00:04:21.940
D for one extra iteration.
00:04:21.940 --> 00:04:26.840
And then the 0 takes you
to state E. Similarly,
00:04:26.840 --> 00:04:30.980
if you begin at state
D, the sequence 1, 1, 0
00:04:30.980 --> 00:04:33.890
leaves you at state
D for two iterations.
00:04:33.890 --> 00:04:38.520
And then on the third, the
0 takes you to state E.
00:04:38.520 --> 00:04:42.720
Beginning at state E
itself, the sequence 1, 1, 0
00:04:42.720 --> 00:04:47.160
takes you to state
B, then D, then E.
00:04:47.160 --> 00:04:49.200
So we have one
state left to check,
00:04:49.200 --> 00:04:52.500
and that is state
C. From state C,
00:04:52.500 --> 00:04:58.350
the sequence 1, 1, 0 takes us
to state B, then D, then E.
00:04:58.350 --> 00:05:01.990
So once again, the
sequence 1, 1, 0 works.
00:05:01.990 --> 00:05:04.080
This means that
regardless of what state
00:05:04.080 --> 00:05:10.570
you start in, the sequence 1, 1,
0 will have you end at state E.
00:05:10.570 --> 00:05:13.600
The last question we want to
answer about the finite state
00:05:13.600 --> 00:05:16.240
machine is whether
or not there exists
00:05:16.240 --> 00:05:21.610
an equivalent FSM that has only
four states instead of five.
00:05:21.610 --> 00:05:23.590
In other words, are
there two states
00:05:23.590 --> 00:05:27.940
that can be merged into one to
reduce the FSM to an equivalent
00:05:27.940 --> 00:05:31.300
FSM with one fewer state?
00:05:31.300 --> 00:05:34.300
Recall that in a
Mealy FSM, two states
00:05:34.300 --> 00:05:37.930
are equivalent if they
have the same input/output
00:05:37.930 --> 00:05:40.780
transitions as each other.
00:05:40.780 --> 00:05:43.690
If it were a Moore FSM,
then the two states
00:05:43.690 --> 00:05:46.750
would be equivalent if they
produced the same output
00:05:46.750 --> 00:05:49.780
and have the same transitions.
00:05:49.780 --> 00:05:53.020
Taking a closer look at
the states in this FSM,
00:05:53.020 --> 00:05:57.730
we see that both states C and
E transition to state B on a 1
00:05:57.730 --> 00:06:01.090
input and produce a 01 output.
00:06:01.090 --> 00:06:04.480
On a 0 input, they both
transition to state A
00:06:04.480 --> 00:06:07.180
and produce a 10 output.
00:06:07.180 --> 00:06:10.180
So states C and E are
equivalent and can
00:06:10.180 --> 00:06:13.960
be merged into a single state,
thus reducing the total number
00:06:13.960 --> 00:06:17.271
of states in our FSM to four.