Skip to content
BetterDL

State

Also called: present state, current state, machine state

A summary of everything a sequential circuit needs to remember about its past inputs, stored in flip-flops, that decides how it responds next.

A state is the circuit's memory, boiled down to what matters. A combinational circuit only sees its inputs right now. A sequential circuit also carries a state, held in flip-flops, which sums up the past.

The key idea is summary. A machine doesn't store its whole input history, only the part that can still affect what it does:

  • A turnstile needs two states: Locked or Unlocked.
  • A machine that spots two 0s in a row needs three: "no 0 yet", "one 0" and "two or more 0s".
  • A machine that tracks the number of 1s mod 3 needs three: remainder 0, 1 or 2, however long the input is.

The state the machine is in now is the present state. At each active clock edge it moves to the next state, chosen by the present state and the inputs. In a state diagram each state is a circle; in a state table each is a row.

When you design a finite state machine, start by writing in words what each state remembers. If two states would remember the same thing, they're probably equivalent states.

start010101no 00one 00two 0s1

Worked example

Example

How many states?

Ask: what is the least I must remember to decide what happens next?

  1. 1.

    Output 1 when the last input was 1: remember the last bit → 2 states.

  2. 2.

    Output 1 when the last two inputs were 0, 0 (the diagram): no 0 yet, one 0, two or more 0s → 3 states.

  3. 3.

    Output 1 when the number of 1s so far is a multiple of 4: remainder 0, 1, 2 or 3 → 4 states.

  4. 4.

    Output 1 when the last three bits were 110: nothing, seen 1, seen 11, seen 110 → 4 states (as a Moore machine).

Common mistakes

  • Trying to remember the whole input history. A state only needs what can still change the future.

  • Confusing a state with an output. Several states can share an output value; the state is what the machine remembers.

  • Forgetting that the state is physically stored. Every state needs a distinct pattern in the flip-flops.

Practice State

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

State is taught in Finite State Machines.