Sub topic 8
Multiplexers and Implementing Functions with Them
A multiplexer, or MUX, is a combinational circuit that selects one input and sends it to one output. “Combinational” means the output depends only on the current inputs, not on a clock or stored state.
Assume you know binary notation, Boolean operators, and basic logic gates. A MUX is useful because it can replace several gates with one structured selection circuit.
How a multiplexer works
An \(n\)-to-1 MUX has \(n\) data inputs and enough select inputs to choose one of them. For \(n=2^k\), it has \(k\) select lines.
| MUX | Data inputs | Select lines |
|---|---|---|
| 2-to-1 | 2 | 1 |
| 4-to-1 | 4 | 2 |
| 8-to-1 | 8 | 3 |
For a 4-to-1 MUX, select lines \(S1S0\) act like a two-bit binary index:
| \(S_1S_0\) | Selected input | Output |
|---|---|---|
| 00 | \(D_0\) | \(Y=D_0\) |
| 01 | \(D_1\) | \(Y=D_1\) |
| 10 | \(D_2\) | \(Y=D_2\) |
| 11 | \(D_3\) | \(Y=D_3\) |
The Boolean expression is
\[ Y=\overline{S1}\overline{S0}D0+ \overline{S1}S0D1+ S1\overline{S0}D2+ S1S0D3. \]
A 4-to-1 MUX can be built from three 2-to-1 MUXes: two MUXes select between pairs of inputs, and a third selects between their outputs.
Implementing a Boolean function
A MUX can implement a Boolean function by connecting some variables to the select lines and connecting constants or remaining variables to the data inputs. This follows the Shannon expansion, which expresses a function in terms of a variable's two possible values.
Consider
\[ F(A,B,C)=\Sigma m(1,2,5,7). \]
Use \(A\) and \(B\) as the select lines, with \(AB\) selecting \(D0\) through \(D3\). Examine the function for each fixed value of \(AB\):
| \(AB\) | Function of \(C\) | MUX input |
|---|---|---|
| 00 | \(C\) | \(D_0=C\) |
| 01 | \(\overline{C}\) | \(D_1=\overline{C}\) |
| 10 | \(C\) | \(D_2=C\) |
| 11 | \(C\) | \(D_3=C\) |
Thus, the MUX implements the function with one inverter and four data connections.
module function_with_mux(
input wire a,
input wire b,
input wire c,
output wire f
);
wire [3:0] d;
assign d[0] = c;
assign d[1] = ~c;
assign d[2] = c;
assign d[3] = c;
assign f = d[{a, b}];
endmoduleHere, {a, b} concatenates the two select bits. The expression d[{a, b}] selects the data input whose index equals the binary value of \(AB\).
Common errors
- Treating a MUX as a storage element. A normal MUX has no memory.
- Reversing the select-line order.
- Assigning data inputs from the wrong minterm groups.
- Forgetting that a data input may be \(0\), \(1\), a variable, or its complement.
- Assuming a larger MUX always needs every data input to be a variable. Constants are valid data connections.
Exercise
Implement F(A,B,C) = Σm(0, 3, 4, 6) using a 4-to-1 MUX with A and B as select lines. What should connect to D0 through D3?
Show answer
D0 = C̅, D1 = C, D2 = C̅, and D3 = C̅.