Gray 1110 → binary — Gray code
introcumulative XOR from the left
Answer
1011
Why this example is worth doing
The reverse conversion is not symmetric, and that asymmetry is the thing to notice. Each binary bit is the XOR of all Gray bits from the most significant down to that position, so the computation is a running total and each output depends on every input above it. In hardware that is a chain, not a row, so decoding is slower than encoding — a real consideration when the code is used at speed.
Try your own input in the Gray code. Convert binary to reflected Gray code and back, and build the sequence by reflection.
How the answer is reached
Gray code 1110 to binary
Copy the most significant bit, then XOR each Gray bit with the binary bit already produced above it. This direction is inherently sequential.
| bit i | g_i | b_(i+1) | b_i = b_(i+1) XOR g_i |
|---|---|---|---|
| 3 | 1 | - (the MSB is copied) | 1 |
| 2 | 1 | 1 | 0 |
| 1 | 1 | 0 | 1 |
| 0 | 0 | 1 | 1 |
Gray1110
binary1011
equivalentlyb_i = parity of g_(n-1) ... g_i
This is the binary reflected Gray code. It is one Gray code among many: any single-bit-change ordering of the codewords is a Gray code, and other constructions give different tables.
Source: Frank Gray, US Patent 2,632,058, "Pulse Code Communication" (filed 1947, granted 1953)