Introduction

A synchronous sequential circuit combines combinational logic with edge-triggered flip-flops sharing a common clock. Its behaviour is a finite state machine (FSM): present state and inputs determine outputs and next state. Mealy machines let outputs depend on inputs and state; Moore machines let outputs depend on state only.

GATE asks you to analyse a given circuit into a state table, design sequence detectors (overlapping or not), count the states and flip-flops a machine needs, reduce a state table, and derive flip-flop input equations.

Prerequisites

Core concepts

Model

  • State register: kk FFs encode up to 2k2^k states, so ss states need ⌈lg⁡s⌉\lceil \lg s \rceil FFs with binary encoding, or ss FFs with one-hot encoding.
  • Next-state logic: combinational map (state,input)↦next state(\textit{state},\textit{input})\mapsto\textit{next state}.
  • Output logic: Mealy (state,input)↦out(\textit{state},\textit{input})\mapsto\textit{out} or Moore state↦out\textit{state}\mapsto\textit{out}.

Design procedure

  1. Word specification to state diagram (or ASM chart).
  2. State table; reduce equivalent states if asked.
  3. Assign binary codes to states.
  4. Choose FF type; derive excitation inputs from present/next bits.
  5. Minimize excitation and output Boolean functions; implement.

Sequence detectors

Classic: detect overlapping or non-overlapping patterns such as 11011101 on a serial input. Each state records the longest prefix of the pattern that is also a suffix of the input seen so far.

  • Overlapping: after a match, the machine keeps the longest proper suffix of the pattern that is also a prefix. For 11011101, after a match the last bit 1 is kept, so the stream 11011011101101 holds two matches (ending at bits 4 and 7).
  • Non-overlapping: after a match the machine returns to the start state, and the same stream holds one match.

State counts for a pattern of length nn. A minimal Mealy detector has nn states (prefix lengths 00 to n−1n-1); the output 1 sits on the arc that completes the pattern. A minimal Moore detector has n+1n+1 states, because "just matched" must be a state of its own with output 1. For 11011101: 4 Mealy states (2 FFs) and 5 Moore states (3 FFs).

Mealy versus Moore

MealyMoore
Output depends onstate and inputstate only
Reactioncan change asynchronously with input (still sampled if registered)changes on clock with state
Statesoften feweroften more

Timing difference. In this detector example, the unregistered Mealy output uses the pre-update state and current input and may assert on the final input symbol; the current-state Moore output appears after the edge entering the matching state. Calling this a one-cycle shift depends on the sampling convention. Equivalent Mealy/Moore realizations do not have a universal one-clock lag from their definitions alone.

Mealy and Moore state diagrams for a sequence detector
Figure 1. Mealy (left) and Moore (right) diagrams detecting input sequence 11 with overlap; Moore places the output label inside states.

How it works

Analysis

From a schematic: write FF excitation equations, apply characteristics to get next-state maps, build the state table, draw the diagram. With D flip-flops the next state equals the D inputs; with JK or T, substitute into Q+=JQ′+K′QQ^+ = JQ' + K'Q or Q+=T⊕QQ^+ = T \oplus Q first.

State reduction

Two states are equivalent if they produce the same output sequences for every input sequence. Equivalent states can be merged without changing the behaviour seen from outside.

Partition refinement. Start with blocks of states that have the same output row. Repeatedly split a block when two of its states move, on some input, to different blocks. Stop when nothing splits; each block is one state of the minimal machine. Identical rows (same outputs and same next states) are only the easy case: two states can be equivalent even when their next states differ, as long as those next states are themselves equivalent. The implication-chart method finds the same result.

State assignment

Binary encoding uses the fewest FFs. Gray-adjacent codes for states that transition into each other can reduce logic and avoid some simultaneous bit flips. One-hot encoding uses one FF per state: the next-state logic is simple, but the FF count equals the state count. Unused codes (for example 1 of 4 codes when 3 states use 2 FFs) may be treated as don't-cares in the excitation maps, or given a transition back into the used states so that the machine cannot stay stuck there after a glitch.

Algorithms and pseudocode

Arrays and states are 0-indexed; <- is assignment.

Text
SEQ-DESIGN(diagram, FFtype)
1  table <- state table from diagram
2  assign binary codes to states
3  for each FF bit
4      derive required Q+ from codes
5      set excitation from excitation table of FFtype
6  minimize excitation and output functions
7  return gate network plus FF bank

