HDL & Verification
For a state machine with three states, how many flip-flops are needed to store the state (binary encoding / one-hot encoding)?
- A3 / 2
- B2 / 3
- C1 / 3
Show answer and explanation
Answer: B. 2 / 3
Binary encoding numbers the states in binary, so three states fit in 2 bits (two flip-flops): 00, 01 and 10. One-hot encoding uses one flip-flop per state, so three. Binary leaves the unused code 11, so it is safer to define its destination with a default branch, letting the machine recover if noise ever puts it there.
- A. It is the other way around.
- B. Correct. Two bits can represent up to four states.
- C. One bit can represent only two states.