Hardware Reference
In-Depth Information
sequence s2_v3( logic start, local input logic l_b[4]);
logic l_a = 1'b0;
dataType l_data;
@( posedge clk)
start ##1 ...
endsequence
The keyword local specifies that l_b is an argument local variable, while the
direction input specifies that l_b will receive its initial value from the associated
actual argument expression, after casting to the type of l_b . The keyword local
prevents preceding data type information from applying to the associated formal
argument, so the data type logic must be repeated for l_b .
The semantic equivalence of s2 and s2_v3 is exact. In general, an argument
local variable of direction input behaves exactly like a body local variable of the
same type, together with a dummy formal argument of the same type, where the
body local variable has a declaration assignment whose entire right-hand side is
a reference to the dummy formal argument. As a result, an input argument local
variable gets its initial value at the same time step in which body local variable
declaration assignments are performed.
Argument local variables are considered to precede body local variables. If a
sequence or property has both input argument local variables and body local
variables with declaration assignments, then the initialization assignments of the
input argument local variables are performed first. It is legal for the right-hand
side of a body local variable declaration assignment to reference an input argument
local variable. Figure 16.2 shows a variant of property p1 from the preceding section
illustrating this capability.
Argument local variables can also be declared of direction output or inout ,
but only in a sequence declaration. An argument local variable of a property must
be of direction input .An output argument local variable outputs its value to the
actual argument whenever the sequence matches. The actual argument must itself
be a local variable. An inout argument local variable behaves as a combination of
an input and an output argument local variable—it receives its initial value from
the actual argument and also outputs its value back to the actual argument whenever
the sequence matches. The actual argument must again be a local variable.
Figure 16.3 gives an example of a sequence s_arg_dirs with argument local
variables of all three directions and a property p_arg_dirs that instantiates it. The
instance of s_arg_dirs on Line 12 passes the expression e_i to l_s_i and passes
the local variables l_p_io and l_p_o to l_s_io and l_s_o , respectively. In the
evaluation of s_arg_dirs , l_s_i gets its initial value from e_i , while l_s_io gets
property p1_v2( local input byte l_byte);
byte l_byteMasked = l_byte & mask;
...
endproperty
Fig. 16.2
Body local variable declaration assignment referencing argument local variable
Search WWH ::




Custom Search