FSM Lecture 2- Mealy and Moore machine

  • Post author:
  • Post category:Blog

 

Mealy and Moore machine

 

 

Mealy and Moore machines are two different types of Finite State Machines (FSMs) that are commonly used for modeling and designing digital systems. Both types of machines define the behavior and state transitions of a system, but they differ in how they handle outputs.

 

Mealy machine:

  • In this machine, the output produced by the state machine depends on the input events fed to the state machine AND presents an active state of the state machine.
  • The output is not produced inside the state.

 

Here are the key characteristics of a Mealy machine:

  • Outputs depend on the current state and the inputs.
  • Outputs can change asynchronously during the state.
  • The output is associated with the transitions between states.

A Mealy machine can be represented by a state diagram or a state table. The state diagram consists of circles (representing states) and arrows (representing transitions), where each transition is labeled with both the triggering input and the associated output.

Mealy and Moore machine
Figure 1. Generic model of the Mealy machine.

 

Figure 1 shows the Generic model of the Mealy machine.

  • In the Mealy machine, the output is represented along with each input separated by a ‘/’ character. 
  • An ‘Output’ is also called ‘Actions.’
  • In the Mealy model, the ‘Output’ is also called ‘Input action.’ Because when the input is received, the action may happen or output happens, and there will be a state transition.

That’s why, in the mealy machine, all you need to remember is, the output is not produced inside the states but along the transition.

 

Example of Mealy Machine:

Mealy and Moore machine
Figure 2. Mealy machine Example

 

A light control application has 4 states. 

  1. Off state 
  2. the dim state 
  3. medium brightness state 
  4. Full brightness state

A state can be drawn as a circle, or as a rectangle, or as a rounded rectangle; it doesn’t matter. You can draw it in any way you want. But, if it is a UML specification-based state machine diagram, it should be a curved rectangle. 

But, if you are modeling your application using different states, you can either use a circle or a rectangle, no problem. 

 

Mealy and Moore machine
Figure 3. Event move to the Initial state to Dim state

 

In Figure 3, there are two buttons on the light stand, the ON button and the OFF button.  

When you give power to the table lamp, initially, the application will be in the ‘OFF’ state. The ‘ON’ event is delivered to the state machine when you press the’ ON’ button. That’s an ‘ON’ event. When you press the ‘OFF’ button, the ‘OFF’ event is delivered to the state machine. 

As I said, when you first give the power, the table lamp software gets into the initial state ‘OFF .’ When you press the ‘ON’ button, the ‘ON’ event is delivered to the software, making a transition. The state of the software will be changed to ‘Dim,’ and along with this transition it produces the output ‘Dim the light.’ So, the light will be turned ‘ON,’ but its intensity will be ‘Dim.’

 

 Mealy and Moore machine
Figure 4. Event move to the Dim state to Medium brightness state

 

Now the software is in the ‘Dim’ state, and when it gets into the ‘Dim’ state, it doesn’t do anything in the Mealy machine; it just waits in the ‘Dim’ state. When you again press the ‘ON’ button one more time, the state machine receives the ‘ON’ event, and the state machine moves from ‘Dim’ state to ‘Medium brightness’ state, producing the output ‘Medium brightness .’(Figure 4)

 

Figure 5. Move event to the medium brightness to Full brightness
Figure 5. Event move to the medium brightness to Full brightness

 

Now the software is in ‘Medium brightness’ state, and again you press the ‘ON’ button, it receives the ON event and produces some other output. (Figure 5)

 

Figure 6
Figure 6. Event move to the any of the state to OFF state

 

When the state machine is in any of the states, when the user presses the ‘OFF’ button, the OFF event is received, and they go back to the OFF state, and along with the transition the action taken was ‘Lights Off.’ (Figure 6)

 

Moore Machine:

  • In this state machine, the output is determined only by the present active state of the state machine and not by any input events.
  • No output during state transition.
Figure 7.Generic Moore model
Figure 7.Generic Moore model
  • Output is represented inside the state.
  • ‘Output’ is also called  ‘Action.’
  • In the Moore model, the ‘Output’ is also called ‘Entry action.’

Here are the key characteristics of a Moore machine:

  • Outputs depend only on the current state.
  • Outputs change synchronously at the beginning of each state.
  • The output is associated with the states.

A Moore machine can also be represented by a state diagram or a state table. The state diagram consists of circles (representing states) and arrows (representing transitions), where the outputs are typically written inside the circles representing the states.

 

Moore Machine Example:

Figure 8. Moore machine Example
Figure 8. Moore machine Example

 

When the initial state is ‘OFF’ or when the initial state ‘OFF’ is entered, the entry action gets executed, or the output is produced. That is ‘Lights Off .’

And when the user presses the ‘ON’ button, the state machine receives the ‘ON’ event, and when the state machine receives the ‘ON’ event, it moves to the ‘Dim’ state, or it enters the ‘Dim’ state.

And when it enters the ‘Dim’ state, the entry action gets executed. That is ‘Dim the Light.’

 

The Mealy and Moore machines are not quite famous in software engineering to model your software engineering problems, but it is still being used. Its application areas are digital circuit designs, the VLSI system design, etc. 

In the following article, let’s learn Mealy and Moore State Transition Table.

 

FastBit Embedded Brain Academy Courses

Click here: https://fastbitlab.com/course1

 

 

FastBitLab

The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.