K
Kevin Neilson
Guest
Signed types (using numeric_std) can have widths bigger than 32, but the
to_signed() function only takes integers as an argument, so it seems to
be very difficult to assign values to large signed constants. For
example, in my code I have:
constant round_const: signed(c'range) := to_signed(2**x-1,c'length);
This doesn't work if x==32, because 2**32-1 is outside the range of an
integer (which must be <=(2**31-1)). I can't use a real as an argument,
and I can't convert a real to a signed without converting it to an
integer first, and then I have the same problem.
A workaround, for this case, seems to be:
constant round_const: signed(c'range):= (x-1 downto 0=>'1',others=>'0');
But that is weak.
-Kevin
to_signed() function only takes integers as an argument, so it seems to
be very difficult to assign values to large signed constants. For
example, in my code I have:
constant round_const: signed(c'range) := to_signed(2**x-1,c'length);
This doesn't work if x==32, because 2**32-1 is outside the range of an
integer (which must be <=(2**31-1)). I can't use a real as an argument,
and I can't convert a real to a signed without converting it to an
integer first, and then I have the same problem.
A workaround, for this case, seems to be:
constant round_const: signed(c'range):= (x-1 downto 0=>'1',others=>'0');
But that is weak.
-Kevin