Hardware Reference
In-Depth Information
16.5
Input and Output with Local Variables
This section describes the mechanisms provided by SystemVerilog for passing
values of local variables into instances of named sequences and properties and out
of instances of named sequences. Special rules apply when passing values into an
instance of a named sequence to which a sequence method (
triggered
or
matched
)
is applied. There is no notion of passing values of local variables out of instances of
named properties.
16.5.1
Input with Local Variables
In general, any local variable that is assigned a value at the point of instantiation
of a named sequence or property may have its value passed into that instance
simply by referencing the local variable as an entire actual argument expression
of the instance or as a proper subexpression of an actual argument expression of the
instance. The local variable itself cannot be referenced from within the instance, so
the instance does not track changes to the local variable or to copies of it that might
occur in the instantiating context. Rather, the value of the local variable passed into
the instance remains constant throughout the evaluation of the instance.
The following simple example illustrates input of a local variable to an instance
of a named property:
property
p_no_repeat_ttype(
1
transType varying_ttype, captured_ttype
2
);
3
start[->1:2]
4
|-> varying_ttype != captured_ttype;
5
endproperty
6
property
p_ttype_check;
7
transType l_ttype;
8
(start && (ttype == INV || ttype == PRG), l_ttype = ttype)
9
|=> p_no_repeat_ttype(
10
.varying_ttype(ttype), .captured_ttype(l_ttype)
11
);
12
endproperty
13
This example is an equivalent recoding of the property
p_ttype_check
from
Sect.
16.4
. It uses an auxiliary property,
p_no_repeat_ttype
. In the instance
of
p_no_repeat_ttype
in Lines
10
-
12
, the signal
ttype
ispassedtothe
formal argument
varying_ttype
, while the local variable
l_ttype
is passed
to the formal argument
captured_ttype
. During an evaluation of this instance
of
p_no_repeat_ttype
, the formal argument
captured_ttype
behaves as
a constant equal to the value of the local variable
l_ttype
at the time the
evaluation begins. Referring back to the waveform in Fig.
16.9
, the evaluation of
p_ttype_check
beginning at time 20 causes an evaluation of
p_no_repeat_ttype
Search WWH ::
Custom Search