Sunday, 21 July 2013

Design of GRAY to Binary Code Converter using if-else statements (Behavior Modeling Style) Verilog CODE-






Design of GRAY to Binary Code Converter using if-else statement (Behavior Modeling Style)-


Output Waveform  :   GRAY to Binary Code Converter


Verilog CODE-


//-----------------------------------------------------------------------------
//
// Title       : GRAY_to_Binary
// Design      : verilog upload 2
// Author      : Naresh Singh Dobal
// Company     : nsdobal@gmail.com
// Verilog Programs & Exercise by Naresh Singh Dobal.
//
//-----------------------------------------------------------------------------
//
// File        : GRAY to Binary code converter using if else statements.v

module GRAY_to_Binary ( din ,dout );

output [3:0] dout ;
reg [3:0] dout ;

input [3:0] din ;
wire [3:0] din ;


always @ (din) begin
if (din==0) 
dout = 0;
else if (din==1) 
dout = 1;
else if (din==2) 
dout = 3;
else if (din==3) 
dout = 2;
else if (din==4) 
dout = 7;
else if (din==5) 
dout = 6;
else if (din==6) 
dout = 4;
else if (din==7) 
dout = 5;
else if (din==8) 
dout = 15;
else if (din==9) 
dout = 14;
else if (din==10)
dout = 12;
else if (din==11)
dout = 13;
else if (din==12)
dout = 8;
else if (din==13)
dout = 9;
else if (din==14)
dout = 11;
else
dout = 10;
end


endmodule

0 comments :

Post a Comment

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