module mux16_1 (
input [15:0] I,
input [3:0] S,
output Y
);
wire Y0, Y1, Y2, Y3;
mux4to1 M0 (I[3:0], S[1:0], Y0);
mux4to1 M1 (I[7:4], S[1:0], Y1);
mux4to1 M2 (I[11:8], S[1:0], Y2);
mux4to1 M3 (I[15:12], S[1:0], Y3);
mux4to1 M4 ({Y3, Y2, Y1, Y0}, S[3:2], Y);
endmodule
module mux4_1 (
input [3:0] I,
input [1:0] S,
output Y
);
wire Y0, Y1;
mux2to1 M0 (I[0], I[1], S[0], Y0);
mux2to1 M1 (I[2], I[3], S[0], Y1);
mux2to1 M2 (Y0, Y1, S[1], Y);
endmodule
module mux2_1 (
input I0, I1,
input S,
output Y
);
wire nS, w0, w1;
not (nS, S);
and (w0, I0, nS);
and (w1, I1, S);
or (Y, w0, w1);
endmodule