A multiplexer (mux) is a broad type of logic circuit that takes multiple data inputs and selector inputs. They’re best analogous to conditional statements in programming — if we meet a certain condition, then we select certain data to pass through.
Multiplexers can be huge if necessary. A basic 2-to-1 multiplexer is given by the expression:
We can extend to a 2-bit wide gate:
And so on.
Implementation
In Verilog, multiplexers can be explicitly defined with their logic expressions, or we can use case statements to achieve the same effect.
Explicitly, we can implement a two-bit wide multiplexer in Verilog as a combination of two one-bit wide multiplexers (this holds for higher-order wide multiplexers).
With case statements: