Binary to Gray code circuit: build and simulate it online
Gray code changes one bit at a time: G3 = B3, and each other bit is the XOR of neighbours.
Build the binary to gray code in the free online simulator — it checks your circuit automatically.
What you need
- 4 logic switches labelled B3, B2, B1, B0
- 4 probes labelled G3, G2, G1, G0
- 3 XOR gates
Step by step
- Inputs and outputs. From the Logic section of the library, drop digital inputs (0/1 boxes) or logic switches for the inputs, and digital outputs or probes for the outputs; give each its label in the inspector (the checker finds them by label). Switches B3, B2, B1, B0; Probes G3, G2, G1, G0
- Three XOR gates. G2 = B3 ⊕ B2, G1 = B2 ⊕ B1, G0 = B1 ⊕ B0; G3 is just B3.
- Prove it. All 16 codes.
Truth table
| B3 | B2 | B1 | B0 | G3 | G2 | G1 | G0 |
|---|---|---|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| 0 | 0 | 0 | 1 | 0 | 0 | 0 | 1 |
| 0 | 0 | 1 | 0 | 0 | 0 | 1 | 1 |
| 0 | 0 | 1 | 1 | 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 | 0 | 1 | 1 | 0 |
| 0 | 1 | 0 | 1 | 0 | 1 | 1 | 1 |
| 0 | 1 | 1 | 0 | 0 | 1 | 0 | 1 |
| 0 | 1 | 1 | 1 | 0 | 1 | 0 | 0 |
| 1 | 0 | 0 | 0 | 1 | 1 | 0 | 0 |
| 1 | 0 | 0 | 1 | 1 | 1 | 0 | 1 |
| 1 | 0 | 1 | 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 1 | 1 | 1 | 0 |
| 1 | 1 | 0 | 0 | 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 |
| 1 | 1 | 1 | 0 | 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 1 | 1 | 0 | 0 | 0 |
Frequently asked questions
How do you build a binary to gray code?
Gray code changes one bit at a time: G3 = B3, and each other bit is the XOR of neighbours. In short: inputs and outputs, then three xor gates, then prove it.
What is the truth table of a binary to gray code?
It has 4 inputs (B3, B2, B1, B0) and 4 outputs (G3, G2, G1, G0), so 16 rows. The full table is on this page; the Embedded Lab checks all of them against your circuit.
What parts do you need for a binary to gray code?
3 XOR gates — plus logic switches for the inputs and probes for the outputs.
Can I simulate a binary to gray code online for free?
Yes. Open it in the BitForBytes Embedded Lab, a free browser-based circuit and logic simulator: drag in the gates, wire them, and press "Check my circuit" — every input combination is simulated and marked for you. No download or sign-up needed.
Part of DSD 25 · Code converters in the free BitForBytes digital system design course.