Sunday, 21 July 2013

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






Binary To GRAY Code Converter using if -else statements (Behavior Modeling Style) -


Output Waveform :  Binary to GRAY Code Converter



Verilog CODE -



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

module binary_to_gray ( 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 = 6;
else if (din==5)
dout = 7;
else if (din==6)
dout = 5;
else if (din==7)
dout = 4;
else if (din==8)
dout = 12;
else if (din==9)
dout = 13;
else if (din==10)
dout = 15;
else if (din==11)
dout = 14;
else if (din==12)
dout = 10;
else if (din==13)
dout = 11;
else if (din==14)
dout = 9;
else
dout = 8;
end

endmodule

0 comments :

Post a Comment

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