module mux2x1(A,B,select,OUT); input A,B,select; output OUT; reg OUT; always @ (select or A or B) if (select == 1) OUT = A; else OUT = B; endmodule module testmux; reg TA,TB,TS; //inputs for mux wire Y; //output from mux mux2x1 mx (TA,TB,TS,Y); // instantiate mux initial begin TS = 1; TA = 0; TB = 1; #10 TA = 1; TB = 0; #10 TS = 0; #10 TA = 0; TB = 1; end initial $monitor("select = %b A = %b B = %b OUT = %b time = %0d", TS, TA, TB, Y, $time); endmodule