Mealy to Moore Machine Conversion



Mealy and Moore machines are special finite state machines that generate outputs. In this chapter, we will explain how to convert a Mealy machine to a Moore machine. We'll use the state diagram of the Mealy machine as our starting point and learn how to convert it into its equivalent state diagram of the Moore machine through intermediate states.

Concepts of Moore and Mealy Machines

The output of a Moore machine is represented on the state itself, as is common knowledge. On the other hand, the output of a Mealy machine is displayed on the transition, or more precisely, on the arrow itself.

Moore-to-Mealy conversion is comparatively easier than the Mealy-to-Moore conversion. Let's discuss a few of the conversion guidelines.

Basic Conversion Rules

Converting a Mealy machine to Moore machine is little complex where it needs additional intermediate states.

Imagine there is a state 'A' with two incoming transitions. In one transition, the input is '0' and output is 1, while in the second transition, the input is '1' and output is also 1.

Conversion Rules Mealy Machine to Moore Machine

In the equivalent Moore representation, we'll write the '1' alongside state. This '1' represents the output when we reach the state 'A'.

Conversion Rules Mealy Machine to Moore Machine 1

This is done because of we have the same output 1 for inputs 0 and 1. But for the following case with different output in Mealy.

Conversion Rules Mealy Machine to Moore Machine 2

It will have two different states in Moore machine −

two different states in Moore machine

Conversion Stages: Mealy to Moore Machine

To convert a Mealy machine to its equivalent Moore machine, we must follow the steps given below −

Identify Incoming Transitions

For each state in the Mealy machine, carefully get all the incoming transitions.

Analyze the Outputs

Analyze the outputs associated with these incoming transitions.

  • Case 1: Same Outputs − If all incoming transitions to a state have the same output, no splitting is needed. We can directly write that output within the state itself in the Moore diagram.
  • Case 2: Different Outputs − If incoming transitions to a state have different outputs, we must split that state into multiple states in the Moore diagram. The number of new states will equal the number of unique outputs for the original state.

Splitting States

When there is a splitting a state, assign a new state for each unique output.

Label these new states based on the original state and their corresponding output. As given in the above diagrams, if the original state is 'A' and we have outputs '0' and '1', we create states 'A0' and 'A1' in the Moore diagram.

Incoming transitions from the Mealy diagram are directed to the corresponding new states based on their outputs. From the above example we can get, a Mealy transition with output '1' to state 'A' will now go to state 'A1' in the Moore diagram.

Outgoing Transitions

All outgoing transitions from the original Mealy state will be copied to each of the newly generated Moore states.

Example of Mealy to Moore Machine Conversion

Consider we have a Mealy machine state diagram with four states −

Mealy to Moore Machine Conversion

State Transition Table

The state transition table is like below −

PS Next State (X = 0) Next State (X = 1) Output (X = 0) Output (X = 1)
A A B 0 0
B C D 0 0
C A C 0 0
D B A 1 1

From the above diagram and table, we can analyze that A, C and D has no splitting since all outputs are the same while reaching at that state, but for B, it is generating 0 for incoming ages from A, B abd C, but output 1 for edge coming from D.

Now let us try to make the Moore machine diagram corresponding to the previous Mealy diagram −

Moore Machine Diagram Corresponding
State Output Input = 0 Input = 1
A 0 A B
B0 0 C B0
B1 1 C B0
C 0 D B0
D 0 A B1

Let us take another example

Moore Machine Diagram Corresponding

Here, we can see A can be split into A0 and A1 and B will be B0 and B1. So, the final diagram will be like this −

Mealy to Moore Machine Conversion Final Diagram

Conclusion

Converting a Mealy machine to a Moore machine needs to analyze the incoming transitions and splitting states based on unique outputs. In this chapter, we explained the steps for each and individual concepts in detail.

By following the steps, we can systematically create an equivalent Moore machine that replicates the functionality of the original Mealy machine, as we have seen through the examples and transition tables.

Advertisements