Skip to content
BetterDL

One-hot state assignment

Also called: one-hot state encoding, one-hot FSM, one-hot state machine

A state encoding with one flip-flop per state, where exactly one flip-flop is 1 at any time, trading extra flip-flops for very simple logic.

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.

0000
0010
0100
0111
1000
1011
1100
1111

Worked example

Example

One-hot equations by inspection

Encode the Mealy 110 detector one-hot, with one flip-flop per state, named A, B and C after the states. Arrows: A on 0 → A, A on 1 → B, B on 0 → A, B on 1 → C, C on 0 → A (Z = 1), C on 1 → C.

  1. 1.

    Into A: every arrow on 0. A⁺ = = , since exactly one of A, B, C is 1.

  2. 2.

    Into B: only A on 1. B⁺ = .

  3. 3.

    Into C: B on 1 and C on 1. C⁺ = (the diagram's table).

  4. 4.

    Output: Z = .

  5. 5.

    No K-maps were needed: each equation came straight from the arrows.

Common mistakes

  • Using ⌈log₂ N⌉ flip-flops for one-hot. One-hot always uses N.

  • Forgetting the reset. All-zeros is not a valid one-hot state, and a machine that starts there may never leave.

  • Thinking one-hot is always worse because it uses more flip-flops. It often needs much less logic.

Practice One-hot state assignment

Interactive questions with instant feedback and a worked solution for every wrong answer.

Learn it step by step

One-hot state assignment is taught in Finite State Machines.