Binary → Gray Code Converter
Enter a 4-bit binary number. The circuit produces the equivalent Gray code using three parallel XOR gates. Only one bit changes between consecutive Gray codes.
Binary → Gray Circuit (4-bit)
Binary 0000 = 0
Gray 0000
Truth Table (all 16 codes)
| Dec | B3B2B1B0 | G3G2G1G0 |
|---|---|---|
| 0 | 0000 | 0000 |
| 1 | 0001 | 0001 |
| 2 | 0010 | 0011 |
| 3 | 0011 | 0010 |
| 4 | 0100 | 0110 |
| 5 | 0101 | 0111 |
| 6 | 0110 | 0101 |
| 7 | 0111 | 0100 |
| 8 | 1000 | 1100 |
| 9 | 1001 | 1101 |
| 10 | 1010 | 1111 |
| 11 | 1011 | 1110 |
| 12 | 1100 | 1010 |
| 13 | 1101 | 1011 |
| 14 | 1110 | 1001 |
| 15 | 1111 | 1000 |
How Gray Code Works
Formula
G3 = B3
G2 = B3 ⊕ B2
G1 = B2 ⊕ B1
G0 = B1 ⊕ B0
Key Property
Only one bit changes between any two consecutive Gray codes. This eliminates glitches in encoders and minimizes switching errors.
Used In
Rotary encoders, analog-to-digital converters, Karnaugh maps, and error correction codes.