RE: [sv-ec] Initialisation of static data members

From: Rich, Dave <Dave_Rich_at_.....>
Date: Wed Aug 09 2006 - 08:21:16 PDT
Shalom,

Once you allow hierarchical references in an expression, it is after
elaboration and there's no need to follow constant expression or
constant function rules. It's perfectly reasonably to want to, and be
able to, call $random or the randomize() method.

So there's no need to restrict the initialization expression in a static
const variable in any way different from a non-const static variable. 

What I'm trying to say is that there's also no need to restrict the
initialization expressions in a static variable versus a non-static
variable other than the order of evaluation. That can either be left as
a user beware problem, or we can create some rules as I suggested
earlier

The BNF is in A.1.8 
| const { class_item_qualifier } data_type
                const_identifier [ = constant_expression ] ;


is incorrect because constant_expression does not allow hierarchical
references or calls to $random or randomize(), which is reasonable and
shown in the examples.

> -----Original Message-----
> From: Bresticker, Shalom [mailto:shalom.bresticker@intel.com]
> Sent: Wednesday, August 09, 2006 5:16 AM
> To: Rich, Dave; sv-ec@server.eda-stds.org
> Subject: RE: [sv-ec] Initialisation of static data members
> 
> Dave,
> 
> I don't understand.
> 
> First, I once asked what "or other constants" refers to. Steven Sharp
> wrote that he thinks it means "other static const variables".
> 
> But even assuming that "or other constants" refers to "constant
> expressions", then you just have a list of possible components of an
> expression to be assigned to a const variable, one of which is
constant
> expressions. You still could not conclude from that that hierarchical
> references are excluded from the entire list, only from that part of
the
> list.
> 
> Finally, I don't see that hierarchical references are excluded from
> "literals, parameters, local parameters, genvars, enumerated names".
> That quote does not say that the parameters, for examples, cannot be
> hierarchically referenced.
> 
> Shalom
> 
> 
> > -----Original Message-----
> > From: owner-sv-ec@server.eda-stds.org
[mailto:owner-sv-ec@server.eda-
> > stds.org] On Behalf Of Rich, Dave
> > Sent: Wednesday, August 09, 2006 12:11 AM
> > To: Brad Pierce; sv-ec@server.eda-stds.org
> > Subject: RE: [sv-ec] Initialisation of static data members
> >
> > It says "or other constants"
> >
> > In any case, a hierarchical name is not "an expression of literals,
> > parameters, local parameters, genvars, enumerated names, a constant
> > function of these, or other constants", so there is the
> contradictions.
> >
> > Dave
> >
> >
> > > -----Original Message-----
> > > From: owner-sv-ec@server.eda-stds.org
> [mailto:owner-sv-ec@server.eda-
> > > stds.org] On Behalf Of Brad Pierce
> > > Sent: Tuesday, August 08, 2006 2:02 PM
> > > To: sv-ec@server.eda-stds.org
> > > Subject: RE: [sv-ec] Initialisation of static data members
> > >
> > > The paragraph I quoted didn't use the phrase "constant
expression".
> > > Where's the contradiction?
> > >
> > > -- Brad
> > >
> > > -----Original Message-----
> > > From: Rich, Dave [mailto:Dave_Rich@mentor.com]
> > > Sent: Tuesday, August 08, 2006 1:57 PM
> > > To: Brad Pierce; sv-ec@eda-stds.org
> > > Subject: RE: [sv-ec] Initialisation of static data members
> > >
> > > Then the LRM contradicts itself because the next sentence says:
> > > "Hierarchical names are allowed because constants declared with
the
> > > const keyword are calculated after elaboration."
> > >
> > > Hierarchical names are not part of constant expressions.
> > >
> > > I think your example should be legal, although the LRM does not
> > mention
> > > any order dependencies. For random object stability, we already
> state
> > > that seeds are taken in the order they appear in the source, so I
> > don't
> > > see why we don't initialize variables in the order they appear
> within
> > a
> > > given scope. There should be no guarantees with hierarchical
> > references.
> > >
> > > In any case, calling a static method as part of a static
> > initialization
> > > of a class property should be legal.
> > >
> > > Dave
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: owner-sv-ec@server.eda-stds.org
> > [mailto:owner-sv-ec@server.eda-
> > > > stds.org] On Behalf Of Brad Pierce
> > > > Sent: Tuesday, August 08, 2006 8:47 AM
> > > > To: sv-ec@server.eda-stds.org
> > > > Subject: Re: [sv-ec] Initialisation of static data members
> > > >
> > > > According to 6.3.5 --
> > > >
> > > > "A static constant declared with the const keyword can be set to
> an
> > > > expression of literals, parameters, local parameters, genvars,
> > > > enumerated names, a constant function of these, or other
> constants.
> > > > [...] An automatic constant declared with the const keyword can
be
> > set
> > >
> > > > to any expression that would be legal without the const
keyword."
> > > >
> > > > >There are no special restrictions on the initializers of static
> > data
> > > > declarations
> > > > >or even const declarations.
> > > >
> > > > Wouldn't the following be illegal for a static constant c?
> > > >
> > > >     int v = 0;
> > > >     const int c = v;
> > > >
> > > > -- Brad
> > >
Received on Wed Aug 9 08:21:20 2006

This archive was generated by hypermail 2.1.8 : Wed Aug 09 2006 - 08:21:24 PDT