What is a State Machine
In digital electronics, a state machine is a system that is defined by the sequential states in which it exists. Basically all practical digital system like computers, calculators, traffic light controllers, washing machine controllers etc. are state machines in which the present and future behavior of the system always depend upon the state in which it exists. To clarify the point, take an example of a traffic light controller. In a traffic light controller, the next state of lights always depends upon the current state i.e. the lights don’t turn off and on in a random manner bur follow a sequence.A State Machine always has a state graph associated with it which is nothing but a pictorial representation of the relationship between state transistions, system inputs and outputs. To design any practical digital system, it is essential to represent the system in the form of the aforementioned state graph.
By represeting the different states by binary bits, one can synthesize a hardware model where the present state variables are used along with the system input variables to generate the next state variables along with the system outputs. The next state variables are fed in to flip flops and on the next system clock will become the present state variables and thus will generate new next state variables along with new system outputs.
Thus a state machine basically consists of a sequential flip flop part along with a combinational digital circuitry in to which the outputs of the flip flops are fed back along with the system inputs to generate the next state variables along with the system outputs. The next state variables so generated are connected indeed to the input lines of the sequential flip flops. The combinational circuit in this model is known as the Steering Logic i.e. the logic that steers the machine from state to state.
Further, in a state machine if the system outputs depend only upon the present state of the machine, then it is known as a Moore Machine. But if the system outputs depend on the present state of the machine and also the system inputs in that state, then such a machine is known as a Mealy Machine. Also it is not necessary for a state machine to have external inputs and outputs. For example:- An arbitary sequence counter is a state machine that moves from state to state with every clock pulse and has zero external inputs and outputs.