2 TO 1 MUX CODE:
//2 TO 1 MULTIPLEXER CODE
//DATED 19-07-2017
module mux_2x1(f,a,b,select);
output f;
input a,b,select;
assign f=(~select)?a:b;
endmodule
AND2_USING_MUX CODE:
`timescale 1ns/1ps; // TIMESCALE IS USED TO SPECIFY DELAY TIME IN NANO SECONDS
module and2_using_mux();
reg A,B;
wire out;
mux_2x1 DUT(.f(out),.a(0),.b(A),.select(B));
initial
begin
A=1'b0;
B=1'b0;
#200 $finish;
end
initial
begin
end
endmodule
OUTPUT:-
VSIM21>run
OR2_USING_MUX CODE:
`timescale 1ns/1ps;
module or2_using_mux();
reg A,B;
wire out;
mux_2x1 DUT(.f(out),.a(B),.b(1),.select(A));
initial
begin
A=1'b0;
B=1'b0;
#200 $finish;
end
initial
begin
end
endmodule
OUTPUT:-
VSIM 21>run
// 4 to 1 MULTIPLEXER CODE
input[3:0] d;
assign q = d[select];
endmodule
NOR3_USING_MUX CODE:
`timescale 1ns/1ps;
module nor3_using_mux();
reg a,b,c;
wire f;
initial
begin
a=1'b0;
b=1'b0;
c=1'b0;
#100 $finish;
end
initial
begin
end
endmodule
OUTPUT:-
VSIM 29> run
Nand3_USING_MUX CODE:
`timescale 1ns/1ps;
module nand3_using_mux();
reg a,b,c;
wire f;
initial
begin
a=1'b0;
b=1'b0;
c=1'b0;
#100 $finish;
end
initial
begin
end
endmodule
OUTPUT:-
VSIM 21>run