FSM - Finite State Machine
There are two types of machines, namely
- Moore Machine : A finite state machine for
which the output depends only on the states.
- Mealy Machine : A finite state machine for
which the input depends on the states and the inputs.
Now, let us break down the problem.
Tasks
- A state table.
- A state diagram.
1. STATE
TABLE
Let us explore the question
deeper.
Firstly, what is the objective of the
machine?
- TO PROVIDE AN OUTPUT OF "1" IF A SEQUENCE OF
"101" IS DETECTED.
Secondly, what other information do we
have about the machine?
- It has 'SINGLE' input, i.e. we have one input port to our
machine
- It has 'SINGLE' output, i.e. we have one output port to our
machine
Let us start at some initial state
S.
This state S
could be any random state, or to look at it from another
perspective, S
could be the current state of the machine.
Now, we have a sequence of input
arriving at the input port of machine. (Say 00010101000111)
- t = 0 ; INPUT = 0
- t = 1 ; INPUT = 0
- t = 2 ; INPUT = 0
- t = 3 ; INPUT = 1
- t = 4 ; INPUT = 0
- t = 5 : INPUT = 1
- t = 6 ; INPUT = 0
Say we just started the machine. the
input to the FSM changes with every clock pulse.
If an input of "1"
arrivies at the input while the machine is in state
S
- The machine has to start detecting for a sequence of "101", and
the first "1" in the sequecnce (xx1) has arrived.
- This takes the machine to a different state S1 (say).
- The output for the machine is "0" since a sequence of "101" has
not been detected.
If an input of "0"
arrivies at the input while the machine is in state
S
- The system stays in S.
- The output for the machine is "0" since a sequence of "101" has
not been detected.
If an input of "1"
arrivies at the input while the machine is in state
S1
- The sequence becomes "11".
- But, this "1" that arrived now could be the first in the
sequence for a "101".
- Hence, we stay in S1.
- The output for the machine is "0" since a sequence of "101" has
not been detected.
If an input of "0"
arrivies at the input while the machine is in state
S1
- With the arrival of "0" we have two bits of the sequence
(x10).
- The system transitions to S2.
- The output for the machine is "0" since a sequence of "101" has
not been detected.
If an input of "1"
arrivies at the input while the machine is in state
S2
- We have a sequence of "101".
- The machine transitions to state S3.
- The output for the machine is "1" since a
sequence of "101" has been
detected.
If an input of "0"
arrivies at the input while the machine is in state
S2
- The input sequence becomes "100".
- A state transition happens from S3 to
S.
- The output for the machine is "0" since a sequence of "101" has
not been detected.
If an input of "1"
arrivies at the input while the machine is in state
S3
- State S3 is when the current input has already made a sequence
of "101"
- We another "1" arrives the sequence becomes "011", which is not
the output we are looking for.
- But, the "1" that arrives could be the beginning of a
sequence(xx1).
- Hence, a state transition from S3 to
S1 happens.
- The output for the machine is "0" since a sequence of "101" has
not been detected.
If an input of "0"
arrivies at the input while the machine is in state
S3
- The sequence becomes "010", where we have 2 bits in the
sequence(x10).
- The state transition happens from S3 to
S2.
- The output for the machine is "0" since a sequence of "101" has
not been detected.
1. STATE
DIAGRAM