Subprograms and Packages 119
The first component instantiation statement for the transcomponent
labeled U1shows how conversion functions are used for inout ports. The
first port mapping maps portx1to a(0). Port a(0)is a ninevaltype;
therefore, the signal created by the port is a ninevaltype. When this sig-
nal is mapped to port x1of component trans, it must be converted to a
fourstatetype. Conversion function convert9valmust be called to com-
plete the conversion. When data is transferred out to port x1for the out
portion of the inout port, conversion function convert4statemust be
called.
The conversion functions are organized such that the side of the port
mapping clause that changes contains the conversion function that must
be called. When x1changes, function convert4stateis called to convert
the fourstatevalue to a ninevalvalue before it is passed to the con-
taining entity trans2. Conversely, when port a(0)changes, function
convert9valis called to convert the ninevalvalue to a fourstatevalue
that can be used within the transmodel.
Conversion functions are used to convert a value of one type to a value of
another type. They can be called explicitly as part of execution or implicitly
from a mapping in a component instantiation.
Resolution Functions
A resolution function is used to return the value of a signal when the sig-
nal is driven by multiple drivers. It is illegal in VHDL to have a signal with
multiple drivers without a resolution function attached to that signal.
A resolution function consists of a function that is called whenever one of
the drivers for the signal has an event occur on it. The resolution function
is executed and returns a single value from all of the driver values; this
value is the new value of the signal.
In typical simulators, resolution functions are built in, or fixed. With
VHDL, the designer has the ability to define any type of resolution function
desired, wired-or, wired-and, average signal value, and so on.
A resolution function has a single-argument input and returns a single
value. The single-input argument consists of an unconstrained array of
driver values for the signal that the resolution function is attached to. If
the signal has two drivers, the unconstrained array is two elements long;
if the signal has three drivers, the unconstrained array is three elements
long. The resolution function examines the values of all of the drivers and
returns a single value called the resolved value of the signal.