HDL & Verification

What is a characteristic of one-hot encoding for state machine states?

  1. AIt encodes states in binary to minimize flip-flops
  2. BAll flip-flops are always 1
  3. CIt uses one flip-flop per state with exactly one set at a time, so next-state and output logic tend to be simple and fast
Show answer and explanation

Answer: C. It uses one flip-flop per state with exactly one set at a time, so next-state and output logic tend to be simple and fast

One-hot encoding represents, say, four states as 0001, 0010, 0100 and 1000, assigning one flip-flop to each state. It needs more flip-flops, but checking whether the machine is in a state means looking at a single bit, so next-state and output logic is shallow and fast. It is common on flip-flop-rich FPGAs, while binary encoding is used when flip-flop count must be minimized.

  • A. That is binary encoding.
  • B. Exactly one is 1 at any time.
  • C. Correct. It is popular on flip-flop-rich FPGAs.
Practice this topic Back to topic

More HDL & Verification questions

  1. For a state machine with three states, how many flip-flops are needed to store the state (binary encoding / one-hot encoding)?
  2. In the 4-bit counter above, when count is 15 and a rising clock edge arrives, what does count become?
  3. In Verilog, two 8-bit signals a and b are added and assigned to an 8-bit signal s (assign s = a + b;). What should be watched for?
  4. Intending a to be signed -1, someone wrote the code above, and gt became 1. Why?
  5. Which set of values makes up the four-state logic used in Verilog simulation?