This is a great question about the fundamental difference between Mealy and Moore finite state machines (FSMs) and their output timing characteristics, particularly regarding glitch susceptibility.
Let me break this down systematically:
Moore FSM Characteristics:
- Output depends on: Current state only
- Timing: Outputs are registered (synchronous) - they change on clock edges
- Output update: Occurs when the state register updates
- Propagation: State → Output decoder → Output (all combinational after register)
Mealy FSM Characteristics:
- Output depends on: Current state AND current input
- Timing: Outputs are combinational - can change immediately when inputs change
- Output update: Can occur combinationally between clock edges
- Propagation: State → Output decoder (with input) → Output (no final register on outputs)
Glitch Susceptibility Analysis:
Mealy FSMs are MORE prone to glitches because:
-
Combinational Paths: The output path contains combinational logic from both state bits and external inputs. When either the state or input changes, there are multiple propagation delays through different paths in the combinational output logic.
-
Critical Paths and Race Conditions:
- Different paths through the output decoder can have different delays
- An input change can propagate through multiple routes to reach the output
- These paths arriving at different times cause temporary incorrect output values (glitches)
-
External Input Changes: Since external inputs affect the outputs combinationally, any noise, metastability, or timing skew in the inputs can directly affect outputs.
-
Example: Imagine a Mealy output that's true when in State A AND Input X. If you transition through State A but Input X changes at nearly the same time, the different logic paths computing the output could arrive at different times, causing a momentary glitch.
Moore FSMs are more resistant to glitches because:
Outputs only change on clock edges when the state register updates, keeping them stable between clock cycles. The state register acts as a synchronizing buffer, and since the output logic only decodes from this stable registered state, there's no direct path from external inputs to outputs. This clock-controlled timing prevents asynchronous input changes from causing momentary output errors.
In a Mealy machine, outputs can glitch when state bits transition while inputs have timing issues—for example, if state[1:0] shifts from 01 to 10 during an input spike, the output decoder might momentarily see intermediate values and produce a glitch. A Moore machine avoids this because its outputs depend solely on state decoding, like output = state[1:0] == 2'b01, which only changes when the state register itself updates on a clock edge.
Mealy designs are more vulnerable to metastability problems since asynchronous external inputs can directly affect outputs, potentially causing glitches if an input becomes metastable. Moore machines provide better isolation—external inputs first synchronize through the state register before influencing outputs.
To reduce glitching in Mealy FSMs, I can register the outputs, add pipeline stages, debounce inputs, use gray code for state encoding, and ensure tight timing closure. Moore machines already benefit from synchronization through the state register, though careful decoder design and minimizing state vector width still matter.
The core distinction holds: Moore outputs are inherently synchronous while Mealy outputs respond combinationally to inputs. However, this can be modified—registering Mealy outputs creates a synchronous variant, and modern designs often employ this technique. The fundamental advantage of Moore remains its lower susceptibility to glitches, since Mealy's direct input-to-output paths create the vulnerability that needs mitigation.
Mealy vs Moore: Glitch Susceptibility
Output Timing Summary
| Aspect | Moore | Mealy |
|---|
| Output depends on | State only | State + Input |
| Timing | Synchronous (registered) | Combinational |
| Change timing | Clock edges only | Asynchronously (between cycles) |
| Glitch prone | Lower | Higher |
Why Mealy is More Glitch-Prone
1. Combinational Paths with Multiple Routes
Mealy: State + Input --[Combinational Decoder]--→ Output
(N paths with different delays)
└─→ Glitches from propagation delay mismatches
- Multiple logical paths from inputs/state to output
- Different propagation delays create races
- Momentary incorrect values before stabilization
2. Direct Input-to-Output Coupling
When external inputs directly affect outputs combinationally:
// Mealy - INPUT HAZARD
assign output = (current_state == READY) & input_signal;
// └─ If input_signal glitches, output glitches immediately
// └─ No synchronization barrier
3. Critical Timing Scenario
Timeline: State transitions [01→10] while input toggles [0→1→0]
Intermediate logic values:
t0: state=01, input=0 → output=0
t0+ε: state transitioning, input becomes 1 → output=? (GLITCH)
t0+2ε: state=10, input goes back to 0 → output=0 (settled)
RESULT: Unwanted output pulse
Why Moore is More Resistant
Synchronous Output Update
State Register --→ Output Decoder --→ STABLE Output
(Clock) (Combinational)
└─ Only changes on clock edges
// Moore - NO INPUT HAZARD
always @(posedge clock)
state <= next_state;
assign output = (current_state == READY);
// Output is stable between clocks; only changes at clock edges
Buffering Effect
- State register acts as a synchronization barrier
- Output decoder sees only stable state values
- External input timing issues don't directly propagate
Practical Comparison
Mealy Glitch Example
Scenario: Output should pulse when state=ACTIVE and sensor_input=1
if (state==ACTIVE && sensor_input) begin
pulse <= 1;
end
- Noisy sensor signal → immediate output glitch
- Metastable input → output glitch mid-cycle
Moore Glitch Example
always @(posedge clock)
pulse_enabled <= (next_state == ACTIVE);
assign pulse = pulse_enabled & sensor_input;
- Still has input glitch risk, but state changes are clean
- Can be further improved by registering sensor_input
Mitigation Strategies
| FSM Type | Risk Level | Mitigation |
|---|
| Raw Mealy | 🔴 High | Register outputs; debounce inputs; add pipelines |
| Synchronous Mealy | 🟡 Medium | Register Mealy outputs (output <= output_comb) |
| Moore | 🟢 Low | Careful decoder design; input debouncing optional |
Register Mealy Outputs (Best Practice)
// Synchronous Mealy - Reduced glitches
always @(posedge clock) begin
output <= (state == ACTIVE) & input_signal;
end
// Now output changes only on clock edges
Key Takeaway
Mealy FSMs are significantly more glitch-prone due to:
- Combinational output paths with input-dependent delays
- Direct coupling to asynchronous inputs
- No synchronization barrier
Moore FSMs are naturally glitch-resistant due to:
- Registered state → stable output decoder inputs
- Output changes tied to clock edges
- Inherent synchronization
In modern designs, synchronous Mealy (with registered outputs) is preferred: it gains Mealy's responsiveness while maintaining Moore's glitch immunity.