Verilog 4 To 1 Multiplexer/Mux
Verilog 4 To 1 Multiplexer/Mux
Verilog 4 to 1 Multiplexer/Mux
(/images/verilog/4x1_mux.png)
sel is a 2-bit input and can have four values. Each value on
the select line will allow one of the inputs to be sent to output
pin out .
sel a b c d out
0 3 7 1 9 3
1 3 7 1 9 7
2 3 7 1 9 1
3 3 7 1 9 9
12 endmodule
11 case (sel)
16 endcase
17 end
18 endmodule
Hardware Schematic
Testbench
1 module tb_4to1_mux;
7 reg [3:0] b;
8 reg [3:0] c;
9 reg [3:0] d;
12 integer i;
13
17 .b (b),
18 .c (c),
19 .d (d),
20 .sel (sel),
21 .out (out));
22
24 initial begin
30 a <= $random;
31 b <= $random;
32 c <= $random;
33 d <= $random;
34
37 #5 sel <= i;
38 end
39
43 endmodule
Simulation Log