Skip to content
digiwleeaTools
LearnGlossaryAboutCheat sheetHow a CPU worksToolsOpen the lab →

Half adder using 2-to-1 multiplexers (MUX), live

A half adder can be built from two 2-to-1 multiplexers and one NOT gate. Input A drives the select line of both muxes, so each mux picks between two half-rows of the truth table: the sum mux chooses B when A = 0 and NOT B when A = 1, and the carry mux chooses 0 when A = 0 and B when A = 1.

This is the multiplexer used as a function generator. Split the truth table on A: when A = 0 the half adder's sum is B and its carry is 0; when A = 1 the sum is NOT B and the carry is B. Each of those four entries is either a constant or B itself, so wire them to the mux data inputs and let A choose. The result is S = A XOR B and C = A AND B without a single XOR or AND gate. The same trick with 4-to-1 muxes and two select lines builds the full adder using 4-to-1 multiplexers, and any function of n + 1 variables fits in a 2n-to-1 mux this way, which is how FPGA lookup tables work. Compare the gate version, the half adder (one XOR and one AND). All four rows are checked before the page is built.

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 →

What you need

Step by step

  1. Place inputs A and B and probes S and C.
  2. Split the truth table on A: for A = 0, S = B and C = 0; for A = 1, S = NOT B and C = B.
  3. Sum mux: data 0 = B, data 1 = NOT B, select = A. Carry mux: data 0 = 0 (ground), data 1 = B, select = A.
  4. Try all four rows: S is 1 when exactly one input is 1, and C only when both are.

Half adder truth table

ABSum mux picksSCarry mux picksC
00B000
01B100
10NOT B1B0
11NOT B0B1

Because A selects, each mux only has to produce a function of B, and every function of one variable is 0, 1, B or NOT B. That is the whole method in one line.

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.

Build more parts from gates

half adderfull adderhalf subtractorfull subtractor2:1 multiplexer4:1 multiplexerXOR gate from NAND gates2-to-4 decoderSR latchD flip-flopJK flip-flopT flip-flop4-bit shift register4-bit ripple carry adderD latch1-to-4 demultiplexer4-bit magnitude comparator4-bit ring counter4-bit Johnson counter4-to-2 priority encoder4-bit synchronous counter3-to-8 decoder8-to-1 multiplexer4-bit carry lookahead adderhalf adder from NAND gates2-bit comparatorBCD to 7-segment decoder4-bit up/down counterdecade counter2-bit multiplier4-bit ALU4-bit array multiplierNOT, AND, OR and NOR from NANDNOT, OR, AND and XOR from NORfull adder from NAND gatesSR latch from NAND gatesparity generator and checker4-bit adder/subtractorBCD adder4-bit universal shift registermod-6 counter4-bit ripple counterbinary to Gray code converterhalf adder from NOR gatesfull adder from NOR gates4-bit register with parallel load1011 sequence detectorbinary to BCD converterD flip-flop from NAND gates1-bit ALUCMOS inverterCMOS NAND gateCMOS NOR gatePISO shift registerSR flip-flop from NAND gatesBCD to excess-3 code converterHamming (7,4) code encoder and correctortraffic light controller4-bit barrel shifterCMOS AND gateCMOS OR gateCMOS XOR gate1-bit magnitude comparatorhalf subtractor from NAND gatesfull subtractor from NAND gates8-to-3 encoderGray to binary converter4-to-16 decoderfull adder using 4:1 multiplexersedge detectorserial adder4-bit carry-select adder4-bit Kogge-Stone adder4-bit carry-skip adder4x4 Wallace tree multiplier8-bit adderfrequency divider (by 2, 4 and 3)switch debouncer (SR latch)3-bit Gray code counterMealy machine (1011 detector)master-slave JK flip-flop (NAND)half subtractor from NOR gates1-to-8 demultiplexerexcess-3 to BCD code convertervending machine FSM4-bit carry-save adder3-bit synchronous counter (JK)CMOS transmission gatetri-state buffer (CMOS)2-to-1 mux from transmission gatesmod-5 counterflip-flop conversion (JK to D)8-bit ALUdecimal to BCD encoderBCD to decimal decoder4-to-1 mux from 2-to-1 muxesXOR gate from NOR gates4-bit LFSR74LS138 decoderBCD subtractor74181 ALUCMOS AOI gate (AOI21)D latch vs D flip-flop74LS47 BCD to 7-segment decoder74HC595 shift register7400 quad NAND gate chip7402 quad NOR gate chip7404 hex inverter chip7408 quad AND gate chip7432 quad OR gate chip7486 quad XOR gate chip7474 dual D flip-flop74HC165 shift registerCD4017 decade counter74LS283 4-bit adder74LS90 decade counter74HC161 4-bit counter74HC151 8-to-1 multiplexer74HC157 quad 2-to-1 multiplexer74HC139 dual 2-to-4 decoderCD4511 BCD to 7-segment decoder7492 divide-by-12 counter7493 4-bit binary counter74HC244 octal bufferRace-around condition (JK latch)74HC373 octal latch74HC374 octal D flip-flopTurnstile state machine1-to-2 demultiplexerregister file (4 x 4-bit)digital PWM generatorCD4013 dual D flip-flop74LS76 dual JK flip-flop

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 half adder using 2:1 multiplexers in the lab →

Frequently asked

How do you make a half adder using a multiplexer?

Use two 2-to-1 multiplexers with A on both select lines. For the sum, feed B into data input 0 and NOT B into data input 1; for the carry, feed 0 into input 0 and B into input 1.

How many multiplexers does a half adder need?

Two 2-to-1 multiplexers (one for the sum, one for the carry) plus one NOT gate for NOT B. With 4-to-1 muxes, A and B on the selects and constants on the data inputs, it needs no NOT gate at all.

Why can a multiplexer implement any logic function?

Because its select inputs pick one row of a truth table and its data inputs supply that row's value. Feed the data inputs with constants or the remaining variable and the mux reproduces the whole table.