Module 3: Sequential Circuit Design · 3.3 Finite State Machines

Moore and Mealy Machines

The primary distinction between Moore and Mealy state machines lies in the mathematical formulation of the output function $\lambda$.

In a Moore machine, output values depend only on the current state:

$$\lambda: S \to O$$

In a Mealy machine, output values depend on both the current state and the current inputs:

$$\lambda: S \times I \to O$$

This architectural difference determines state counts, output timing, and glitch susceptibility.

Hardware Architectures

In a Moore machine, the output logic block connects exclusively to the state register (Figure 1).

Moore structure
Figure 1: Moore FSM architecture where outputs depend exclusively on the state register

In a Mealy machine, the output logic block receives signals from both the state register and the external inputs (Figure 2).

Mealy structure
Figure 2: Mealy FSM architecture where outputs depend on state registers and external inputs

A Mealy machine provides a direct combinational path from external inputs through output logic to circuit outputs.

Comparison Example: Rising-Edge Detector

Consider an edge detector that asserts an active-high output pulse for one clock cycle when an input signal transitions from 0 to 1.

A Moore machine requires a dedicated state to represent the output condition (Figure 3). The machine requires three states: ZERO, PULSE, and ONE.

Moore edge detector
Figure 3: Moore edge detector requiring three states to isolate the output pulse

A Mealy machine associates the output pulse directly with the transition condition (Figure 4). The machine requires only two states: ZERO and ONE. The transition arrows indicate Input / Output.

Mealy edge detector
Figure 4: Mealy edge detector requiring two states with outputs placed on transitions

Timing and Glitch Considerations

Moore and Mealy architectures exhibit different output timing:

Moore Output Timing

Moore outputs update only on active clock edges because they depend solely on registered state bits.

Input transitions that occur between clock edges do not affect the outputs immediately. Moore outputs are glitch-free and synchronize cleanly with downstream logic.

Mealy Output Timing

Mealy outputs respond immediately when input signals transition, even between clock edges.

This immediate response provides faster reaction times (often one cycle earlier than a Moore machine).

However, combinational noise or glitches on input signals propagate directly to Mealy outputs. If an unbuffered Mealy output drives an asynchronous clear or write-enable pin, false assertions can corrupt system data.

State Requirements

A Mealy machine generally requires fewer states than an equivalent Moore machine.

A Moore machine must assign a unique state for every distinct output combination. A Mealy machine can generate different output combinations from a single state by evaluating different input conditions.

This state reduction frequently saves flip-flops and reduces next-state combinational gating.

The Registered Mealy Architecture

To combine the state efficiency of a Mealy machine with the glitch-free operation of a Moore machine, designers use the registered Mealy architecture.

In this architecture, combinational Mealy logic evaluates the next output values. Dedicated output flip-flops capture these values on the clock edge.

Downstream circuits receive clean, clock-aligned outputs with zero combinational glitches.

Comparison Summary

Metric Moore Architecture Mealy Architecture Registered Mealy
Output Stability Clock-aligned and glitch-free Combinational (susceptible to input glitches) Clock-aligned and glitch-free
State Count Higher Lower Lower
Output Latency One clock cycle after state entry Same clock cycle as input transition One clock cycle after input transition
Primary Applications Safety controllers, bus interfaces High-speed protocol parsers Production RTL control units

Second Example: Sequence Detector for Pattern “10”

Both machines detect the serial bit sequence 10:

  • The Moore machine requires four states (Figure 5).
  • The Mealy machine requires two states (Figure 6).

Moore 10 detector
Figure 5: Moore state diagram for detecting binary sequence 10

Mealy 10 detector
Figure 6: Mealy state diagram for detecting binary sequence 10

The Mealy machine asserts its output in the same clock cycle that the 0 arrives, reducing output latency by one cycle.

Practice Exercises

Problem 1

A Moore implementation requires 6 states. An equivalent Mealy implementation requires 4 states. Calculate the number of flip-flops required for binary state encoding in both implementations.

Solution

Calculate the required register width $n = \lceil \log_2 N \rceil$:

  • Moore machine: $\lceil \log_2 6 \rceil = 3$ flip-flops.
  • Mealy machine: $\lceil \log_2 4 \rceil = 2$ flip-flops.

The Mealy implementation saves one state flip-flop and simplifies next-state decoding logic.

Problem 2

An asynchronous memory write enable pin connects directly to a combinational Mealy output. Explain why this configuration introduces reliability risks.

Solution

Mealy outputs contain a direct combinational path from inputs.

Any electrical noise, crosstalk, or intermediate hazard glitch on input signals propagates immediately to the write enable pin. A false glitch on a write enable pin can overwrite or corrupt memory contents asynchronously.

Designers must register the write enable signal or use a Moore architecture for asynchronous control interfaces.

Problem 3

Convert the two-state Mealy 10 detector into a registered Mealy machine. Compare its latency to the Moore implementation.

Solution

Insert an edge-triggered D flip-flop at the output of the Mealy output logic block:

  1. The combinational Mealy logic evaluates the output pulse when the 0 bit arrives.
  2. The output flip-flop captures this value on the next rising clock edge.
  3. The registered output asserts for one clock cycle following the edge.

The registered Mealy machine has the same one-cycle latency as the Moore machine. However, it requires only two internal states instead of four.

The next article explains standard notations for drawing state diagrams and constructing state transition tables.

← What a State Machine Is State Diagrams and State Tables →