ParityCheck

January 2, 2008

Converting Binary to Grey code

Filed under: ASIC Design — paritycheck @ 8:32 pm

Here is a snippet of Verilog code that converts an 8-bit binary value to Grey code.  It makes use of Exclusive-OR to to generate Grey values.

grey_value[0] = ^binary_value[1:0];

grey_value[1] = ^binary_value[2:1];

grey_value[2] = ^binary_value[3:2];

grey_value[3] = ^binary_value[4:3];

grey_value[4] = ^binary_value[5:4];

grey_value[5] = ^binary_value[6:5];

grey_value[6] = ^binary_value[7:6];

grey_value[7] = binary_value[7];

Here is a snippet of Verilog code to convert from Grey to Binary using an 8-bit Grey value,

binary_value[7] = grey_value[7];

binary_value[6] = ^grey_value[7:6];

binary_value[5] = ^grey_value[7:5];

binary_value[4] = ^grey_value[7:4];

binary_value[3] = ^grey_value[7:3];

binary_value[2] = ^grey_value[7:2];

binary_value[1] = ^grey_value[7:1];

binary_value[0] = ^grey_value[7:0];

About these ads

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Shocking Blue Green Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: