Home › Practice › RTL Design › Widen a signed number
Widen a signed number
EasyRTLcombinationalarithmetic
Your 4-bit thermometer reads from -8 to +7. It has to be sent on an 8-bit bus, and the number it shows must not change on the way.
Concept first. In two's complement the top bit has a negative weight. In 4 bits the top bit is worth -8, and the others are worth +4, +2, +1. So 1111 is -8+4+2+1 = -1, and 0011 is +3. When you move to 8 bits, the new top bits must make the value come out the same. Try it: what must the four new bits be to keep 1111 equal to -1? And to keep 0011 equal to 3? Then ask what decided the answer each time.
What to build.
- Input
x[3:0](a signed number), outputy[7:0]. yhas the same signed value asx: -8 stays -8, -1 stays -1, +7 stays +7.- The low 4 bits of
yarex. No clock.
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.