BCD to Gray code converter using 8:1 multiplexers, live
A BCD to Gray code converter can be built from four 8-to-1 multiplexers, one per Gray output. B3, B2 and B1 drive the select lines of all four, so each select value picks a pair of BCD digits, and each data input is wired to 0, 1, B0 or NOT B0, read straight from the truth table.
This is the multiplexer used as a function generator. With B3 B2 B1 on the selects, select value s covers the two BCD digits 2s and 2s + 1, which differ only in B0. For each output, look at those two rows of the truth table: if the output is the same in both, the data input is that constant; if it follows B0, the input is B0; if it is the opposite of B0, the input is NOT B0. Select values 5, 6 and 7 stand for the codes 1010 to 1111, which never occur in BCD, so those inputs are don't-cares and tied to 0 here. The four outputs need only one inverter between them, for NOT B0. Each MUX block is the verified gate-level 8-to-1 multiplexer, saved as a part; open the circuit in the lab to look inside. The gate version, which uses the don't-cares to get down to one OR and two XOR gates, is the BCD to Gray code converter, and the general rule is G = B XOR (B shifted right by one), as in the Gray code converter.
Open this circuit in the lab →
What you need
- 4× 8-to-1 MUX: one per output G3 to G0, all with S2 S1 S0 = B3 B2 B1
- 1× NOT: NOT B0, for the data inputs where the output is the opposite of B0
- 2× constant: 0 (GND) and 1 (VDD) on the remaining data inputs
Step by step
- Place inputs
B3toB0, four 8-to-1 multiplexers and probesG3toG0. - Connect B3, B2 and B1 to S2, S1 and S0 of every multiplexer.
- Wire each multiplexer's data inputs D0 to D7 from the table below: 0, 1, B0 or NOT B0.
- Step B3 B2 B1 B0 through 0000 to 1001: G3 G2 G1 G0 shows each digit's Gray code, and only one output bit changes from one digit to the next.
Data inputs of each 8:1 mux
| B3 B2 B1 (select) | BCD digits | G3 mux | G2 mux | G1 mux | G0 mux |
|---|---|---|---|---|---|
| 000 | 0, 1 | 0 | 0 | 0 | B0 |
| 001 | 2, 3 | 0 | 0 | 1 | B0' |
| 010 | 4, 5 | 0 | 1 | 1 | B0 |
| 011 | 6, 7 | 0 | 1 | 0 | B0' |
| 100 | 8, 9 | 1 | 1 | 0 | B0 |
| 101 | not BCD | 0 (unused) | 0 (unused) | 0 (unused) | 0 (unused) |
| 110 | not BCD | 0 (unused) | 0 (unused) | 0 (unused) | 0 (unused) |
| 111 | not BCD | 0 (unused) | 0 (unused) | 0 (unused) | 0 (unused) |
BCD to Gray code truth table
| Digit | BCD B3 B2 B1 B0 | Gray G3 G2 G1 G0 |
|---|---|---|
| 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 |
All ten BCD digits are checked on the live circuit before the page is built; the six codes 1010 to 1111 are not valid BCD and are not graded.
You can also read the full theory in the lesson on the multiplexer as a universal block. Prefer to build it yourself from scratch? Open the digiwleea lab and place the gates on the canvas, or start from the logic gate simulator.
More builds: Selecting, routing and decoding
All 246 build guides, by topic
Each of these is one step from a transistor to a working CPU. Build every gate from CMOS transistors and work all the way up in the free digiwleea lab, with the free theory reference alongside.
Open the BCD to Gray code converter using 8:1 multiplexers in the lab →Frequently asked
How do you design a BCD to Gray code converter using 8:1 multiplexers?
Use one 8-to-1 mux per Gray output with B3 B2 B1 on the select lines. For each select value, compare the output's two truth table rows (B0 = 0 and B0 = 1) and wire the data input to 0, 1, B0 or NOT B0. Codes 1010 to 1111 are don't-cares.
How many multiplexers are needed for a BCD to Gray code converter?
Four 8-to-1 multiplexers, one for each of the outputs G3, G2, G1 and G0, plus one inverter for NOT B0.
What are the Boolean expressions of a BCD to Gray code converter?
With the unused codes as don't-cares, G3 = B3, G2 = B3 + B2, G1 = B2 XOR B1 and G0 = B1 XOR B0.
Why can a multiplexer implement any function?
Its select lines pick one row of the truth table, and the data input wired to that row holds the answer. With one variable moved to the data inputs as B0 or NOT B0, an 8-to-1 mux implements any function of four variables.