Saturday, 20 July 2013

Design of 4 to 2 Encoder using if -else statements (Behavior Modeling Style) Verilog CODE -







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

0 comments :

Post a Comment

 
Design by Wordpress Theme | Bloggerized by Free Blogger Templates | coupon codes