How can we describe an officer in this lecture, explain the template code and coding style to describe
an FSM in each of us?
Most of the practical sequential circuits can be described with FSR.
We are already familiar with the essential elements in an officer to describe an officer in us, we
need a C C++ function.
An enumeration data type can define all the states using the FSM on their description, then we need
to define a set of static variables as registers to define states in deficit.
Responding to each state, we define a variable to represent the next state's value.
The idea is that we are not going to change the register value several times throughout the code, therefore,
as a coding ASI, we define the next state variables and change them throughout the function and at
the end we assign them to the state registers.
Then we define a variable corresponding to each output argument in the function.
Again, we modify these variables as the output value and assign them to the output arguments at the
end of the function at the heart of the function.
Buddy, we have a switch case statement that defines all the FSM transitions.
At the end of the function, we modify the state registers and assigned outputs.
Let's explain how to use this template to describe our combination lock example explained earlier in
the section.
As explained in the previous lectures, our combination lock should find the sequence of two, three,
four and six through five states to open the lock.
Let's write the code for this combination lock.
First, it is a good practice to define an enumeration type to represent all the states, then we should
define the design of function, which receives one form with input and generates a binary output.
We can have the function arguments interfaces now.
Registers represent the Sukkoth states in this example, we need one state to register that can be defined
using the C static variable according to our template.
Now we should define a variable that holds the next value of the circus.
States register.
Know that this technique prevents changing the registered value several times throughout the code.
Now, let's define a variable that holds the output value throughout the code.
Again, this variable prevents assigning different values to the function argument several times throughout
the code.
Now we need to each case a statement to represent the state transitions.
The suitcase has five cases and a default, if you are in a state that's zero and the input is two,
then the next state would be as to otherwise the next state is zero.
If you are in the states, too, and the input is three, then the next state would be as two three,
otherwise the next state is as zero.
If you are in a state as two, three and then put is four, then the next state would be as two, three,
four, otherwise the next state is a zero.
If you are in a state as two, three, four and the input is six, then the next state would be two,
three, four, six.
Otherwise the next state is a zero.
If you are in state as two, three, four, six, then the door is open and the second stays in that
state until somebody locked the door again.
Note that for the sake of simplicity, the lock mechanism is not shown in the scope.
Finally, we should change the design of state and assigned output value to the corresponding function
arguments.
In the next lecture, I will explain how to synthesize the scope inviter Satchel's.
These are our takeaway messages, we use a static variables in C to define the states in our telescope.
It is a good practice not to change the static registers several times throughout the code.
So defining nextstep that variables to keep the intermediate state value is a promising technique.
An input signal to our combination lock circuit that resets the state machine and locks the door.