30 likes | 94 Views
Behavioral. module MUX4_to_1(y, x, s); input x[3:0], s[1:0]; output y; reg y; always @(x or s) begin if (s == 0) y=x[0]; else if …; end endmodule. Continuous Assignment. module MUX4_to_1(y, x, s); input x[3:0], s[1:0]; output y;
E N D
Behavioral module MUX4_to_1(y, x, s); input x[3:0], s[1:0]; output y; reg y; always @(x or s) begin if (s == 0) y=x[0]; else if …; end endmodule
Continuous Assignment module MUX4_to_1(y, x, s); input x[3:0], s[1:0]; output y; assign y = (!s[0]&!s[1]&x[0]) | (!s[1]&s[0]&x[1]) | (s[0]&!s[1]&x[2]) | (s[1]&s[0]&x[3]); endmodule
Structure module MUX4_to_1(y, x, s); input x[3:0], s[1:0]; output y; wire s1_, s0_, y0, y1, y2, y3; // optional not(s1_, s1); not(s0_, s0); and(y0, s1_, s0_, x[0]); and(y1, s1_, s0, x[1]); … or (y, y0, y1, y2, y3); endmodule