Skip to content

gray_code

Martyn van Dijke edited this page May 7, 2021 · 1 revision

Gray coding

The purpose of the gray coding is to modulated the bits in such a way that two subsequent symbols differ one bit. Using this approach in the end we can easily recover from off by one bit errors which have a (relatively) high change of happening.

Gray mapping is implemented in the following way, by making a simple for loop over the input array and mapping the bits.

  for (int i = 0; i < noutput_items; i++) {
    out[i] = (in[i] ^ (in[i] >> 1u));
  }
Clone this wiki locally