[sv-ac] local variables and sequence instances


Subject: [sv-ac] local variables and sequence instances
From: John Havlicek (john.havlicek@motorola.com)
Date: Thu Mar 20 2003 - 11:53:44 PST


All:

Please find below proposal 5b. It does not include any
specific syntax, as syntax is out-of-scope of SV-AC and
I have no idea what the syntax group is coming up with
for arguments of sequence definitions.

Best regards,

John Havlicek

========================================================================
DISCUSSION: Some care needs to be taken in the way local variables
flow into and out of instances of named sequences in order to make
management of names reasonable for users. There are two problems
with using the forward flow semantics after instances of sequences
are expanded in a macro fashion:

1. Local variables in the instantiating context may overshadow
   references in the definition of the instantiated sequence
   that were intended to bind otherwise (e.g., to design signals
   of the same name). [Undesirable inward flow.]

2. Local variables in the definition of a named sequence may
   overshadow references in the instantiating context that
   were intended to bind otherwise. [Undesirable outward flow.]

Both problems are illustrated in the following example:

   sequence s(v) = (a; (b==v) (int x=e) ; 1; c==x);

   sequence t = (u (int b=w, int x=z); s(x); y==x+b);

If the instance of s in t is expanded as a macro, then we get

   (u (int b=w, int x=z); (a; (b==x) (int x=e) ; 1; c==x); y==x+b);

As a result, the reference to b in "b==x" now means the local
variable that was sampled in "int b=w", not whatever b meant in
the context of the definition of s. This is an example of
undesirable inward flow.

Also, the reference to x in "y==x+b" now means the local variable
that was sampled in "int x=e", rather than the one sampled in "int x=z".
This is an example of undesirable outward flow.

The following proposal is intended to eliminate undesirable inward
and outward flow, while still allowing both as controlled by
the user through argument passing. This proposal does not
describe the specific syntax for achieving the argument passing,
as it is out-of-scope of SV-AC.

PROPOSAL:

1. A sequence definition will distinguish input and output formal
   arguments.

2. Local variables sampled in the instantiating context will flow
   into an instance of a sequence only if passed in as actual arguments
   to input formal arguments of the sequence. A local variable passed
   as an actual argument to an input formal argument must be declared and
   sampled in the instantiating context before the instance of the
   sequence.

3. Local variables sampled in the definition of the instantiated sequence
   will flow out of an instance of the sequence only if they are output
   formal arguments of the sequence definition. The values passed out
   will be bound to the actual arguments as local variables in the
   instantiating context. This proposal does not say how the actual
   arguments must be declared.
   a. One possibility is that the actual argument constitutes a local
      variable declaration and sampling at completion of the named sequence
      instance.
   b. Another possibility is that the actual argument must be declared
      and sampled before the instance of the sequence.

4. References to names in a sequence definition that are not formal
   arguments will be bound according to scoping rules at the sequence
   definition, not according to scoping rules at instances of the
   sequence.



This archive was generated by hypermail 2b28 : Thu Mar 20 2003 - 11:55:00 PST