3
1 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

Behavioral

Embed Size (px)

DESCRIPTION

Behavioral. module MUX4_to_1(y, x, s); inputx[3:0], s[1:0]; outputy; regy; always @(x or s) begin if (s == 0) y=x[0]; else if …; end endmodule. Continuous Assignment. module MUX4_to_1(y, x, s); inputx[3:0], s[1:0]; outputy; - PowerPoint PPT Presentation

Citation preview

Page 1: Behavioral

1

Behavioralmodule 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

Page 2: Behavioral

2

Continuous Assignmentmodule 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

Page 3: Behavioral

3

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