Your statement is not exactly correct. "vectors" are not 2's
complement. numeric_std is 2's complement. SLV is still not
arithmetic at all. That is the difference.
I beg to differ. The new numeric_std_unsigned package assigns an
arithmetic interpretation to std_logic_vector, just like
std_logic_arith did.
Also, by using the conversion unsigned(my_slv) you are already
implying that the unconverted slv has the same bit representation as
unsigned, which is arithmetic. The tool is not allowed to convert/move
bits around in that conversion, so the new interpretation is in effect
placed on the old slv as well.
What you call "inaccurate" is a result of limited range of the
representation. What would you have the implementation do when the
"overflow" occurs? I can see three choices: roll over treating the
limited range as modulo arithmetic (minimum logic), saturate at the
max and min of the range (more logic and still "inaccurate") or just
not perform the operation (also more logic and who knows what
"inaccurate" really means in this case). Both can/should throw an
error if the operation is actually doing arithmetic. But it is often
that a counter is intended to roll over. For those I have to use an
explicit modulo operator.
If I tell the simulator or synthesis tool to add one to a value, the
new value better be larger than the old value, by exactly one, or it
should die trying (with an informative error message in the case of a
simulator). It should not silently assume that something else will be
good enough. Same goes for subtraction. If I need it do do something
besides adding or subtracting, then I will tell it what I want it to
do (either by resize() or mod, etc.)
Integer and sfixed/ufixed do this correctly, with the exception of
subtracting ufixed values.
I believe overloading operators has been suggested for the next go
around on the VHDL spec. I have no idea if this would create any
problems.
Rick
I think limiting overloaded assignment operators to re-sizing the same
type (between the expression and the target) would be pretty safe, but
it also would not handle the signed/unsigned issue. But because
integer and natural are the same base type, it can also handle signed/
unsigned conversions (with bounds checking). Those are different base
types in VHDL.
So maybe we limit the actions of overloaded assignment operators to
converting "closely related" types and resizing to this relatively
safe. If it works out, maybe we can extend overloaded assignments to
other areas, but I'd rather take baby steps and not break anything,
than take too big a step and cause bigger, unforseen problems.
Andy