MUX 2x1
module mux2x1(y,a,b,s);
output y;
input a,b,s;
//assign y = ((!s) && a) || (s && b);
//assign y = ((~s) & a) | (s & b);
assign y = s ? b : a;
endmodule
MUX 4x1:
module mux4x1(y,s,i);
output y;
input [1:0] s;
input [3:0] i;
//assign y = s[1]? (s[0]?i[3]:i[2]) : (s[0] ? i[1] : i[0]);
assign y = ((~s[1]) & (~s[0]) & i[0]) | ((~s[1]) & (s[0]) & i[1])
| ((s[1]) & (~s[0]) & i[2]) | ((s[1]) & (s[0]) & i[3]);
endmodule
0 comments:
Post a Comment
if you have any doubt please let me know