Binary to Gray Conversion

Problem Description
π Design Challenge: The Universal Gray Encoder
In high-speed digital design, transitions are dangerous. When multiple bits of a binary counter flip simultaneously (like 0111 to 1000), hardware can misread intermediate states. The solution? Gray Code.
The Specification
Your task is to design a parameterized module that converts an $N$-bit binary input into its corresponding Gray code equivalent.
Gray Encoder |
Decimal | Binary Input | Gray Code Output |
0 |
|
|
1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
Below is the parameters :
Feature | Description |
Parameter: | The bit-width of the converter (Default = 4) |
Input: | The N-bit binary value to convert |
Output: | The resulting N-bit Gray code |
Verilog
Code Editor Access
Log in to write, run and submit your solution to this interview question. It's free.
