Overloaded items cannot be resolved if the argument types include common literals, i.e.,
- Resolve the ambiguity by qualifying the literal:
- General tip: Use qualification to avoid numerous problems where the compiler cannot seem to select a specific meaning, e.g., read (abc, string(abcabc));
TYPE twobit IS (0, 1);
TYPE fourbit IS (U, 0, 1, Z);
FUNCTION abc (x: twobit) RETURN INTEGER;
FUNCTION abc (x: fourbit) RETURN INTEGER;
y <= abc(0); -- Which function do we use?
Because literals in VHDL are semantically ambiguous (e.g., abc can be a string or a vector of enumerated values a, b, c), it is often impossible for the VHDL analyzer to determine the exact type of a literal, and thus resolve the overloaded function, if it is dependent on the literal.
For instance, note that in the upper example, '0' appears in the definition for both enumerated types, twobit and fourbit. Therefore, calling abc with '0' as its parameter does not allow for a distinction between the two versions of the abc function.
It is a good idea to use qualification when passing literals as subprogram parameters both to ensure that inadvertent ambiguities are avoided and to improve the readability of the VHDL code.