Home › Practice › RTL Design › 4-bit signed absolute value
4-bit signed absolute value
EasyRTLcombinationalarithmetic
Compute the 4-bit unsigned magnitude (absolute value) of a 4-bit two's complement signed number.
- If
a >= 0(a[3] == 0),y = a. - If
a < 0(a[3] == 1),yis the two's complement negation~a + 4'd1(so-1becomes1,-7becomes7, and-8=4'b1000becomes4'b1000= unsigned8). - No clock.
No install and no sign-up needed. You write your answer in the editor and Nishkam checks it.