Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksBuild a CPUToolsOpen the lab →

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.

Big circuit: pinch, scroll or tap + to zoom in, then drag to move around.

Live circuit: click the inputs to toggle them and watch the outputs update. It runs the real simulator, right here on the page.

Open this circuit in the lab →

Embed or cite this circuit

Free to embed on a course page, blog or worksheet: paste this code. The circuit stays live, and the small digiwleea badge links back here.

To cite it: digiwleea, “BCD to Gray code converter using 8:1 multiplexers”, https://digiwleea.wleeaf.dev/tools/build/bcd-to-gray-mux/

What you need

Step by step

  1. Place inputs B3 to B0, four 8-to-1 multiplexers and probes G3 to G0.
  2. Connect B3, B2 and B1 to S2, S1 and S0 of every multiplexer.
  3. Wire each multiplexer's data inputs D0 to D7 from the table below: 0, 1, B0 or NOT B0.
  4. 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 digitsG3 muxG2 muxG1 muxG0 mux
0000, 1000B0
0012, 3001B0'
0104, 5011B0
0116, 7010B0'
1008, 9110B0
101not BCD0 (unused)0 (unused)0 (unused)0 (unused)
110not BCD0 (unused)0 (unused)0 (unused)0 (unused)
111not BCD0 (unused)0 (unused)0 (unused)0 (unused)

BCD to Gray code truth table

DigitBCD B3 B2 B1 B0Gray G3 G2 G1 G0
000000000
100010001
200100011
300110010
401000110
501010111
601100101
701110100
810001100
910011101

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.