Behavioral modelling of 4-1 Line Multiplexer in Verilog

Field-Programmable Gate Arrays
Post Reply
User avatar
Magneto
Major
Major
Posts: 430
Joined: Wed Jul 15, 2009 1:52 pm
Location: London

Behavioral modelling of 4-1 Line Multiplexer in Verilog

Post by Magneto » Sat Nov 14, 2009 9:04 pm

mul4_1.JPG
mul4_1.JPG (27.92 KiB) Viewed 5489 times
//Behavioral description of 4-to-1- line multiplexer

module mux4x1_bh (i0,i1,i2,i3,select,y);
input i0,i1,i2,i3;
input [1:0] select;
output y;
reg y;
always @ (i0 or i1 or i2 or i3 or select)
case (select)
2'b00: y = i0;
2'b01: y = i1;
2'b10: y = i2;
2'b11: y = i3;
endcase
endmodule

// With Verilog 2001
module mux4x1_bh (i0,i1,i2,i3,select,y);
input i0,i1,i2,i3;
input [1:0] select;
output y;
reg y;
always @ (i0, i1, i2, i3, select)
case (select)
2'b00: y = i0;
2'b01: y = i1;
2'b10: y = i2;
2'b11: y = i3;
endcase
endmodule


// With Verilog 2001
module mux4x1_bh (i0,i1,i2,i3,select,y);
input i0,i1,i2,i3;
input [1:0] select;
output y;
reg y;
always @ ( * )
case (select)
2'b00: y = i0;
2'b01: y = i1;
2'b10: y = i2;
2'b11: y = i3;
endcase
endmodule



// With Verilog 2001
module mux4x1_bh (i0,i1,i2,i3,select,y);
input i0,i1,i2,i3;
input [1:0] select;
output y;
reg y;
always @ ( * )
case (select)
2'b00: y = i0;
2'b01: y = i1;
2'b10: y = i2;
2'b11: y = i3;
default: y = 1’bx;
endcase
endmodule
Post Reply

Return to “FPGA”