Gray to Binary Converter

Convert a 4-bit Gray code back to binary. The binary MSB equals the Gray MSB; each lower binary bit is the XOR of the binary bit above it and the Gray bit at that position: bin[i] = bin[i+1] ^ gray[i].

Input: gray, 4 bits.
Output: bin, 4 bits.

The testbench applies all 16 codes and compares bin with the expected value.

Contributed by Indicore

Compiler Output
Waveform Viewer