130 Chapter Five
END cresolve;
END composite_res;
Type xtypedeclares the record type for signal xbus. Type xtypevector
is an unconstrained array type of xtypevalues used for the resolution
function input argument t. Constant notdrivendeclares the value of the
record that is used to signify that a signal driver is not driving. Negative
number values were used to represent the notdriven state because, in this
example, only positive values are used in the addrand datafields. But
what happens if all of the values must be used for a particular type? The
easiest solution is probably to declare a new type which is a record, con-
taining the original type as one field of the record, and a new field which
is a boolean that determines whether the driver is driving or not driving.
In this example, resolution function cresolvefirst checks to make certain
that at least one driver value is passed in argument t(drivers can be turned
off using guarded signal assignment). If at least one driver is driving, the
loop statement loops through all driver values, looking for driving values.
If a driving value is detected, and it is the first, then this value is assumed
to be the output resolved value, until proven otherwise. If only one driving
value occurs, that value is returned as the resolved value.
If a second driving value appears, the output is set to the nondriven
value, signifying that the outcome is uncertain, and the ASSERTstatement
writes out an error message to that effect.
In this example, the negative numbers of the integer type were not
used except to indicate whether the signal was driving or not. We reserved
one value to indicate this condition. Another value could be reserved to
indicate the multiple-driven case such that when multiple drivers are
detected on the signal, this value would be returned as the resolved value.
An example might look like this:
CONSTANT multiple_drive : xtype := (-2,-2);
This constant provides the capability of distinguishing between a non-
driven signal and a multiple-driven signal.
RESOLVED SIGNALS So far we have discussed how to write resolu-
tion functions that can resolve signals of multiple drivers, but we have not
discussed how all of the appropriate declarations are structured to ac-
complish this.
Resolved signals are created using one of two methods. The first is
to create a resolved subtype and declare a signal using this type. The
second is to declare a signal specifying a resolution function as part of
the signal declaration.