Home > finite state machines > State Machine Fundamentals > State Encoding Techniques

State Encoding Techniques :

Before you setup your design for synthesis, provides four encoding schemes : • Gray • One-Hot • Binary • Random

Encoding technique examples Enumerated Gray code One-hot Seq. Random Sa “000” “000001” “000” “000” Sb “001” “000010” “001” “100” Sc “011” “000100” “010” “010” Sd “010” “001000” “011” “001” Se “110” “010000” “100” “101” Sf “111” “100000” “101” “111”

Random Encoded State Machines : Will generate state machines using random state encoding. Random state machine encoding should only be used when all other implementations are not achieving the desired results. It is basically a shot in the dark and not recommended. In random encoding, VHDL randomly determines state assignments using the minimum bit width. Using the previous type definition example, VHDL assigns the bit values randomly to the enumerated states using the minimum bit width for six states, which is three bitsm wide. Table lists a possible conversion for a state type with six states. Binary Encoded State Machines : 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1 Will generate state machines with the fewest possible flip-flops. Binary state machines are useful for area critical designs when timing is not a concern. In binary encoding, determines state assignments using the minimum bit width. The states are sequentially encoded with the bit-level equivalents of the integers 0, 1, 2, 3, ... starting at the left-most position in the enumerated type declaration. The binary encoding option would synthesize the state machine using the bit values, as shown in Table.The number of flip-flops is the smallest number m such that 2m ≥ n, where n is the number of states in the machine.

Gray Encoded State Machines : 0 0 0 0 0 1 0 1 0 0 1 1 1 0 0 1 0 1 1 1 0 1 1 1

Will generate state machines where only one flip-flop changes during each transition. Gray encoded state machines tend to be glitchless. Gray code encoding sequentially encodes the enumerated type using sequential Gray or reflected code. Table lists a Gray code encoding example consisting of six states Similar to binary encoded state machines. State sequence has the property that only one output changes when sequencing between states. Can have lower power can be asynchronously sampled in some systems. There may be unused states.