Re: [vhdl-200x-ft] Some consistency proposals

From: David Bishop <dbishop@server.vhdl.org>
Date: Thu Aug 19 2004 - 13:07:33 PDT

Swart, Chuck wrote:

> I have a question about to_signed and to_unsigned.
> Are they reciprocals of each other?
> In other words is to_signed(to_unsigned( signed_val)) == signed_val
> and is to_unsigned(to_signed(unsigned_val)) == unsigned_val?

Yes, as long as "signed_val" is not negative.
There are cases (like a square) when the result will always be
positive. In which case the sign bit would always be "0", thus
the "abs" would be optomized out.

>>From the description it appears that to_signed increases the size by one bit.
> This might not be good.

If you know how to cast, you can do that. This is designed
for uses that want their hand held.
Also note that to_unsigned decreases the size by one bit.
Received on Thu Aug 19 13:09:14 2004

This archive was generated by hypermail 2.1.8 : Thu Aug 19 2004 - 13:09:38 PDT