REDUCE(states, inputs, next, out)          // partition refinement
1  block[s] <- class of the output row out[s][.] for every s
2  repeat
3      key[s] <- (block[s], block[next[s][x]] for every input x)
4      newblock[s] <- class of key[s]
5      changed <- (number of classes grew)
6      block <- newblock
7  until not changed
8  return block                            // one state per class

DETECTOR-NEXT(pattern P, k, bit b)         // overlapping, Mealy
1  w <- P[0..k-1] followed by b
2  if w = P then output 1 and use w <- w without its first symbol
3  return length of the longest suffix of w that is a prefix of P

REDUCE does O(s⋅∣Σ∣)O(s \cdot |\Sigma|) work per round with hashing, for ss states.

  • Best case: 1 round. This happens when the first refinement adds no class, for example when the output rows already separate every state, or when all states have the same output rows (then all of them are equivalent).
  • At most max⁡(1,s−1)\max(1,s-1) rounds for s≥1s\ge1, hence O(s2∣Σ∣)O(s^2|\Sigma|) overall. For s≥2s\ge2, a chain attains s−1s-1: input 1 advances state ii to i+1i+1 (last stays put), input 0 stays put, and only the last state outputs 1 on input 1. Each round splits off another state; the final no-change check is included.
  • There is no useful average case; it depends on the machine. For a non-overlapping detector, line 2 of DETECTOR-NEXT returns state 0 instead.

Mathematical explanation

A deterministic FSM is (Q,Σ,δ,q0,Λ)(Q,\Sigma,\delta,q_0,\Lambda) with output function Λ\Lambda either Q→ΓQ\to\Gamma (Moore) or Q×Σ→ΓQ\times\Sigma\to\Gamma (Mealy). Encoding injects QQ into {0,1}k\{0,1\}^k, so k≥⌈lg⁡∣Q∣⌉k \ge \lceil \lg |Q| \rceil. Related TOC view: Deterministic Finite Automata omits binary encoding and gates.

Why the Mealy detector needs exactly nn states. The prefix states 0,1,…,n−10, 1, \ldots, n-1 are pairwise distinguishable. For i<ji < j, feed the n−jn - j bits P[j..n−1]P[j..n-1]. From state jj the last of them completes a match. From state ii the matched prefix can reach at most i+n−j<ni + n - j < n, so there is no match. Fewer than nn states would merge two of them.

Worked examples

Example 1: detect 1111 (Mealy, overlap)

States AA (no progress), BB (last bit 1). From AA: input 0 to AA out 0; input 1 to BB out 0. From BB: input 1 to BB out 1; input 0 to AA out 0.

The Moore version needs three states: S0S_0 with output 0 (no progress), S1S_1 with output 0 (last bit 1), S2S_2 with output 1 (last two bits 11). Input 1 moves S0→S1→S2→S2S_0 \to S_1 \to S_2 \to S_2; input 0 returns every state to S0S_0. During the four cycles of input 01110111, the Mealy output is 00110011. The Moore output (the label of the present state) is 00010001 and stays 1 in the fifth cycle: the same response one cycle later.

Example 2: Moore 11 detector with D flip-flops

