Skip to article

Finite State Machines

Moore vs Mealy Output Timing

The difference between Moore-style output (depends on state only) and Mealy-style output (depends on state and input), and why this course defaults to Moore.

2 min read · Updated


An FSM's output logic can be written in one of two styles, and the difference is entirely about what the output depends on.

Take a door controller with two states, LOCKED and OPEN, stored in a state register door, and one input, a button btn.

Moore-style output depends only on the current state:

assign lamp = (door == OPEN);

Because it reads nothing but door, and a state register only changes on a clock edge, a Moore-style output is stable for the entire duration of a state. It cannot change mid-state no matter what the input does — it can only change right after the state register updates.

Mealy-style output depends on the current state and the current input:

assign beep = (door == OPEN) && btn;

Because this reads btn directly, it can respond to input changes while the state stays unchanged: in OPEN, beep follows btn in the middle of a cycle, well before the next clock edge. In LOCKED the door == OPEN test is 0, so btn has no effect there. If btn bounces between edges while the door is OPEN, beep bounces right along with it.

Course 1 uses Moore-style output as the default for exactly this reason: stable, edge-aligned outputs are easier to reason about and easier to hook up to other clocked logic without worrying about mid-cycle glitches. Mealy-style output is real and sometimes genuinely useful — it can save a clock cycle of latency in some designs, since the output can react before the state itself has caught up — but that timing benefit comes with the cost of an input-sensitive signal that can change or glitch between clock edges. Some outputs need it anyway: Lessons 4.6b and 4.7 build sequence detectors that must report a match before the rising edge that samples its final bit, while that bit is still on the input and not yet stored in the state, so their output reads the input. That is the case Mealy exists for.

When you are deciding which style to reach for on your own designs later, ask one question: does this output need to be stable and edge-aligned, or does it need to react immediately to the input? Moore covers the first case; Mealy covers the second.