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

74HC157 (74LS157): the quad 2-to-1 multiplexer chip, live

The 74HC157 has four 2-to-1 multiplexers that share one select input, A/B: with A/B = 0 every output nY copies its input nA, and with A/B = 1 it copies nB. So it switches a whole 4-bit word between two sources at once. The active-low strobe G forces all four outputs to 0 when it is 1. This live circuit behaves like the chip.

Each channel is the classic 2-to-1 multiplexer, (nA AND NOT A/B) OR (nB AND A/B), followed by an AND with NOT G for the strobe; one inverter on A/B and one on G serve all four channels, which is the point of the chip: TI's datasheet says all channels are controlled by the same address select and strobe inputs. That makes it the natural part for choosing which of two 4-bit values feeds the next stage, for example a register loaded either from a bus or from an adder, or the ALU's B input taken either from a register or from an instruction's constant, the kind of choice the datapath of a CPU makes every cycle. Two chips switch a byte. All 1,024 combinations of A/B, G and the eight data inputs 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 A/B, G, the data inputs 1A, 1B to 4A, 4B, and probes 1Y to 4Y.
  2. Invert A/B and G once each.
  3. For each channel n: nY = ((nA AND NOT A/B) OR (nB AND A/B)) AND NOT G.
  4. Put a pattern on the A inputs and another on the B inputs, then flip A/B: all four outputs switch from one word to the other together.

74HC157 function table (each channel)

GA/BnAnBnY
1XXX0
000X0
001X1
01X00
01X11

74HC157 pinout

PinNamePinName
1A/B (select)16VCC
21A15G (strobe, active low)
31B144A
41Y134B
52A124Y
62B113A
72Y103B
8GND93Y

X means the input does not matter. The function table and the 16-pin pinout are from TI's SN74HC157 datasheet (SCLS113F), checked 2026-10-25; it runs from 2 V to 6 V. The 74LS158 in TI's LS157 datasheet is the same multiplexer with inverted outputs.

You can also read the full theory in the lesson on the multiplexer. 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 multiplexer74HC139 dual 2-to-4 decoderCD4511 BCD to 7-segment decoder7492 divide-by-12 counter7493 4-bit binary counter74HC244 octal buffer

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 74HC157 quad 2-to-1 multiplexer in the lab →

Frequently asked

What does the 74HC157 do?

It contains four 2-to-1 multiplexers with a shared select (A/B) and a shared active-low strobe (G). With A/B low the outputs copy the A inputs, with A/B high they copy the B inputs, and with G high all outputs are low.

What is a quad 2-to-1 multiplexer used for?

Switching a 4-bit value between two sources with a single control line: choosing a register's load data, picking an ALU operand, or multiplexing address lines. Two chips switch 8 bits.

What is the difference between the 74HC157 and the 74LS158?

TI's datasheet covers both families: the 157 passes the selected data straight through, while the 158 inverts it.

Can a 74HC157 be used as a logic gate?

Yes. Any 2-to-1 multiplexer is universal: with A/B as one variable and the data inputs tied to constants or a second variable it can make NOT, AND, OR and more, as shown in the multiplexer lessons.