From Diagram to State Table
How to turn a sequence-detector state diagram into a complete state table, including the transitions where a partial match has to reset.
Updated 2026-07-21
A state diagram and a state table describe the exact same FSM in two different shapes. The diagram shows states as circles and transitions as labeled arrows; the table lists the same information as rows — one row per (current state, input) pair, with the next state it leads to.
Take a detector watching for the pattern 1001 on a serial input. Each state represents how much of the pattern has been matched so far by the bits most recently seen: A0 for no match, A1 for "1", A2 for "10", A3 for "100". Reading the diagram one arrow at a time gives one table row at a time — from A2 (matched "10"), an arrow labeled 0 points to A3, because "100" is one bit closer to the full pattern.
The row most learners get wrong is the "partial match resets" case — and the trap is that two rows can look almost identical while behaving completely differently. From A3 (matched "100"), an arrow labeled 0 does not continue forward — it points all the way back to A0. The reason is in the bits themselves: "100" followed by "0" gives "1000", and no prefix of "1001" matches the end of that string at any length, so none of the progress survives. Compare that with A1 (matched "1"): a 0 there gives "10", which IS the start of "1001" — two characters of progress survive, landing on A2, not a reset at all. Both rows start from a partial match and both see the same input, but only one of them actually resets; reading the row correctly means re-deriving it from the bits every time, not pattern-matching on "partial match plus a 0 usually means reset."
The rule that decides every row is always the same: take the bits matched so far, add the new bit, and ask what the longest prefix of the target pattern is that still matches the END of that string. Whatever length that prefix is, that is the next state. When no prefix matches at all, the answer is always the reset state — regardless of how much progress had already been made.