VHDL-93 allows type conversions and conversion functions in association lists.
A conversion function is a special case of a function with only one argument.
Let's look at the declaration of to_bit
:
function to_bit(s : std_ulogic; xmap : bit := '0') return bit;
Although to_bit(s)
looks like a valid conversion function, it's not, because the declaration contains two arguments.
The second argument xmap
is used as the result when is_x(s)
is true.
This is not a ModelSim bug, but maybe the error message is a bit cryptic. ModelSim figures that to_bit
is meant to be a conversion function, but refuses to use it, because it has a second argument, and is thus not a valid conversion function.
A simple wrapper function can solve the problem:
function to_bit(s : std_ulogic) return bit is
begin
return to_bit(s, '0');
end;
Note that the function can also have the name to_bit
, because VHDL supports function overloading. It would be nice to have this in the package std_logic_1164.