Mealy vs Moore Machine: Outputs, Timing and State Count
A state machine consists of a register that holds the current state, combinational logic that decides the next state and combinational logic that decides the outputs. Mealy and Moore machines differ in what determines the outputs. In a Mealy machine, the outputs depend on both the current state and the current inputs, so an input change shows up at the output within the same cycle. In a Moore machine, the outputs depend only on the current state, so an input change reaches the output only after the clock updates the state, one cycle later. Mealy machines need fewer states and respond faster; Moore machines give stable outputs and more predictable timing.
| Aspect | Mealy machine | Moore machine |
|---|---|---|
| What determines the output | Current state and current inputs | Current state only |
| Output in a state diagram | Written on the transition arrows as "input/output" | Written inside the state circle with the state name |
| Response to inputs | When an input changes, the output changes within the same cycle without waiting for the clock | The output changes after the next clock updates the state, one cycle later than a Mealy machine |
| State count (overlapping "101" detector) | 3 states (no match, matched 1, matched 10) | 4 states (an extra "101 detected" state is needed to output 1) |
| State count (in general) | Equal to or fewer than a Moore machine for the same behavior | Mealy states must be split by the output of their incoming transitions, so it tends to need more |
| Glitches and noise | Input glitches and noise pass through the combinational logic straight to the output | Input noise does not reach the output; encoding states so outputs come directly from state-register bits also removes output glitches |
| Timing paths | Combinational logic connects inputs to outputs, lengthening paths that include surrounding logic; connecting Mealy machines together can create combinational loops | Outputs depend only on the state after the clock edge, so paths are broken by registers and timing is easier to analyze |
| HDL style | The combinational output block reads the inputs as well as the state | Output expressions read only the state (for example, a case statement setting outputs per state); outputs are often driven from registers |
| Where it fits | Control that must respond with no cycle of delay, or when fewer states are wanted | Control signals that need clean outputs (such as signals to another clock domain or off chip), or when predictable timing matters |
Figures are typical orders of magnitude and vary by process generation and product.