Home / Learn Verilog / State Encoding: Binary, Gray, One-Hot
State Encoding: Binary, Gray, One-Hot
How states are numbered.
Quick summaryHow states are numbered.
How to think about this
The basic idea
States are stored in flip-flops; the encoding decides how many and how the logic looks.
Why this comes up
Encoding affects speed, area and power.
The mechanics
Use localparam or enum names, never raw numbers.
Where it is used
- Everyday RTL design
- FPGA and ASIC projects
- Testbenches and debugging
Try it
Named statesVerilog: edit and run
Named constants make the code readable.
Quick check
1. FPGAs usually prefer...
Flip-flops are plentiful.