FW: arguments on removal of "static"


Subject: FW: arguments on removal of "static"
From: Srouji, Johny (johny.srouji@intel.com)
Date: Fri Nov 22 2002 - 02:26:12 PST


Hi All,

Per my AR, here is Peter answer regarding excluding the static keyword from
the language.

Steven, I hope this answers your questions. Your questions are put in " ...
".

Regards,

--- Johny.

----------------------------------------------------------------------------

"One of these differences is the existence of the "static" keyword in
SystemVerilog. This keyword was included in the original proposal to the
IEEE VSG for reentrant tasks and functions. After much discussion, it was
decided to exclude it from the standard. None of the reasons have changed
since then."

Testbenches have become more important in recent years, and these resemble
software more than designs.

"The purpose of the "static" keyword is to allow declaring static variables
in automatic tasks or functions. Some kinds of subroutines need some static

storage. The argument in favor of the "static" keyword is that it allows
declaring that static storage inside the subroutine, making its scope more
local. This is generally considered to be good software engineering
practice.
However, this argument is much weaker for Verilog than for C."

I disagree that the argument is weaker. C files define scope, whereas
Verilog files do not. The testbench may be a large module.

"First of all, static variables are never really local in Verilog. A static

variable can be referenced from anywhere by using a hierarchical path name.
"

I think it is difficult to use a hierarchical path name by accident.

"Internal static variables are already unusual in C. The kinds of things
they tend to be used for are even less likely to be needed in Verilog."

Coverage is as widely used in hardware and in software, and is one of the
applications for internal static variables.

"Using a static variable generally prevents a subroutine from being
reentrant.
If a subroutine does not need to be reentrant, a normal Verilog subroutine
will work, and all of its variables are static. If a user believes they
need
to declare a subroutine as automatic but also need local static variables,
they are probably wrong. If they wrote such a thing, it would probably not
work as expected. However, if there really is a valid reason for needing
this, there is an adequate solution."

A simple example is counting the number of times a task is called. This
does not prevent the task from being reentrant.

"In any block structured language other than C and its descendents, if a
variable is needed with a longer lifespan than its scope, it is declared
in a surrounding scope. This is considered reasonable, even though most
of these languages place a greater emphasis on supporting good software
engineering practices than C does. Avoiding an extra mechanism to support
local static variables is considered to be worth the slight reduction in
locality. In Verilog, the scope just above the subroutine scope is always
sufficient. Variables there are completely static.

There is actually an advantage to requiring the subroutine to use a static
variable declared outside of itself. It makes clear that there is a single
shared variable that is being referenced by all activations of the
subroutine.
This is a major issue since Verilog is inherently multi-threaded. It could
have multiple processes executing the same task at the same time, accessing
the same variable. This is a form of nonlocality that the user may not
have considered. The false appearance of locality is more dangerous than
requiring clear and explicit nonlocality. "

This goes against the normal idea that names should be as local as possible
to avoid accidental use.

"The other major argument against including this mechanism is the need to
reserve the extra keyword "static". Any time a new reserved word is added,
it creates a potential backward compatibility issue. New keywords need
strong justification. The name "static" may be used in existing designs,
especially since static discharge protection circuitry may be included in
netlists."

I have never seen the word "static" used in a netlist.
  
Peter.

----------------------------------------------------------------------------
------------------



This archive was generated by hypermail 2b28 : Fri Nov 22 2002 - 02:26:54 PST