RTL Design / Module 6: FSMs & Control
Lesson 6.1

Moore vs Mealy — when each is right

Every control block is a finite state machine (FSM). The split that matters most in RTL is where outputs are computed: Moore machines drive outputs from state only; Mealy machines drive outputs from state plus current inputs. That one choice changes timing, area, and how you debug waveforms.

Core distinction

Moore: output = f(state). Registered, stable for the whole cycle in state.
Mealy: output = f(state, inputs). Can react combinationally to inputs within the same cycle.

1

Side-by-side — same traffic-light spec

Consider a simple controller: in IDLE wait for go; in GREEN assert light_green until timer_done; return to IDLE.

AspectMooreMealy
Output sourceDecoded from state onlyDecoded from state + go, timer_done
Output timingChanges only after state update (next posedge)Can change same cycle as input (combo path)
Typical latency+1 cycle vs minimal Mealy for same reactionCan be 0-cycle reaction to inputs
State countOften more states (output encoded in state)Often fewer states (output on transitions)
Glitch riskLower if outputs registered from stateHigher if outputs are combo from inputs
Waveform debugOutputs align cleanly with state bubblesOutputs may pulse within a state
2

Moore state diagram

Outputs live inside the state bubble. Transitions carry only input conditions — no output labels on arrows.

Moore FSM state diagram

Moore: light_green is implied by being in GREEN — not written on the transition.

3

Mealy state diagram

Outputs can appear on transition arcs — the machine asserts a signal while a condition is true, even before the state register updates.

Mealy FSM state diagram

Mealy: output actions ride on the edge label input / output.

4

Timing — why Moore is one cycle slower

Industry default: Prefer Moore (or Moore-style registered outputs) for chip-wide control signals. Use Mealy only when you need same-cycle response and you register or qualify the output path carefully.

5

Moore RTL — output decode block

moore_traffic.v
// Moore traffic controller — outputs from state only
module moore_traffic (
  input  wire       clk,
  input  wire       rst_n,
  input  wire       go,
  input  wire       timer_done,
  output wire       light_green,
  output wire       light_red
);
  localparam IDLE  = 2'd0;
  localparam GREEN = 2'd1;

  reg [1:0] state, next;

  always @(posedge clk or negedge rst_n)
    if (!rst_n) state <= IDLE;
    else        state <= next;

  always @(*) begin
    next = state;
    case (state)
      IDLE:  if (go)         next = GREEN;
      GREEN: if (timer_done) next = IDLE;
      default: next = IDLE;
    endcase
  end

  // Moore outputs — function of state ONLY
  assign light_green = (state == GREEN);
  assign light_red   = (state == IDLE);
endmodule
6

Mealy RTL — output in next-state logic

mealy_traffic.v
// Mealy traffic controller — output from state + inputs
module mealy_traffic (
  input  wire       clk,
  input  wire       rst_n,
  input  wire       go,
  input  wire       timer_done,
  output reg        light_green
);
  localparam S0 = 1'b0;
  localparam S1 = 1'b1;

  reg state, next;

  always @(posedge clk or negedge rst_n)
    if (!rst_n) state <= S0;
    else        state <= next;

  always @(*) begin
    next        = state;
    light_green = 1'b0;          // default
    case (state)
      S0: begin
        if (go) begin
          next        = S1;
          light_green = 1'b1;      // Mealy: assert on transition condition
        end
      end
      S1: begin
        light_green = 1'b1;        // hold while in S1
        if (timer_done) next = S0;
      end
      default: next = S0;
    endcase
  end
endmodule
Trap

Mealy outputs in always @(*) can glitch when inputs glitch. For external pins or long combo paths, register the output (always @(posedge clk)) — you get a "Moore-ish" timing profile with cleaner timing closure.

7

Decision guide — when to use each

🟢

Pick Moore when…

Outputs must be stable all cycle; easy waveform review; multi-clock or CDC output registers; protocol outputs sampled on clock edge.

⚡

Pick Mealy when…

You need minimum latency; fewer states matter (area in state reg); output is inherently tied to input condition (e.g. ack = req & ready).

🔧

Hybrid (common)

Mealy next-state + Moore registered outputs: compute next_out combo, register to out. Best of debuggability and timing control.

▶ Compare Moore vs Mealy in simulator
8

FSM type checklist

  • Draw the state diagram before coding — label Moore outputs in bubbles, Mealy on arcs
  • Document whether each output is Moore, Mealy, or registered Mealy
  • Moore: separate next_state and output_decode blocks
  • Mealy: default every output in the combo block; watch for inferred latches
  • Check latency: does the spec need same-cycle or next-cycle response?
  • Run waves: do outputs glitch mid-cycle on input edges?

🎯 What to remember

  • Moore: output = f(state) — stable, +1 cycle latency, easier debug.
  • Mealy: output = f(state, input) — faster reaction, fewer states, glitch risk.
  • Most production RTL uses Moore outputs or registered Mealy outputs.
  • Always draw the diagram first — the Moore/Mealy choice should be explicit.
Advertisement