Design a Binary to Gray Code Converter that converts a 4-bit binary input into its 4-bit Gray code equivalent.
Requirements
Module name:bin2gray4
Inputs:
bin_in[3:0]
Outputs:
gray_out[3:0]
Expected behavior (full truth table)
bin
gray
bin
gray
bin
gray
bin
gray
0000
0000
0100
0110
1000
1100
1100
1010
0001
0001
0101
0111
1001
1101
1101
1011
0010
0011
0110
0101
1010
1111
1110
1001
0011
0010
0111
0100
1011
1110
1111
1000
Note - Binary to Gray conversion
The most significant bit (MSB) of the Gray code is the same as the MSB of the binary input. Each subsequent bit of the Gray code is obtained by XORing the current bit of the binary input with the previous bit.