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.
Open this circuit in the lab →
What you need
- 2× NOT: NOT A/B and NOT G, shared by all four channels
- 8× AND: nA AND NOT A/B, and nB AND A/B, for each channel
- 4× OR: the two terms of each channel
- 4× AND: each channel AND NOT G (the strobe)
Step by step
- Place
A/B,G, the data inputs1A,1Bto4A,4B, and probes1Yto4Y. - Invert A/B and G once each.
- For each channel n:
nY = ((nA AND NOT A/B) OR (nB AND A/B)) AND NOT G. - 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)
| G | A/B | nA | nB | nY |
|---|---|---|---|---|
| 1 | X | X | X | 0 |
| 0 | 0 | 0 | X | 0 |
| 0 | 0 | 1 | X | 1 |
| 0 | 1 | X | 0 | 0 |
| 0 | 1 | X | 1 | 1 |
74HC157 pinout
| Pin | Name | Pin | Name |
|---|---|---|---|
| 1 | A/B (select) | 16 | VCC |
| 2 | 1A | 15 | G (strobe, active low) |
| 3 | 1B | 14 | 4A |
| 4 | 1Y | 13 | 4B |
| 5 | 2A | 12 | 4Y |
| 6 | 2B | 11 | 3A |
| 7 | 2Y | 10 | 3B |
| 8 | GND | 9 | 3Y |
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
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.