Home › Practice › RTL Design › Reading the dial back
Reading the dial back
EasyRTLcombinational
The knob sent its position in Gray code. The computer wants an ordinary binary number.
Concept first. Converting binary to Gray code can be undone, so you can always get the binary number back. The top bit is the same in both. The other bits are found one by one from the top down: to get a bit you need the answer you just found for the bit above it, together with the Gray bit at this place. So each step uses the result of the step before. Check it with 2-bit Gray 11 (which is binary 10): the top bit is 1, so what must the next bit be?
What to build.
gray2bin(g)converts a 4-bit Gray code to binary.- Output
b[3:0]. It is the exact inverse of the Gray code of the previous problem: Gray 0010 gives 3, Gray 0110 gives 4. - No clock.
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.