 In this video we are going to explain the process to translate or to go from a finite state machine and build a digital circuit. Now in order to explain this process we are going to start from our generic finite state machine that has four states 0 0 0 1 1 1 and 1 0 and it has the following transition structure. Now this transition structure is assuming that the machine has two variables to represent the state but also one input and the input values that are considered for all these transitions are shown here. So this is our starting point, a fully specified finite state machine. Now aside from one input which we are going to call i we also have the state of the finite state machine that we are going to represent with two bits s0 and s1 as we can see here we have two bits. Now from this description we can derive the truth table in which i s0 and s1 are used to compute the values s0 plus and s1 plus denoting the next states to which the machine is making a transition. Since we have three boolean variables here we need to write eight combinations 0 0 0 0 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 0 1 1 1 0 and finally 1 1 1. So these are the eight possible situations when we consider input and current state and now we have to derive the values of the next state and we derive this simply by looking at this diagram. We know that from state 0 0 when it comes to 0 we make a transition to the same state. When we are in state 0 1 and we have a transition 0 we go to state 1 1. 1 0 with a 0 makes a transition to 0 0. 1 1 with a 0 remains in the same state. 0 0 with a 1 makes a transition to 0 1. 0 1 with a 1 remains in the same state. 1 0 with a 1 remains in the same state and finally 1 1 with a 1 makes a transition to 1 0. So what we have here basically is the truth table for two boolean variables as 0 plus and as 1 plus. Now the trick to implement a digital circuit from here is simply to implement these two boolean functions as if they were regular boolean functions. In other words taking the input I and as 0 and as 1 we build a set of logic gates this will be logic gates that produce as output precisely this column of the truth table as 0 plus. And we are going to have another set of logic gates with the same inputs in other words the inputs and the state variables they produce as 1 plus. Now here comes the final touch to make sure we implement this final state machine. These two variables here or these two functions what are telling us is the values that should be the future state or the state at the next time unit. So these two signals will be stored in a flip flop a 2 bit flip flop which is going to hold the current state. We can denote this like this with a clock signal and as we can see the output of these two logic blocks it's being now captured and stored another way of looking at it is that this is an element that has memory and it's captured as the current state of the machine. Now when the clock signal makes a transition the future the state of the machine becomes the current state of the machine and therefore what we have here is precisely the value of s1 and s0 and therefore they need to be connected this one over here and to s0 over here. Now this is the resulting implementation of this final state machine so we have seen the transition from this diagram to a circuit but of course we need to implement with gates these two columns over here. Now suppose that we need to implement also some values for certain outputs and let's suppose that the outputs of the circuit are only dependent on the state variables. Now we have four states 0 0 0 1 1 0 1 1 and let's assume we are extending our finite state machine let's assume that we have two outputs 0 0 0 1 that depend only on the value of the states and let's just write some arbitrary logic here this would be the value of one of the outputs depending on the states and this would be the value of the other outputs. Now one more observation before we proceed since the outputs only depend on the value of the current state this is what is called a Moore machine. How would we implement this? Well it's very simple we just need to implement a Boolean function that gives us this truth table which just so happens to be if I take this signal and this signal is actually an X or gate this will give me output 0 0 and in this case if we look at this truth table is actually an AND gate this will give us 0 1. So another way of looking at this diagram is the following in general for a Moore machine what we're going to have is the inputs going into a set of logic gates and by this box now I'm lumping together these two in other words this would be the block named now logic gates this block would be in charge of generating all the required signals and signals whatever is necessary that feed into a memory element which obviously has a clock which will contain the state and the value of these variables is also used by these logic gates to compute the next state additionally in case of a Moore machine there is another block of logic gates here that take the state variables and produce the outputs so what we have here is an schematic representation of a Moore machine now what happens is what we have is a Milley machine in the case of a Milley machine is very similar in this case the outputs 0 1 and sorry 0 0 and 0 1 wouldn't depend only on the state variables but would depend on the state variables and the inputs in other words these three variables will be taken into account to compute the value over here but again we are in a similar situation we have two Boolean functions that can be implemented with a set of gates and produce the proper truth table the equivalent schematic for a Milley machine would be the following I still have my inputs of the Milley machine these inputs go into a set of logic gates these logic gates still produce a set of signals that represent the state and this state feeds back in here but now this logic block is more complex also produces another set of signals which are the outputs in other words in a Milley machine all the logic gates that are connected to the states actually produce two sets of outputs the state outputs which would be represented by these columns here and the outputs which would correspond to these two columns over here so this scheme here corresponds with the structure of a Milley machine