Re: [sv-bc] static variable initializers

From: Greg Jaxon <Greg.Jaxon_at_.....>
Date: Sun Sep 24 2006 - 15:19:17 PDT
Steven,

    I do not know the story of why "automatic" was dropped from this
part of the specification.  But the C++ rule for initializing local
static variables /is/ that this occurs once on first entry of the
block.  Although C++ does not standardize multi-threading, those
vendors which have provided it safely use a semaphore system to
stall all other entrants to the block until the variable is done
initializing - which happens on the first thread to reach the block.

    Adopting this scheme would answer most of your questions, even as
it raises others.  It also suggests one alternative to your assumption
that the restriction to "automatic" should be restored here.

Greg

Steven Sharp wrote:
> In section 11.6, there is text that says that variables declared in
> a fork..join/join_any/join_none block shall be initialized whenever
> execution enters their scope.
> 
> This text used to say "Automatic variables" in an earlier draft, but
> this changed to just "Variables" in the standard.  This seems to imply
> that static variables declared there would also be initialized at that
> time.  It is bad enough that the text just says variables, but the
> actual dropping of "automatic" from the older draft really seems to 
> imply a change.  I assume that this was a mistake, and that the word
> "automatic" should be added back.  Section 6.4 still says that statics
> should be initialized at the start of simulation.  
> 
> The paragraph also says that reference arguments can be used in the
> initialization values of variables in such blocks.  This only makes
> sense for initializers executed on entry.  If static variables are
> initialized at the start of simulation, it would make no sense for the
> initializer to refer to a reference argument at that point.  So that
> should specify automatic variables also.
> 
> I would also like to raise with the SV-EC another issue with static
> variable initializers.  There used to be a requirement inserted by the
> SV-BC that a static variable with an initializer had to be declared with
> an explicit "static" keyword.  This requirement was deliberate, to help
> avoid users becoming confused and thinking that the initializer would be
> executed every time the block was entered.  This confusion could easily
> happen, given that identical syntax could be either a static or automatic
> variable declaration, depending on context.  Apparently this requirement
> was removed by the SV-EC, without the SV-BC being aware of it.  We need
> to understand why this was done.
> 
> Steven Sharp
> sharp@cadence.com
> 
Received on Sun Sep 24 15:19:22 2006

This archive was generated by hypermail 2.1.8 : Sun Sep 24 2006 - 15:19:36 PDT