Finite State Machines
Model sequential behaviour as states and transitions — Moore and Mealy machines.
Intermediate
An FSM has a finite set of states, inputs that trigger transitions, and outputs:
- Moore — outputs depend only on the current state.
- Mealy — outputs depend on the state and the inputs (react one cycle faster).
Examples: traffic lights, vending machines, protocol decoders, button debouncers. In software:
switch (state) {
case IDLE: if (start) state = RUNNING; break;
case RUNNING: if (fault) state = ERROR; else if (done) state = IDLE; break;
case ERROR: if (reset) state = IDLE; break;
}
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.