***151

Gray code to Binary conversion for PSK and PAM

Given that we have discussed Binary to Gray code conversion, let us discuss the Gray to BInary conversion.

Conversion from Gray code to natural Binary

Let be the equivalent Gray code for an bit binary number with representing the index of the bit.

1. For ,

i.e, the most significant bit (MSB) of the Gray code is same as the MSB of original binary number.

2. For ,

i.e, bit of the Binary number is the exclusive-OR (XOR) of of the bit of the Gray code and of the bit of the binary number.

Simulation model

Look Up Table based Matlab/Octave mode for Gray to Binary conversion

clear
% binary to gray code conversion
ipBin = [0:15] ; % decimal equivalent for a 4-bit binary
opGray = bitxor(ipBin,floor(ipBin/2))
% Gray to Binary conversion
[tt ind] = sort(opGray); % sorting Gray code elements to form the lookup table
opBin = ind(opGray+1)-1; % picking elements from the array

The Trick from DSP-Guru to do Gray to Binary conversion, thanks to Jerry Avins.

clear
% binary to Gray code
ipBin = [0:15]
opGray = bitxor(ipBin,floor(ipBin/2))
% Gray code to binary
opBin = bitxor(opGray,floor(opGray/2^8)) ;
opBin = bitxor(opBin,floor(opBin/2^4)) ;
opBin = bitxor(opBin,floor(opBin/2^2)) ;
opBin = bitxor(opBin,floor(opBin/2^1)) ;

Concluding thoughts

1. As on now, I do not understand how the DSP Guru trick for Gray code to Binary works. Of course, if I figure out, I will update this post. :)

2. Having discussed Binary to Gray code conversion and Gray to Binary conversion, we are now armed  to discuss the bit-error rate probabilities for various modulation schemes (Recall: We have been discussing symbol error rate in Additive White Gaussian noise till date).

Thanks,
Krishna

Please click here to SUBSCRIBE to newsletter and download the FREE e-Book on probability of error in AWGN. Thanks for visiting! Happy learning.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

If you liked this post, you may leave a comment below, or subscribe to the RSS feed.

You may also find these posts relevant...
  • Binary to Gray code conversion for PSK and PAM
  • Binary to Gray code for 16QAM
  • Bit error rate for 16PSK modulation using Gray mapping
  • 16QAM Bit Error Rate (BER) with Gray mapping
  • Linear to log conversion
  • Comments

    No comments yet.

    Leave a comment

    (required)

    (required)