Re: [sv-bc] Ballot issue 216 (Mantis 693) generated identifiers

From: Steven Sharp <sharp_at_.....>
Date: Thu Apr 28 2005 - 12:46:32 PDT
I am also uncomfortable with this, for reasons similar to Gord's.

Some of it seems to be based on the old misconception that the syntax
block[N].ident for referencing an identifier in a generate for-loop
is some kind of "funny generated identifier name".  This was clarified
a while ago.  That is not a special syntax, but a normal hierarchical
name.  The block part is a array of scopes, like an instance array,
that was declared by the generate loop.  It is being indexed by the
constant expression N.  The ident part is the name of the identifier.
The whole thing is a hierarchical reference with a scope name, a dot,
and an object name.

The "genvar" part gets us right back into issues that were resolved
for genvars in 1364-2005.  It creates something that seems to be a single
object but which has different values depending on the physical position
of the reference in the source.

I also don't see the purpose of allowing these genvar references outside
the generate loops.  The examples given could all be done equally well
by using the constant expression instead of the genvar.  I.e. instead of

  genvar gv;
  gv = 3;
  moduledef inst(a[gv]);
  gv = 2
  moduledef inst(a[gv]);
  
You can do

  moduledef inst(a[3]);
  moduledef inst(a[2]);
  
Or if you want a symbolic name for a complex expression, use a localparam:

  localparam p1 = 3;
  moduledef inst(a[p1]);
  localparam p2 = 2;
  moduledef inst(a[p2]);
  
I realize that these were trivial examples, but I think the same argument
applies to arbitrarily complex examples.  Whatever value you assign to the
genvar could be used directly in building the identifier, or assigned to
a distinct localparam that then can be used in building identifiers.  I am
not clear on why genvars have been brought into this at all.

If there is something that can be done with this that is not obvious, I
would need to see a realistic example.

Separate from the genvar assignments, I would like to see some realistic
examples of where the ability to generate identifiers is needed, since there
may already be ways of getting equivalent functionality.

Steven Sharp
sharp@cadence.com
Received on Thu Apr 28 12:46:45 2005

This archive was generated by hypermail 2.1.8 : Thu Apr 28 2005 - 12:47:45 PDT