There are many different methods
of coding the states. And the codes are directly related to the
Flip-Flops used in the design. For n bits codes, we will need n FFs
because one FFs can output one bit signal. And the output signals from
the FFs will form the codes and represent certain state. Following are
several possible encoding methods (Prof. Cheng has taught them in
class).
(1). Binary code
Use binary numbers to encode the states.
n bits binary code needs n FFs and can
represent 2^n states.
(2). Gray code
Adjacent Gray codes are different in only
one bit.
n bits Gray code needs n FFs and can represent
2^n states.
(3). Johnson code
Use the output pattern of Johnson counter
to encode the states.
n bits Johnson code needs n FFs and can
represent 2n states.
(4). One hot code
Only one bit is '1' in the code for each
state.
n bits one hot code needs n FFs and can
represent n states.
For example, encoding for 8 states:
| |
Binary Code
(3bits) |
Gray Code
(3bits) |
Johnson Code
(4bits) |
One Hot Code
(8bits) |
|
S0 |
000 |
000 |
0000 |
00000001 |
|
S1 |
001 |
001 |
0001 |
00000010 |
|
S2 |
010 |
011 |
0011 |
00000100 |
|
S3 |
011 |
010 |
0111 |
00001000 |
|
S4 |
100 |
110 |
1111 |
00010000 |
|
S5 |
101 |
111 |
1110 |
00100000 |
|
S6 |
110 |
101 |
1100 |
01000000 |
|
S7 |
111 |
100 |
1000 |
10000000 |