0% found this document useful (0 votes)
101 views

Module Mux2x1

This document defines two modules: a 2x1 multiplexer (mux2x1) that selects between its two inputs (a and b) based on the value of its select line (s); and a top-level multiplexer module (muxtop) that uses four mux2x1 modules and additional logic to select between various combinations of its inputs (x, s0, s1) and output the results (a, b, c, d, x3, y3).

Uploaded by

Murali
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
101 views

Module Mux2x1

This document defines two modules: a 2x1 multiplexer (mux2x1) that selects between its two inputs (a and b) based on the value of its select line (s); and a top-level multiplexer module (muxtop) that uses four mux2x1 modules and additional logic to select between various combinations of its inputs (x, s0, s1) and output the results (a, b, c, d, x3, y3).

Uploaded by

Murali
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

module mux2x1(a,b,s,y);

input a,b,s;
output y;
reg y;
always @(a or b or s)
begin
if(s==0)
y=a;
else
y=b;
end
endmodule
module muxtop(x,s0,s1,a,b,c,d,x3,y3);
input [7:0]x;
input s0,s1;
output [7:0]a,b,c,d,x3,y3;
wire [7:0]y0,y1,y2,y4;
assign
assign
assign
assign

a=(x/8);
b=(8'hb*a);
c=(8'h7*a);
d=(8'hd*a);

mux2x1
mux2x1
mux2x1
mux2x1

a1(b,a,s0,y0);
a2(d,c,s0,y1);
a3(c,d,s0,y2);
a4(a,b,s0,y4);

mux2x1 a5(y1,y0,s1,y3);
mux2x1 a6(y4,y2,s1,x3);
endmodule

You might also like