Verilog practice / Problem 8
Binary to Gray code
Convert the 4-bit binary number b to Gray code g. In Gray code, neighbouring numbers differ in exactly one bit. The top bit stays the same, and each lower bit is the XOR of that binary bit and the one above it.
Ports
| Name | Direction | Bits |
|---|---|---|
b | input | 4 |
g | output | 4 |
How it's checked
The test tries the input combinations and checks every output for each one.
Stuck? Read the lesson Gray code pointers.
bin2gray.vCtrl + Enter runs