Skip to content

Instantly share code, notes, and snippets.

@Shashi18
Created March 22, 2019 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shashi18/d88dedc8d1fbf1c2863e258f1d7f0aeb to your computer and use it in GitHub Desktop.
Save Shashi18/d88dedc8d1fbf1c2863e258f1d7f0aeb to your computer and use it in GitHub Desktop.
module MUX1(a,b,sel,c);
input [3:0] a,b;
input sel;
output reg [3:0]c;
always @(*)begin
if(sel==0)
c = a;
else
c = b;
end
endmodule
module MUX2(a,b,sel,c);
input [7:0] a,b;
input sel;
output reg [7:0]c;
always @(*)begin
if(sel==0)
c = a;
else
c = b;
end
endmodule
module MUX3(a,b,sel,c);
input [7:0] a,b;
input sel;
output reg [7:0]c;
always @(*)begin
if(sel==0)
c = a;
else
c = b;
end
endmodule
module MUX4(a,b,sel,c);
input [7:0] a;
input [7:0] b;
input sel;
output reg [7:0]c;
always @(*)begin
if(sel==1'b0)
c = a;
else
c = b;
end
endmodule
module MUX4(a,b,sel,c);
input [7:0] a;
input [7:0] b;
input sel;
output reg [7:0]c;
always @(*)begin
if(sel==1'b0)
c = a;
else
c = b;
end
endmodule
module MUX4(a,b,sel,c);
input [7:0] a;
input [7:0] b;
input sel;
output reg [7:0]c;
always @(*)begin
if(sel==1'b0)
c = a;
else
c = b;
end
endmodule
module MUX4(a,b,sel,c);
input [7:0] a;
input [7:0] b;
input sel;
output reg [7:0]c;
always @(*)begin
if(sel==1'b0)
c = a;
else
c = b;
end
endmodule
module MUX8(a,b,c,d,f,g,sel,e);
input [7:0] a;
input [7:0] b;
input [7:0] c;
input [7:0] d;
input [7:0] f;
input [7:0] g;
input [3:0]sel;
output reg [7:0]e;
always @(*)begin
case(sel)
4'b1000:
e = b; //out
4'b0100:
e = c;
4'b0010:
e = d;
4'b0001:
e = f;
4'b0000:
e = a;
default:
e = g;
endcase
end
endmodule
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment