Sunteți pe pagina 1din 2

/////////////// ***USING ASSIGN SATEMENT*** ////////////////////////////////////

///////////////
module mux_using_assign(
din_0
, // Mux first input
din_1
, // Mux Second input
sel
, // Select input
mux_out
// Mux output);
//-----------Input Ports--------------input din_0, din_1, sel ;
//-----------Output Ports--------------output mux_out;
------------Internal Variables-------wire mux_out;
-------------Code Start----------------assign mux_out = (sel) ? din_1 : din_0;
endmodule //End Of Module mux
///////////////// *** USING IF STATEMENT *** /////////////////////////////////
//////////////////
module mux_using_if(
din_0
, // Mux first input
din_1
, // Mux Second input
sel
, // Select input
mux_out
// Mux output
);
//-----------Input Ports--------------input din_0, din_1, sel ;
//-----------Output Ports--------------output mux_out;
//------------Internal Variables-------reg mux_out;
//-------------Code Starts Here--------always @ (sel or din_0 or din_1)
begin : MUX
if (sel == 1'b0) begin
mux_out = din_0;
end else begin
mux_out = din_1 ;
end
end
endmodule //End Of Module mux
///////////////////// *** USING CASE STATMENT *** /////////////////////////////
///////////////////////////////
module mux_using_case(
din_0
, // Mux first input
din_1
, // Mux Second input
sel
, // Select input
mux_out // Mux output
);
//-----------Input Ports--------------input din_0, din_1, sel ;
//-----------Output Ports--------------output mux_out;
//------------Internal Variables-------reg mux_out;
//-------------Code Starts Here--------always @ (sel or din_0 or din_1)

begin : MUX
case(sel )
1'b0 : mux_out = din_0;
1'b1 : mux_out = din_1;
endcase
end
endmodule //End Of Module mux
////////////////////////////////////////////////////////////////////

S-ar putea să vă placă și