| State machine encoding (Gray, Binary and One-hot) |
|
|
|
Page 1 of 4
Each state of a state machine can be represented with a unique pattern of high (1) and low (0) register output signals, this process called "encoding." The two primary encoding methods are binary and one-hot encoding. One-hot encoding uses one flip-flop for each state. For example if there are 10 states in logic then it will use 10 flip-flops. This type of encoding is fast because only one bit needed to check for each state. It implies complex logic and more area inside the chip due to more number of flip-flops. Check the following one hot encoded state values (for a 4 state state-machine) 1000 0100 0010 0001 Gray encoding (a type of binary encoding) is especially useful when the outputs of the state bits are used asynchronously. This kind of state coding avoids intermediate logics. For example if a sate wants to change it’s state from "01" to "10". Here both bits are getting changed, in reality both flip-flops will not change at the same time. So there are two possibilities for this transition. Check this following diagram for the two possible transitions. ![]() Intermediate_state 00 01 11 10 Binary-encoding implements very less logic. Also it used minimum number of FFs. Possible state values for a 4 state binary state machine 00 01 10 11 ![]() State Diagram |





