Skip to content
DenseChip
Learn
PracticeCode labInterview

DenseChip

Navigate

Menu

LearnPracticeCode labInterview

Tools

All toolsSV editorCode repoResume
DenseChip

Practice, courses, and chip-design tools in one focused workspace.

LearnPracticeCode labInterviewToolsLearning paths

© 2026 DenseChip

AboutContactPrivacyTerms
Skip to lesson

Course contents

  • RTL Foundations36
  • Combinational Design25
  • Sequential Design27
  • FSM & Control27
  • Timing & Clocking39
  • Reset & CDC34
  • Memory & Buses57
  • Advanced RTL28
  • Senior & Interview76
    • Low-Power RTL Hub
    • DFT and Scan Hub
    • Physical Awareness Hub
    • Waveform Debug Hub
    • STA and ECO Hub
    • RTL-to-Implementation Closure
    • DFT-Ready RTL
    • Capstone: Resilient Streaming Peripheral
    • Principal Design Review
    • Senior RTL Interview Questions & Model Answers
      • Interview: Combinational and Arithmetic
      • Interview: Sequential and Pipelines
      • Interview: FSM and Control
        • Choosing an FSM Encoding from Timing
        • Moore vs Mealy Outputs
        • Proving an FSM Correct
        • The Controller and Datapath Split
      • Interview: Timing and STA
      • Interview: CDC and Reset
      • Interview: Memories and Buses
      • Interview: Low-Power Design
      • Interview: Debug and ECO
      • Interview: Coding and Whiteboard
  • Glossary and Notation
Loading lesson

‹Interview: FSM and Control
  1. Topics
  2. RTL Design
  3. Senior & Interview
  4. Senior RTL Interview Questions & Model Answers
  5. Interview: FSM and Control
  6. Moore vs Mealy Outputs

Part 9 · Senior · Senior

Moore vs Mealy Outputs

A Mealy edge flag fires this cycle and the Moore version one cycle later, proven by one testbench.

