3.4.11Sequential Circuits

State diagram and state table design

2,141 words10 min readdifficulty · medium

WHY do we need states at all?

WHY this matters: A combinational circuit's output depends only on current inputs. A sequential circuit's output depends on current inputs plus history. We encode "history" into a finite set of labels (states), so the circuit only ever needs to store which state it is in, not the whole input stream.


Mealy vs Moore — WHAT is the difference?


HOW to design: the recipe

This note focuses on steps 1–5 (the "capture the behaviour" half). Steps 6+ (K-maps, flip-flop excitation) come later.

Figure — State diagram and state table design

Worked Example 1 — "1011" sequence detector (Mealy, overlapping)

Spec: Output Z=1Z=1 for one cycle whenever the input serial bit stream XX ends in the pattern 1011. Overlapping allowed (the last bits of one match can start the next).

Step 1 — WHAT must we remember?

We only care about how much of the target prefix we have seen so far. Define states by the longest prefix of 1011 currently matched:

  • S0S_0 = matched nothing (or a useless prefix)
  • S1S_1 = matched 1
  • S2S_2 = matched 10
  • S3S_3 = matched 101

Why this step? These four prefixes are the only facts about the past that change what a future bit means. Any longer history is irrelevant → finite states.

Step 2 — build transitions (Forecast-then-Verify)

At S3S_3 (101 seen), if next bit is 1 → we complete 1011 → output Z=1Z=1. Forecast: where do we go after matching? Because overlap is allowed, the trailing 1 of 1011 is itself a fresh 1 prefix → go to S1S_1, not S0S_0. Verify: input 10111011 — check it detects two matches. It does. ✅

Let's reason each transition. On input bit XX:

Present X=0 → Next / Z X=1 → Next / Z Why?
S0S_0 S0S_0 / 0 S1S_1 / 0 a 1 starts a possible match
S1S_1 (1) S2S_2 / 0 S1S_1 / 0 10 progresses; 11 still ends in one 1
S2S_2 (10) S0S_0 / 0 S3S_3 / 0 100 dead → S0S_0; 101 progresses
S3S_3 (101) S2S_2 / 0 S1S_1 / 1 1010 ends in 10S2S_2; 1011 = MATCH, overlap leaves 1

Step 3 — state assignment

Pick S0=00,  S1=01,  S2=10,  S3=11S_0=00,\;S_1=01,\;S_2=10,\;S_3=11. Now every "Next" entry becomes a 2-bit number, ready for flip-flop equations.


Worked Example 2 — Moore version of the same detector

In Moore, the output belongs to a state, so we need an extra "accept" state S4S_4 that outputs 1.

Present Output X=0 → Next X=1 → Next Why?
S0S_0 0 S0S_0 S1S_1
S1S_1 0 S2S_2 S1S_1
S2S_2 0 S0S_0 S3S_3
S3S_3 0 S2S_2 S4S_4 on 1 we reach the match state
S4S_4 1 S2S_2 S1S_1 behaves like S1S_1 for future input (it holds a 1), but outputs 1

Common mistakes


Active recall

Recall What is a "state", in one line?

A finite label summarizing exactly the part of past input needed to decide future outputs & transitions.

Recall Why can Mealy machines often use fewer states than Moore?

Because Mealy attaches the output to transitions, so it doesn't need a separate state just to display an output.

Recall After detecting

1011 with overlap, why go to S1S_1 not S0S_0? The trailing 1 is a valid prefix of a new 1011; going to S0S_0 would discard it and miss overlapping matches.

Recall (Feynman) Explain state design to a 12-year-old.

Imagine a lock that opens only if you press 1, 0, 1, 1 in order. The lock can't remember every button you ever pressed — that's too much. Instead it keeps a tiny sticky note saying "how far along the secret code am I?" Each note ("nothing yet", "got the 1", "got 1-0", "got 1-0-1") is a state. When a button is pressed, the lock updates the sticky note and, if it just finished the code, it pops open. A state diagram is just a map of all the sticky notes with arrows showing which button leads where.


Connections

  • Finite State Machines — the abstract model behind these diagrams
  • Flip-Flops and Latches — the physical memory that stores the state bits
  • State Assignment and Reduction — choosing codes & merging equivalent states
  • Excitation Tables and Next-State Equations — steps 6+ of the recipe
  • Sequence Detectors — the canonical application
  • Combinational Circuits — contrast: no memory, no states
What summarizes the past in a sequential circuit?
A state — the minimal memory of history needed to decide future output and next state.
In a Moore machine, output depends on what?
The present state only (written inside the state bubble).
In a Mealy machine, output depends on what?
Present state AND current input (written on the transition arrow as input/output).
Where is the output written in a Mealy state diagram?
On the transition arrow, as X/Z.
Where is the output written in a Moore state diagram?
Inside the state bubble.
Why does a sequence detector for '1011' with overlap return to the '1' state after a match?
The trailing 1 is a valid prefix of the next 1011, so overlap needs it (going to start would miss matches).
List the 6 steps of state-machine design.
1) Understand spec 2) Identify states 3) Draw state diagram 4) Build state table 5) State assignment (binary codes) 6) Derive next-state/output equations & pick flip-flops.
Why does Moore usually need ≥ as many states as Mealy?
Moore needs extra states just to display each output value, since output is tied to states not transitions.
What makes a state table 'complete'?
Every (present-state, input) combination has a defined next-state (and output) entry.
For '1011' Mealy detector, how many states are needed?
4 (matched: nothing, 1, 10, 101).

Concept Map

collapse into

drawn as

written as

same info as

output on state only

output on state plus input

glitch-free, one clock late

faster, fewer states

assign binary codes

later derive

example

states = matched prefixes

Infinite history

Finite states

State diagram

State table

Moore machine

Mealy machine

Design tradeoff

State assignment

Next-state and output equations

1011 detector (Mealy)

Hinglish (regional understanding)

Intuition Hinglish mein samjho

Dekho, sequential circuit ka matlab hai ek aisa circuit jo past yaad rakhta hai. Lekin poora history yaad rakhna impossible hai — infinite memory chahiye. Isliye hum ek smart trick use karte hain: saari possible histories ko chhote-chhote labels me squeeze kar dete hain, jinko hum state kehte hain. Har state basically ek sticky note hai jo bolta hai "abhi tak main kitna aage pahunch gaya hoon". Yehi core idea hai.

State diagram ek map hai — circles matlab states, aur arrows matlab input aane par kahan jaana hai. State table wahi cheez table form me hai: rows = present state, columns = input, aur andar likha hai next state aur output. Dono same information, bas alag look.

Ek important cheez: Moore vs Mealy. Moore me output state ke andar likha jaata hai (circle me), matlab output sirf state pe depend karta hai. Mealy me output arrow pe likha jaata hai (X/Z form), matlab output state + current input dono pe depend karta hai. Isliye Mealy usually kam states me kaam kar leta hai, par Moore glitch-free aur stable hota hai. Yaad rakho: "MOORE = Output On Resting spot, MEALY = output Meets you en-route."

Sabse badi galti jo students karte hain: 1011 detect karne ke baad wapas start state S0S_0 pe chale jaana. Yeh galat hai jab overlapping allowed ho, kyunki 1011 ka last 1 naye pattern ka pehla 1 ban sakta hai. Isliye match ke baad S1S_1 pe jaana hai, S0S_0 pe nahi. Ye chota sa point exams me bahut baar puchha jaata hai — dhyan rakhna!

Go deeper — visual, from zero

Test yourself — Sequential Circuits

Connections