Mealy machines
A mealy machine is a special type of finite state machine that also handles output. It follows all the rules of a finite state machine i.e. The machine is always in one of a finite number of states, and it moves between states
when triggered by an external event or timer. The new aspect is that as well as being labelled with the input that causes the transition, each arrow will also show the output associated with the action.
The mealy machine above accepts an input of a string of 1s and 0s and outputs a string of equal length. If we consider the number 1010 we can see how it works.
We start in the start state S0 and the first input is a 1 so the first output is a 0 and we move to S1.
The next input is a 0 so the output is 1 and we move to S2.
The next input is 1 so the output is 0 and we move to S1.
The final input is 0 so the output is 1 and we move to S2 and our output is 0101.
This particular mealy machine is actually performing a right bit shift of one place.