Hardware Reference
In-Depth Information
when the sequence matches. A system of rules defines which local variables may
be referenced after match of that sequence. These rules ensure that a local variable
that might have inconsistent values in a thread of evaluation ensuing from the match
may not be referenced after the match until an unambiguous value is stored into it.
The rules can be checked at compile time and do not depend on the particular values
stored in the local variables in the evaluation threads.
There are mechanisms for passing values of local variables into instances of
named sequences or properties and out of instances of named sequences. Argument
local variables enable improved type checking and self-documentation of code
intent for these mechanisms.
We continue to assume that, unless otherwise specified, all assertions are clocked
at posedge clk and there is a default clocking specification.
16.1
Declaring Body Local Variables
Body local variables are declared immediately after the header of the named
sequence or property in which they appear. Here is an example:
sequence s1;
logic l_a, l_b[4];
dataType l_data;
@( posedge clk)
...
endsequence
This example declares l_a to be a local variable of type logic , l_b to be a local
variable that is an unpacked array of four elements of type logic , and l_data to be
a local variable of the user-defined type dataType . Body local variable declarations
precede the main sequence or property of the declaration. In particular, they precede
any clocking event or disable iff specified in the declaration.
The form of a body local variable declaration is a special case of the form of a
SystemVerilog variable declaration. The data type of a local variable declaration
must be explicit and must be one of the types allowed in assertion Boolean
expressions (see Clause 16.6 of the LRM [ 8 ]). The following example shows some
illegal local variable declarations. 1
property p_illegal_loc_var_decl;
logic l_a, [3:0] l_b; // packed dimension not in data type
l_c;
// no explicit data type
bit l_d [];
// dynamic array type not allowed
...
endproperty
1 Note that dynamic array elements can appear in expressions as long as the type of the expression
is cast compatible with an integral type. However a local variable itself cannot be of dynamic array
type.
Search WWH ::




Custom Search