In a one-hot state assignment, an N-state machine uses N flip-flops, one per state. Exactly one of them is 1 ("hot") at any time, and that tells you the state. Three states become 001, 010 and 100.
That's far more flip-flops than binary encoding's ⌈log₂ N⌉, so why use it?
- Simple next-state logic. The equation for a state's flip-flop is just the OR of the arrows coming into it: each term is "source state AND input condition".
- Simple outputs. A Moore output is the OR of the flip-flops for the states where it's 1. No decoding needed.
- Fast and easy to change. Each equation is small, and adding a state doesn't reshuffle every code.
FPGAs have plenty of flip-flops, so one-hot is a common choice there. A ring counter is one-hot by nature.
The catch: with N flip-flops there are 2ᴺ − N unused patterns (all 0s, or two 1s at once). The machine must be reset into a valid code.
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 0 |
| 1 | 0 | 1 | 1 |
| 1 | 1 | 0 | 0 |
| 1 | 1 | 1 | 1 |