Wednesday, 13 November 2019

rtl - How to choose between Mealy and Moore state machine


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.



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.


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...