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.