Finite State Machine
A Finite State Machine (FSM) is the fundamental design pattern for any digital circuit that has memory(sequential logic). If a circuit's output depends not just on the current inputs, but also on the sequence of past inputs, you need an FSM.
The core idea is state.
A "state" is a snapshot of the system's history—it's the memory of what has happened before. An FSM is a system that can only be in a limited (finite) number of these states. It moves from one state to another based on its inputs and a clock signal.
Think of an FSM as the "brain" or "control unit" for a sequential process.
The Core Anatomy of an FSM
Every synchronous FSM is built from three essential parts. Understanding these three parts is the key to understanding all FSMs.
1. State Register (Memory)
- What it does: It stores the binary value representing the machine's current state.
- How it works: It's made of one or more D Flip-Flops. On each rising edge of the clock(clock goes 0 → 1), this register updates itself with the value of the next state. For the rest of the clock cycle, it holds the current state value steady for the other parts of the circuit to use.
2. Next State Logic
- What it does: This is the logic that decides where to go next. It calculates the next state of the machine.
- How it works: It is a combinational circuit (made of basic logic gates like AND, OR, NOT). Its inputs are the current state (from the State Register) and the external inputs to the FSM. Its output is the binary value for the next state, which it feeds to the input of the State Register.
3. Output Logic
- What it does: This logic generates the FSM's external outputs.
- How it works: It's also a combinational circuit. What it uses as inputs determines the type of FSM it is. This is the most critical distinction to learn.