The multiplexer: choosing between two signals
A multiplexer (or mux) is a switch made of logic gates. It has data inputs, a select input and one output. With 2 data inputs, A and B, the output shows A when Sel is 0 and B when Sel is 1.
Truth table
| A | B | Sel | Y |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 0 | 0 | 1 | 0 |
| 0 | 1 | 0 | 0 |
| 0 | 1 | 1 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 0 | 1 | 0 |
| 1 | 1 | 0 | 1 |
| 1 | 1 | 1 | 1 |
Try it Click the inputs to change them.
How it works
Give each input its own “gate keeper”: an AND gate that lets it through only when it is selected. A should pass when Sel is 0, so it is ANDed with NOT Sel. B should pass when Sel is 1, so it is ANDed with Sel. At most one of the two ANDs can be 1, so an OR gate collects the result.
Multiplexers are everywhere in a processor: they choose which register goes into the adder, which address goes to memory, which value is written back. Bigger ones with 4, 8 or 16 inputs need 2, 3 or 4 select bits.
Hints and solution
Try on your own first. Each hint gives away a little more.
- Use one AND gate per input to let it through only when it is selected.
- A passes when Sel is 0 (AND it with NOT Sel); B passes when Sel is 1.
- OR the two results.