Multiplexer is a combinational circuit that has maximum of 2n data inputs, ‘n’ selection lines and single output line. One of these data inputs will be connected to the output based on the values of selection lines.
Since there are ‘n’ selection lines, there will be 2n possible combinations of zeros and ones. So, each combination will select only one data input. Multiplexer is also called as Mux.
4x1 Multiplexer
4x1 Multiplexer has four data inputs I3, I2, I1 & I0, two selection lines s1 & s0 and one output Y. The block diagram of 4x1 Multiplexer is shown in the following figure.
design.v |
testbench.v |
module mux4x1 (y,s,i); input [0:3] i; input [1:0] s; output y; assign y = s[1] ? (s[0] ? i[3]:i[2]) : (s[0] ? i[1]:i[0]); endmodule |
module tb; reg [0:3] i; reg [1:0]s; wire y; integer z; mux4x1 dut(y,s,i); initial begin $monitor ($time, " i=%b s=%b y=%b",i,s,y); #100; end initial begin for (z=0; z<16; z=z+1) begin {i,s}=z; #5; end end endmodule |