On this page

    Why this matters

    The same falling-edge flag fires in the cycle the input falls as a Mealy output and one cycle later as a Moore output. The choice trades that cycle against a combinational input-to-output path.

    After this lesson you can: draw the one-cycle gap between a Mealy and a Moore output, and decide which to register before a port.

    The question

    "Show me the same output done as Moore and as Mealy. When does each fire, and which would you ship?" The interviewer wants the timing difference drawn precisely, plus a decision.

    The complete answer gives both machines, states the one-cycle gap, and names the timing path each choice creates.

    Model answer

    A Moore output depends on state alone; a Mealy output also depends on live inputs. A combinational Moore decode can still glitch just after an edge while state bits settle. Only an explicitly registered output (or a separately verified hazard-free implementation) provides a glitch-free boundary.

    For a falling-edge flag, the Mealy version fires in the cycle the input falls. The Moore version needs a dedicated state, so it fires one cycle later.

    Mealy state diagram with states ZERO and ONE. x=1 goes to ONE, x=0 goes to ZERO. The arc from ONE to ZERO on x=0 carries the output y=1.
    Mealy edge flag: two states, and y is written on the arc. It is 1 while the machine sits in ONE and x is already 0.
    Moore state diagram with states ZERO, ONE and FELL with y = 1. x=1 goes to ONE from every state. From ONE, x=0 goes to FELL; from FELL or ZERO, x=0 goes to ZERO.
    Moore edge flag: the fall needs its own state FELL, and y is written in the state. It is 1 only after the edge that enters FELL.

    Compare where y is written. On the Mealy arc it appears as soon as x falls; in the Moore state it waits for the edge that enters FELL, which is the one-cycle gap.

    Moore

    Mealy

    Depends on

    State only

    State and current inputs

    Reacts to an input

    After the next clock edge

    In the same cycle

    Stability within a cycle

    Settles after state/decode transitions; may glitch during settling

    Can also follow input glitches

    States for the same job

    Often one more

    Fewer

    Timing path

    State clock-to-Q plus decode and routing

    Input/state through combinational logic to output

    Each slot is one clock cycle sampled just before its closing edge. The same input drives both machines, and it falls during slot 3.

    • Slot 3: x falls while both machines still read ONE, so y_mealy rises in the same slot. The Moore machine only moves to FELL at the closing edge.

    • Slot 4: o_state reads FELL (the 2 in its lane), so y_moore rises exactly one cycle after y_mealy.

    • Slot 6: x rises again and neither flag fires. Rising edges are ignored by design.

    For glitch-sensitive exported controls, register the output explicitly, whether its decision is Moore or Mealy. A combinational Moore output can be used at a synchronous boundary when its decode delay and settling are included in the timing contract. Keep plain Mealy for intentional same-cycle feedback with a budgeted path.

    Interview

    One-line answer: Moore means state-only, not automatically registered. Mealy adds live-input dependence. State the latency and timing path, and register outputs whose consumers require glitch-free controls.

    Follow-ups

    • The Mealy decision must leave the block. What changes? Register it before the port. A registered Mealy output keeps the small state with Moore-like timing.

    • Which closes timing more easily? Compare the actual paths. Moore removes live input-to-output dependence but may have a deep state decode. A registered output moves that decode before its output flop; clock-to-Q and routing then dominate the external path.

    • Two Mealy blocks chained together? The combinational paths add up across the chain. Budget the full input-to-output delay, or register between the blocks.

    Common wrong answers

    • "Mealy saves a cycle, so it is always better." The saved cycle costs a combinational path to the output. At a boundary that path can fail timing or glitch.

    • "Moore and Mealy detect different things." On the same spec they flag the same events. They differ only in when the flag is visible relative to the clock.

    • "Sample the Mealy output right at the edge." Inputs driven at the edge race the sampling. Drive inputs away from the edge and compare after the logic settles.

    Common pitfall

    Chained Mealy outputs can create a long input-to-output path. Moore decode avoids live-input dependence but can still glitch as state bits change. Register a glitch-sensitive control explicitly, and include any remaining decode in STA.

    Check yourself The input falls in cycle 3. In which cycle does each version of the edge flag fire?

    Mealy fires in cycle 3, the same cycle. Moore fires in cycle 4, one cycle later. The testbench below checks exactly this relationship on every sample.

    Check yourself Why does the testbench wait #1 after driving x before comparing the Mealy output?

    The Mealy output is combinational in x. The delay lets it settle, so the check compares the settled value instead of racing the input change.

    Testbench

    A falling-edge flag in both styles, checked sample by sample: Mealy equals the spec, Moore equals the spec delayed by one cycle.

    edge_mealy.sv
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    module edge_mealy (input logic clk, rst_n, x, output logic y);
      typedef enum logic {ZERO, ONE} state_t;   // ONE means the previous sample was 1
      state_t state;
      always_ff @(posedge clk or negedge rst_n)
        if (!rst_n)      state <= ZERO;
        else if (x)      state <= ONE;
        else             state <= ZERO;
      assign y = (state == ONE) && !x;          // Mealy: state AND live input
    endmodule
    
    module edge_moore (input logic clk, rst_n, x, output logic y);
      typedef enum logic [1:0] {ZERO, ONE, FELL} state_t;
      state_t state, next_state;
      always_comb begin
        next_state = state;
        case (state)
          ZERO: if (x) next_state = ONE;
          ONE:  if (x) next_state = ONE; else next_state = FELL;
          FELL: if (x) next_state = ONE; else next_state = ZERO;
          default: next_state = ZERO;
        endcase
      end
      always_ff @(posedge clk or negedge rst_n)
        if (!rst_n) state <= ZERO;
        else        state <= next_state;
      assign y = (state == FELL);               // Moore: state only
    endmodule
    

    Remember

    • Moore depends on state alone; Mealy also depends on live inputs. Moore is not automatically registered.

    • A combinational Moore decode can still glitch just after an edge.

    • Chained Mealy outputs add up their combinational delay across the chain.

    Rule of thumb: register any output whose consumer needs a glitch-free control.

    Keep going

    • Practice: FSM output encoding: registered vs combinational hazards

    • Code lab: Moore three-state FSM

    • Interview: run a mock interview on this topic

    Related topics

    • Behavioral difference

    • Side-by-side sequence detector

    Previous

    322 / 350

    Next: Proving an FSM Correct

    Up next

    Up nextProving an FSM Correct

    Sign in to save progress

    Practice this lessonReport an error

    See also

    • The Controller and Datapath Split
    clkxm_statey_mealyo_state0120y_moore
    One falling input drives both edge flags: the Mealy flag fires in the fall cycle and the Moore flag one cycle later