Lesson 12 of 15
Multiplexer
Multiplexer (MUX)
A multiplexer (MUX) selects one of several input signals and routes it to the output, based on select lines.
A 4-to-1 MUX has:
- 4 data inputs: D0, D1, D2, D3
- 2 select lines: S1, S0
- 1 output Y
| S1 | S0 | Y |
|---|---|---|
| 0 | 0 | D0 |
| 0 | 1 | D1 |
| 1 | 0 | D2 |
| 1 | 1 | D3 |
The select lines form a 2-bit binary address: S1 is the MSB, S0 is the LSB. Together they select which input to pass through.
Multiplexers are used everywhere: bus arbitration, data routing, function generators, and implementing any Boolean function using a single MUX.
Your Task
Implement mux4to1(d0, d1, d2, d3, s1, s0) that returns the selected input based on the select lines.
JavaScript loading...
Loading...
Click "Run" to execute your code.