FSM Sequence Detector (101 and 1101) in Logisim-evolution: Mealy vs Moore State Machines

Direct Answer: Designing an FSM Sequence Detector in Logisim-evolution

A Sequence Detector is a synchronous Finite State Machine (FSM) that monitors a 1-bit serial input stream (X) and asserts output Z = 1 whenever a target bit pattern such as 101 or 1101 arrives. A Mealy machine computes its output from both the present state and current input X, requiring $N$ states for an $N$-bit sequence (3 states for 101, 4 states for 1101) and asserting Z = 1 immediately in the same cycle. A Moore machine derives its output strictly from the registered present state, requiring $N+1$ states (4 states for 101, 5 states for 1101) while guaranteeing glitch-free synchronous outputs.

Recommended FSM Design Textbooks and FPGA Synthesis Boards

Finite State Machines power every protocol parser, memory controller, and CPU control unit. Pair Logisim-evolution’s state table synthesis with these industry-standard resources:

FSM Design Standard

Digital Design & Computer Architecture

By David Harris & Sarah Harris. Dedicates an entire chapter to Mealy vs. Moore state encoding, next-state Karnaugh minimization, and Verilog/VHDL FSM templates.

Publisher: Morgan Kaufmann • Essential Coursework Reference
View Textbook on Amazon →
Physical Hardware Target

Digilent Basys 3 Artix-7 FPGA

Synthesize your sequence detector onto physical silicon using onboard pushbuttons for X and CLK and LEDs to indicate live state transitions.

Price: ~$165 USD • Native Logisim FPGA Commander Support
Check Basys 3 on Amazon →

Comparing Mealy and Moore Sequence Detector Architectures

Before drawing a state diagram, select between a Mealy or Moore architecture and decide whether overlapping sequences are allowed:

Evaluation Dimension Mealy State Machine Moore State Machine
Output Dependency $Z = f(\text{Present State}, X)$ $Z = f(\text{Present State})$ only
States for 101 Detector 3 states (2 flip-flops) 4 states (2 flip-flops)
States for 1101 Detector 4 states (2 flip-flops) 5 states (3 flip-flops)
Detection Latency Immediate (0 cycle delay on final bit) 1 clock cycle after final bit latches
Glitch Resistance Susceptible to input X glitches Glitch-free (Synchronous state output)

State Transition Table for an Overlapping 1101 Moore Detector

In an overlapping detector, the trailing 1 of 1101 simultaneously acts as the first 1 of a subsequent 1101 sequence (for example, stream 1101101 asserts Z = 1 twice). Below is the complete 5-state Moore transition table:

Present State Code (Q2 Q1 Q0) Matched Prefix Next State (X = 0) Next State (X = 1) Output (Z)
S0 (Idle) 000 None S0 (000) S1 (001) 0
S1 001 1 S0 (000) S2 (010) 0
S2 010 11 S3 (011) S2 (010) 0
S3 011 110 S0 (000) S4 (100) 0
S4 (Detected) 100 1101 S0 (000) S2 (010) [Overlap!] 1

Two Proven Methods to Build Sequence Detectors in Logisim

You can implement any state transition table in Logisim-evolution using either minimized Boolean gates or a clean ROM lookup table:

Method A: Discrete D Flip-Flops and Combinational Analysis

  1. Open Window → Combinational Analysis. Define inputs Q2, Q1, Q0, X and outputs D2, D1, D0, Z.
  2. Enter the next-state rows from the table above (setting unused states 101, 110, 111 to transition safely back to 000).
  3. Click Build Circuit to synthesize the minimized next-state logic, then wire D2, D1, D0 into a 3-bit Register whose output Q[2:0] feeds back to the combinational inputs.

Method B: ROM-Based State Machine (Cleanest Architecture)

Combine the 3-bit state register output Q[2:0] and 1-bit input X into a 4-bit ROM address bus ({Q2, Q1, Q0, X}). Configure a 16×4-bit ROM whose 4-bit data output directly encodes {Z, D2, D1, D0}. Updating the sequence from 1101 to 1011 requires changing only a few hex bytes in the ROM rather than rewiring logic gates.

Frequent Traps in Sequence Detector State Machines

Avoid these four classic mistakes when debugging your FSM in Logisim:

Trap 1: Incorrect Overlap Transition After Detection

Problem: Returning from S4 (1101) back to S0 when X = 1 misses overlapping matches like 1101101.
The Fix: In S4, the last two bits received are ...01; if the next bit is X = 1, the suffix is 11, so transition to S2, not S0 or S1.

Trap 2: Don’t-Care Lockup in Unused Binary States

Problem: Marking unused 3-bit states (101, 110, 111) as Don’t-Cares (X) can accidentally synthesize a closed loop trapping the FSM permanently if noise occurs.
The Fix: Explicitly map all unused states to return to S0 (000) for self-recovering hardware.

Trap 3: Self-Looping on Repeated 1s in S2

Problem: Sending S2 (matched 11) back to S0 when X = 1 fails on streams like 11101.
The Fix: When in S2 (11) and X = 1 arrives, the trailing two bits are still 11, so S2 must loop to itself!

Trap 4: Toggling Input X After the Clock Edge

Problem: In a Mealy machine, toggling X manually while testing changes output Z asynchronously before the clock even ticks.
The Fix: Set X to the desired bit before ticking the clock, or feed X from a synchronous Shift Register driven by the same clock.

Curriculum Progression from Sequence Detectors to Control Units

Apply your finite state machine skills to real-world hardware controllers and processors:

Frequently Asked Questions About FSM Sequence Detectors

Can I build a sequence detector using a Shift Register instead of an FSM?

Yes, for fixed-length bit patterns! Feed the serial stream into a 4-bit SIPO Shift Register and wire an AND gate checking Q3 & Q2 & ~Q1 & Q0 to detect 1101. However, FSMs are far more memory-efficient for long patterns or complex protocol handshakes.

Why does a Moore machine need one more state than a Mealy machine?

Because a Moore output depends solely on the stored state, the machine must enter a dedicated final state (e.g., S4) after the last bit arrives just to assert Z = 1. A Mealy machine asserts Z = 1 on the transition arc leaving S3, eliminating the extra state.

What is the difference between overlapping and non-overlapping sequence detection?

In a non-overlapping detector, once 101 is detected, the machine resets completely to S0, ignoring the final 1. In an overlapping detector, the final 1 of 101 is reused as the first 1 of a new 101 match (so 10101 triggers twice).

Should I use Binary or One-Hot state encoding in Logisim-evolution?

Use Binary encoding (3 flip-flops for 5 states) when minimizing flip-flop count for coursework K-maps. Use One-Hot encoding (5 flip-flops for 5 states) when exporting Verilog/VHDL to FPGAs, where flip-flops are abundant and simple decoding maximizes clock frequency.

Affiliate Disclosure: Logisim-evolution Community is an independent educational resource. Some links in this guide are affiliate links. If you purchase textbooks or FPGA hardware through these links, we may earn an affiliate commission at no extra cost to you.

Similar Posts