Electronic – How to choose between Mealy and Moore state machine

rtlstate-machines

I know the basic differences between Mealy and Moore FSM (Finite state machine). What I want to understand is the following:

  • Pros and cons of using Mealy over Moore and vice versa
  • In which situation Moore is more suitable than Mealy and vice versa

The figures of merit for comparison could be latency, throughput, area (state encoding FF's), power etc.

Best Answer

From a discrete logic & HDL perspective:

-Mealy machines (generally) have less states. Mealy machines change their output based on their current input and present state, rather than just the present state. However, less states doesn't always mean simpler to implement.

-Moore machines may be safer to use, because they change states on the clock edge (if you are using DFF logic for present and next state), whereas Mealy machines are faster, because the state is dependent on the input. Thus, the state can change asynchronously. This comes down to predictability vs raw speed. When it comes down to it, it's difficult to draw hard lines where one machine would always be better than the other.

It really comes down to the specific task at hand. Does one want to have a synchronous or asynchronous machine? Is speed paramount? Will there be potential unstable (bouncing) signals? Are both the inputs and present state readily available? The answer to each of these questions determines the type of machine that would work best.

It's worth mentioning that for a hardware implementation, Mealy machines require less hardware in their circuits, but when working with an HDL and RTL scenario, the actual amount of discrete hardware may not be terribly important.