Verilog Coding Exercise · Combinational I
Binary to Gray Code Converter
XOR each bit with its neighbor and the ambiguity disappears.
Converts a 4-bit binary value into Gray code, where only one bit ever changes between two consecutive values — the same property that makes Gray code safe for crossing clock domains.