Subprograms and Packages 117
This method is much more verbose, requiring an intermediate temporary
signal for each port of the component being mapped. This clearly is not
the preferred method.
If a port is of mode INOUT, conversion functions cannot be used with
positional notation. The ports must use named association because two
conversion functions must be associated with each inout port. One con-
version function is used for the input part of the inout port, and the other
is used for the output part of the inout port.
In the following example, two bidirectional transfer devices are contained
in an entity called trans2:
PACKAGE my_pack IS
TYPE nineval IS (Z0, Z1, ZX,
R0, R1, RX,
F0, F1, FX);
TYPE nvector2 IS ARRAY(0 TO 1) OF nineval;
TYPE fourstate IS (X, L, H, Z);
FUNCTION convert4state(a : fourstate)
RETURN nineval;
FUNCTION convert9val(a : nineval)
RETURN fourstate;
END my_pack;
PACKAGE body my_pack IS
FUNCTION convert4state(a : fourstate)
RETURN nineval IS
BEGIN
CASE a IS
WHEN X =>
RETURN FX;
WHEN L =>
RETURN F0;
WHEN H =>
RETURN F1;
WHEN Z =>
RETURN ZX;
END CASE;
END convert4state;
FUNCTION convert9val(a : nineval)
RETURN fourstate IS
BEGIN
CASE a IS
WHEN Z0 =>
RETURN Z;
WHEN Z1 =>