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

From: Rich, Dave <Dave_Rich_at_.....>
Date: Tue Aug 08 2006 - 08:23:50 PDT
Jonathon,

There are no special restrictions on the initializers of static data
declarations or even const declarations. Only the normal declare before
use, or scope visibility rules apply to the expression that makes up the
initializer.

The only thing special about a const is that you can't assign to it
after it is declared.  And the only exception is that a const class
property can be assigned in its constructor.

You are correct that each specialization of a parameterized class
creates another set of static members of a class. But there is currently
no syntax (BNF) to refer to a static member via the class scope
resolution operator when the class is parameterized. For example, if
Derived was a parameterized class: 

Derived#(value)::NN // is not legal reference

typedef Derived#(value) Derived_value;
Derived_value::NN  // is a legal reference

Dave


> -----Original Message-----
> From: owner-sv-ec@server.eda-stds.org [mailto:owner-sv-ec@server.eda-
> stds.org] On Behalf Of Jonathan Bromley
> Sent: Tuesday, August 08, 2006 2:31 AM
> To: sv-ec@server.eda-stds.org
> Subject: [sv-ec] Initialisation of static data members
> 
> Given a base class
> 
>   class Base;
>     static local int N = 0;
>     static function int nextN(); nextN=N; N++; endfunction
>   endclass
> 
> is it legitimate to call its static member function in the
> initializer of a static data member of a derived class?
> 
>   class Derived extends Base;
>     static local int NN = super.nextN(); // or Base::nextN() ??
>     function int getNN(); return NN; endfunction
>   endclass
> 
> My specific motivation here is that if Derived is a parameterized
> class, then I get a different value of NN for each specialization.
> 
> The example I show above has a common-sense interpretation (static
> parts of Derived are built after the static parts of Base, so the
> function call is reasonable) but I can easily see why implementations
> might wish to outlaw such a construct.  The LRM doesn't appear to
> place any restriction on the initializer for a static data member,
> although it *does* restrict the initialiser on a "const" to be
> a constant expression, and it *does* hint that static data
> members may often be const.
> 
> Thanks
> --
> Jonathan Bromley, Consultant
> 
> DOULOS - Developing Design Know-how
> VHDL * Verilog * SystemC * e * Perl * Tcl/Tk * Project Services
> 
> Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24
1AW,
> UK
> Tel: +44 (0)1425 471223                   Email:
> jonathan.bromley@doulos.com
> Fax: +44 (0)1425 471573                           Web:
> http://www.doulos.com
> 
> This e-mail and any  attachments are  confidential and Doulos Ltd.
> reserves
> all rights of privilege in  respect thereof. It is intended for the
use of
> the addressee only. If you are not the intended recipient please
delete it
> from  your  system, any  use, disclosure, or copying  of this
document is
> unauthorised. The contents of this message may contain personal views
> which
> are not the views of Doulos Ltd., unless specifically stated.
Received on Tue Aug 8 08:23:54 2006

This archive was generated by hypermail 2.1.8 : Tue Aug 08 2006 - 08:24:02 PDT