KJ said:
How does the compiler know whether it should choose the '=' function
that is part of the standard packages or the new '=' that you define?
The answer is that it can't since both forms of '=' take the same
parameter types and return the same type. In that situation, the
compiler usually complains that there are multiple functions that can
be used here so the usage is ambiguous.
And that is exactly why the ModelSim has the -explicit compile option and
the "Explicit = 1" setting in modelsim.ini. If that is in effect, it will
use the explicitly defined operator for that type (in contrast to the
implicit operator that came with the type definition itself), even if the
operator is defined in another package than the type. If I recall
correctly, this violates the LRM. It only allows to (re-)define an operator
for a type in the same package where the type is defined.
(So that's yet another reason why not to use the ieee.std_logic_(un)signed
packages: they redefine operators for std_logic_vector are defined in
ieee.std_logic_1164 and by doing so violate the LRM.)
If you want to define operators that honors '-' as don't care, the best way
is to create your own type and define operators for that to your heart's
content. Exactly how it is done for e.g. signed and unsigned in
ieee.numeric_std.
TYPE slv_dc IS ARRAY(natural RANGE <>) of std_logic;
FUNCTION "=" (L, R: slv_dc) RETURN boolean;
etc....
Of course, just as with (un)signed and std_logic_vector, you can't assign
one to the other, because they are types. You'll need conversion like
std_logic_vector(my_slv_dc) and slv_dc(my_slv), where the type of my_slv_dc
is slv_dc and the type of my_slv is std_logic_vector.
On the other hand: why bother and just use the std_match function from
numeric_std, or your own defined function. OK, you'll lose the coolness of
the operator style of writing and can't write "IF a=b THEN ... END IF;".