A topic in the Open Knowledge Graph — a free, open map of 15,290 topics and the order to learn them in.

Finite State Machines (FSMs)

College Depth 78 in the knowledge graph I know this Set as goal
535topics build on this
329prerequisites beneath it
See this on the map →
Combinational Circuit DesignFlip-Flops and Latches+3 moreBehavior-Based Robotics and Reactive ControlCPU Control Unit+5 more
FSM Moore Mealy sequential-logic state-machine

Core Idea

A finite state machine (FSM) is a model of a sequential system with a finite number of discrete states. At each clock edge, the system transitions to a next state determined by the current state and the inputs (next-state logic). Outputs are produced either as a function of the current state only (Moore machine) or of both state and inputs (Mealy machine). FSMs are implemented in hardware using flip-flops to hold state and combinational logic for the transition and output functions, and they model everything from traffic lights to CPU control units.

How It's Best Learned

Design FSMs for simple problems like a sequence detector or vending machine controller. Draw the state diagram, derive the state transition table, assign binary encodings, and implement with flip-flops and combinational logic. Verify with timing diagrams.

Common Misconceptions

Explainer

A combinational circuit computes a pure function of its current inputs — it has no memory of what happened before. This is powerful but limiting. Real-world controllers — traffic lights, elevator controllers, CPU control units — need to remember where they are in a sequence. That is exactly what a finite state machine adds: a finite set of discrete states that summarize all the history the system needs.

An FSM is defined by five elements: a set of states, an input alphabet, a transition function (current state + input → next state), an output function, and an initial state. The state diagram is the most intuitive representation: circles are states, arrows are transitions labeled with inputs (and sometimes outputs). When you design an FSM for a problem, you start with the state diagram — drawing out every situation the system needs to distinguish — before thinking about gates.

The two classic variants differ in where outputs are placed. In a Moore machine, each state has a fixed output label; the output depends only on the current state. In a Mealy machine, outputs are labels on transitions; the output depends on both the current state and the current input. Moore machines are easier to reason about and produce glitch-free outputs (since outputs only change at clock edges when state changes). Mealy machines typically require fewer states to achieve the same behavior because a single state can emit different outputs depending on the input. Both models are equally powerful — you can always convert one to the other.

Hardware implementation connects directly to your combinational circuit design knowledge. The FSM has two parts: (1) next-state logic — a combinational circuit that takes the current state bits and inputs and computes what state to move to; and (2) output logic — another combinational circuit (or a direct wiring for Moore outputs) that produces the outputs. The current state is held in a register of flip-flops, one per state bit. At every rising clock edge, the flip-flops capture the next-state logic's output and the system advances to the new state.

When implementing, you must also choose a state encoding — how to represent each state as a binary number stored in the flip-flops. Binary encoding uses the minimum number of flip-flops (⌈log₂ n⌉ for n states), while one-hot encoding uses one flip-flip per state (exactly one flip-flop is 1 at all times). Binary encoding is more compact; one-hot encoding produces simpler next-state logic because checking "are we in state X?" is just reading a single flip-flop. The choice affects the complexity of your combinational logic but not the FSM's observable behavior.

Practice Questions 3 questions

Prerequisite Chain

Understanding ZeroThe Number ZeroCounting to FiveCounting to 10Counting to 20Counting a Set of Objects Up to 20Cardinality: The Last Number CountedMatching Numerals to QuantitiesSubitizing Small QuantitiesAddition Within 10Number Bonds to 10Addition Within 20Doubles and Near DoublesDoubles Facts Within 10Near Doubles Facts Within 20Mental Math Strategies for AdditionMental Math: Adding and Subtracting TensAddition Within 100Repeated Addition as MultiplicationMultiplication as Equal GroupsMultiplication: ArraysBasic Multiplication Facts (0s, 1s, 2s, 5s, 10s)Multiplication Facts Within 100Division as Equal SharingDivision as Grouping (Measurement Division)Division: Grouping (Repeated Subtraction) ModelDivision: Fair Sharing ModelDivision as Equal SharingDivision as GroupingBasic Division FactsDivision Facts Within 100Multiplication and Division Fact FamiliesRelationship Between Multiplication and DivisionDivision Facts as Inverse of MultiplicationRemainders and Quotients in DivisionDivision Word ProblemsMulti-Step Word ProblemsSolving Multi-Step Word ProblemsMultiplication Word ProblemsDivision Word ProblemsIntroduction to Long DivisionFactors and MultiplesPrime and Composite NumbersEquivalent FractionsRelating Fractions and DecimalsDecimal Place ValueIntegers and the Number LineComparing and Ordering IntegersAbsolute ValueAdding IntegersSubtracting IntegersMultiplying IntegersIntroduction to ExponentsOrder of OperationsInteger Order of OperationsVariable ExpressionsThe Distributive PropertyVariables and Expressions ReviewIntroduction to PolynomialsAdding and Subtracting PolynomialsMultiplying PolynomialsFactorialPermutationsCombinationsCounting Principles: Addition and Multiplication RulesIntroduction to Graph TheoryPropositional Logic FoundationsLogical EquivalencesBoolean AlgebraBoolean Type and Truth ValuesComparison Operators and Boolean TestsLogical Operators and Boolean AlgebraBoolean Algebra and Fundamental LawsLogic Gates FundamentalsImplementing Boolean Functions with GatesKarnaugh Map SimplificationCombinational Circuit DesignFlip-Flops and LatchesFinite State Machines (FSMs)

Longest path: 79 steps · 329 total prerequisite topics

Prerequisites (5)

Leads To (7)