Learn · 3 of 4

The multiplexer

About 4 minutes. Two practice puzzles.

A multiplexer ("mux") is a switch. It has data inputs, one select input, and one output, and it copies whichever data input the select line points at. The smallest one, a 2-to-1 mux, has inputs A and B and a selector S:

SY
0A
1B

As a formula: Y = (A AND NOT S) OR (B AND S). Read it as two gated lanes. The left AND lets A through only while S is 0; the right AND lets B through only while S is 1; the OR merges the lanes, and since exactly one lane is open at a time there is never a conflict.

Build it

  1. Place inputs S, A and B and an output Y.
  2. NOT S gives the "lane 0 open" signal.
  3. AND(A, NOT S) and AND(B, S) are the two lanes.
  4. OR the lanes into Y.

Four gates. Flip S in the simulator and watch Y follow A, then B.

The NAND version

Because OR of two ANDs is the same as NAND of two NANDs (De Morgan again), the mux collapses nicely onto NAND gates: Y = NAND(NAND(A, NOT S), NAND(B, S)), with NOT S = NAND(S, S). Still four gates, and this is close to how a real CMOS mux cell is laid out.

Where muxes hide

A mux can be anything

Here is a party trick: a 2-to-1 mux is itself universal. Wire A and B to constant 0 and 1 in different combinations and you get NOT, AND and OR. That is exactly why FPGAs use them as building blocks. In Gatesmith puzzles you have no constant inputs, which is why NAND or NOR stays the usual "only one gate" challenge.

Next: latches and flip-flops →