Mealy Machines Finite State Machines with Outputs given on the transitions
Machines with Outputs Mealy machines can output symbols. The symbols it can output are determined by a pre-defined alphabet. The output and input alphabets are independent from each other and are often made up of different symbols. Outputs are shown on the transition arrow, and are initiated when the transition is followed. A backslash is used to separate inputs and outputs from each other. input / output
Example Mealy Machine #1 We will now build a Mealy machine that reverses the input given to it. We can do this in one state, with just two transitions! Here we are saying that if the input is 0 then output a 1. If we read in a 1 then output a 0. This repeats until the end of the string. a 0 / 1 1 / 0
Example Mealy Machine #2 We will now look at a Mealy machine that takes base 10 numbers as its input. It will output a 1 if the number is divisible by 3, and a 0 if not. The number is read from left to right. e.g. 126 → 011 State a reads a 1 Output 0 – move to state b State b reads a 2 Output 1 – move to state a State a reads a 6 Output 1 – stay in state a End of input – last output was a 1, so number is divisible by 3.
Mealy Challenge Integer Division of Binary Numbers Write a Mealy machine that integer divides binary numbers by 2. e.g → → → → → → → → 011 Can you spot a pattern here? What is happening to each number? You can do this using just two states. Use the following logic rule to help you: If digit is a 1, then replace it with a 0 and replace the next zero with a 1.
Mealy Machine to Integer Divide Binary Numbers a b
Mealy Challenge - Answer a 0 / 0 b 1 / 0 1 / 1 0 / 1