superman321
Joined: 20 Dec 2005
Posts: 4
|
Posted:
Sat Jan 21, 2006 7:04 pm Post subject:
2's complement |
|
|
Hi all,
i have a doubt regd. the 2's complement..i have to write a VHDl code for the addition and subtraction of the 2's complement; where A and B are 32 bit each and the output is also 32 bits..if i am not wrong..i think the addition of the 2's compliment is usual addition and i can write:
c <= signed(a) + signed (b);
and the subtraction is where i have to use the 2's compliment...and can i write it as
c <= signed(a) - signed (b);
are these right???.......i have to represent the output in HEX and i have a component that converts the outputs (32 bits) to display in LED (7 segemnt)...i am confused abt the range of the value that will be displayed (in both the addition and subtraction) and abt the overflow...
IS THERE A BETTER WAY OF WRITING THE 2'S COMPLIMENT....???????
PLZ THROW SOME LIGHT....
CHEERS |
|