Binary to Gray Converter

Convert a 4-bit binary number to Gray code. The most significant Gray bit equals the binary MSB; every other Gray bit is the XOR of two adjacent binary bits: gray[i] = bin[i+1] ^ bin[i]. Input: bin, 4 bits. Output: gray, 4 bits. The testbench applies all 16 inputs and compares gray with the expected code.

Compiler Output
Waveform Viewer