Timing analysis and CDC
What is the 4-bit binary value 0110 (decimal 6) converted to Gray code?
- A0111
- B0100
- C0101
Show answer and explanation
Answer: C. 0101
Binary-to-Gray conversion XORs each bit with the bit above it (the most significant bit is kept as is). As a formula, g = b XOR (b >> 1). XORing 0110 with 0011, its one-bit right shift, gives 0110 XOR 0011 = 0101. 0111 is the Gray code for 5 and 0100 for 7, the values on either side of 6. Counting 5→6→7 gives 0111→0101→0100, confirming that only one bit changes between adjacent values.