When to use it
For most FPGA state machines, one-hot encoding (exactly one flip-flop high per state) beats binary encoding. Flip-flops are plentiful, and the next-state and output logic collapses into tiny, fast expressions, you just test one bit per state. It's also trivial to read on a waveform.
How it works
This machine walks S0 → S1 → S2 → S3 and wraps, one step each time en is high, by
rotating the hot bit. In a real FSM each state's transition is its own small
term; you rarely need a big case. Reset forces a known one-hot state (never let a
one-hot machine start at all-zeros).
Gotchas
- Always reset to a valid one-hot value, glitches or a bad reset can leave two bits hot or none.
- Read outputs straight off the state bits (
out = state[2]), that's the whole point, no decode needed.