Encode S0=00S_0 = 00, S1=01S_1 = 01, S2=10S_2 = 10 as Q1Q0Q_1Q_0; code 11 is unused (don't-care). Next state: input x=0x = 0 gives 00 from every state; x=1x = 1 gives 0101 from S0S_0 and 1010 from S1S_1 and S2S_2. Using the don't-cares,

D1=xQ1+xQ0,D0=x Q1′Q0′,z=Q1.D_1 = xQ_1 + xQ_0,\qquad D_0 = x\,Q_1'Q_0',\qquad z = Q_1 .

Neither equation can shrink: D0D_0 has a single on-set row (001), and the don't-cares 110 and 111 are not adjacent to it.

Example 3: analysis of a D flip-flop circuit

DA=Ax+BxD_A = Ax + Bx, DB=A′xD_B = A'x, output y=(A+B)x′y = (A + B)x'. Evaluating every row:

ABABNext, x=0x = 0Next, x=1x = 1yy, x=0x = 0yy, x=1x = 1
00000100
01001110
10001010
11001010

The rows for 10 and 11 are identical, so those two states merge. After that merge, state 01 also matches: it goes to 00 on x=0x = 0 and to 11, now the same state as 10, on x=1x = 1, with the same outputs. The minimal machine has only two states: 00 (last input 0, or reset) and {01,10,11}\{01, 10, 11\} (last input 1), with y=1y = 1 exactly on a 1 followed by 0. Stopping after the first merge, at three states, is the usual mistake. It is a Mealy machine because yy depends on xx.

Example 4: reduction that needs refinement

StateNext, x=0x = 0Next, x=1x = 1Out, x=0x = 0Out, x=1x = 1
AAB00
BCB00
CAD01
DED00
EAB01

By outputs: {A,B,D}\{A, B, D\} and {C,E}\{C, E\}. Refining: on x=0x = 0, AA goes to AA (first block) while BB and DD go to CC and EE (second block), so AA splits off. Now {A},{B,D},{C,E}\{A\}, \{B, D\}, \{C, E\}: BB and DD go to {C,E}\{C, E\} and to {B,D}\{B, D\}; CC and EE go to AA and to {B,D}\{B, D\}. Nothing splits, so the minimal machine has 3 states, even though no two rows of the original table are identical. The input 0101 separates AA from BB: AA outputs 0000, BB outputs 0101.

Example 5: overlapping and non-overlapping 11011101

Mealy states S0S_0 to S3S_3 hold the matched prefix length.

Statex=0x = 0x=1x = 1
S0S_0S0S_0/0S1S_1/0
S1S_1S0S_0/0S2S_2/0
S2S_2S3S_3/0S2S_2/0
S3S_3S0S_0/0S1S_1/1

S2S_2 on 1 stays in S2S_2 (the input 111111 still ends in 1111). The overlapping detector goes from S3S_3 on 1 to S1S_1, keeping the final 1; the non-overlapping one goes to S0S_0. On 11011011101101, the outputs are 00010010001001 (overlapping) and 00010000001000 (non-overlapping).

Example 6: overlapping detector for 101101

States: S0S_0 (start), S1S_1 (got 1), S2S_2 (got 10). Mealy outputs 1 on the transition that completes 101101. From S2S_2, input 1 goes to S1S_1 (the last 1 begins a new pattern); from S2S_2, input 0 goes to S0S_0; from S1S_1, input 1 stays in S1S_1. On 1010110101 the output is 0010100101.

Example 7: unused states

With 3 states in 2 FFs, one code is unused; treat as don't-care next state or force a recovery transition as the question requires.

Important properties and observations

  • All FFs share one clock in the synchronous model; no ripple between state bits for the state register (counters may still ripple; see Registers and Counters).
  • Self-loops and overlapping detections are common pitfalls in diagrams.
  • Output glitches in Mealy machines: if outputs feed asynchronous logic, prefer registered Moore outputs.
  • Flip-flop count: ⌈lg⁡s⌉\lceil \lg s \rceil binary, ss one-hot; 5 states need 3 FFs binary.

Common misconceptions.

  • "Mealy always uses fewer states." Often, not always; for detectors it saves exactly one.
  • "Next state depends only on input." It depends on present state too.
  • "Only identical rows can be merged." Partition refinement merges states whose next states are equivalent, not identical.
  • "The Moore and Mealy outputs rise in the same cycle." For the shown pre-edge Mealy/current-state Moore convention, assertion occurs on opposite sides of the state-update edge; whether this is an extra cycle depends on sampling, not the definitions alone.

GATE examination perspective

  • DRAW THE DIAGRAM. Label transitions as input/outputinput/\textit{output} (Mealy) or inputs on arcs and outputs in bubbles (Moore).
  • STATE AND FF COUNTS. Length-nn detector: nn Mealy, n+1n + 1 Moore states; FFs ⌈lg⁡s⌉\lceil \lg s \rceil.
  • EXCITATION MAPS. From state codes to D/T/JK inputs, with unused codes as don't-cares.
  • OVERLAP. For sequence 11011101, decide whether overlapping is required.
  • REDUCTION. Partition by outputs, then refine by next-state blocks.
  • UNUSED STATES. Don't-cares versus safe recovery.

Summary

Sources

  1. M. Morris Mano, M. D. Ciletti, Digital Design, 5th ed., Pearson, 2013: Chapter 5, Sections 5.5, 5.7 and 5.8 (analysis of clocked sequential circuits; state reduction and assignment; design procedure).

Next steps