Can it be expected any time in the future that
signal aa : unsigned(7 downto 0);
aa <= 3;
will be supported? It just seems pretty obvious what is meant by
that.
Obvious to us, but not inherent in the definitions, I think.
I have long argued that VHDL would greatly benefit from
the ability to overload the assignment operation ":=".
This would allow specialised data types to do all kinds of
intelligent resizing, type conversion and so on. For
your example, I would want the numeric_std package to
incorporate this:
procedure ":=" (target: out unsigned; source: in integer) is
begin
target := to_unsigned(source, target'length);
end;
There would be no need, nor desire, to overload signal
assignment; its behaviour would follow the equivalent
variable assignment, together with all the existing
built-in signal assignment semantics.
There's just one, easily-fixed, wrinkle: The body of any
overloaded ":=" procedure will surely include some assignments.
To avoid circular definition problems, it would be necessary
to appeal to the built-in definition of := (target and source
checked for type equivalence by the compiler; array subtypes
checked for width equivalence at run time). For example,
a version of SIGNED that auto-resizes on assignment to fit
its target:
procedure ":=" (target: out signed; source: in signed) is
begin
std.standard.":="(target, resize(source, target'length));
end;
There are a few places in the language where there is an
implicit copy operation (copying of actual expression value
to a subprogram's "in" or "inout" formal, for example). The
overloaded := would also apply in such situations. Also,
the test expression in an "if" or "assert" could be regarded
as an implied copy from the actual expression to an implicit
boolean variable; in this way, overloading := for boolean
targets would allow you to get "if some_std_logic then"...
in a consistent and flexible way.
~~~~~~~~~~~~~~
Is this, or something like it, already on the table for
the current round of VHDL extensions?
Am I alone in thinking this might be a good idea?