Design of 4 to 2 Encoder using if-else statements (Behavior Behavior Style) - (Verilog CODE)-
Verilog CODE-
//-----------------------------------------------------------------------------
//
// Title : encoder4_2
// Design : verilog upload 2
// Author : Naresh Singh Dobal
// Company : nsdobal@gmail.com
// Verilog Programs & Exercise by Naresh Singh Dobal.
//
//-----------------------------------------------------------------------------
//
// File : 4 to 2 Encoder using if else statement.v
module encoder4_2 ( din ,dout );
output [1:0] dout ;
reg [1:0] dout ;
input [3:0] din ;
wire [3:0] din ;
always @ (din) begin
if (din==8)
dout = 0;
else if (din==4)
dout = 1;
else if (din==2)
dout = 2;
else
dout = 3;
end
endmodule
1 comments :
there is an error in else statement beacuse at the last din values may not be also 6,7,5 on that cases it should not work
Post a Comment