[sv-bc] RE: [sv-ec] Is instance constant allowed outside class?

From: Rich, Dave <Dave_Rich@mentor.com>
Date: Wed Mar 31 2010 - 21:45:29 PDT

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. Hierarchical names

are allowed because constants declared with the const keyword are
calculated after elaboration.

const logic option = a.b.c ;

An automatic constant declared with the const keyword can be set to any
expression that would be legal

without the const keyword.

 

Note the use of the word can, not shall. There is no requirement that it
has to have an assignment. I would expect the behavior to be the same as
a non-const variable. The const keyword is a modifier that prevents
further assignments to that variable. That is all that it does.

 

Dave

 

From: Surya Pratik Saha [mailto:spsaha@cal.interrasystems.com]
Sent: Wednesday, March 31, 2010 9:11 PM
To: Rich, Dave
Cc: sv-ec@eda.org; sv-bc@eda.org; Bijoy Gopal Nandy
Subject: Re: [sv-ec] Is instance constant allowed outside class?

 

Hi Dave,
I could not find anything in "6.20.6" where it allows const declaration
without initialization. Please let me know if there is any LRM
specification.

Also, it is not clear what is the value of using a const declared
variable which does not have initialization, will it take default value
(like for 4 state, it will be all 'x', and for 2 state it will be all
'0')?

And if 'global constant' can be declared without initialization, then I
think some rewriting is required in "8.18 Constant class properties",
otherwise it is very confusing.

Regards
Surya

-------- Original Message --------
Subject: [sv-bc] RE: [sv-ec] Is instance constant allowed outside class?
From: Rich, Dave <Dave_Rich@mentor.com> <mailto:Dave_Rich@mentor.com>
To: Surya Pratik Saha <spsaha@cal.interrasystems.com>
<mailto:spsaha@cal.interrasystems.com> , sv-ec@eda.org, sv-bc@eda.org
Cc: "Bijoy Gopal Nandy" <bijoy@cal.interrasystems.com>
<mailto:bijoy@cal.interrasystems.com>
Date: Wednesday, March 31, 2010 8:21:05 PM

Yes, see section 6.20. There is no requirement to have an user specified
initialization.
 
The name global constant is a misnomer. It behaves like any other const,
which means it can take on different values each time the variable comes
into existence because the initialization expression may evaluate
differently.
 
The only thing special about a class instance constant is that it is
allowing a "write" to the const variable in the constructor instead of
the declaration initialization.
 
  

        -----Original Message-----
        From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf
Of
            

Surya
  

        Pratik Saha
        Sent: Wednesday, March 31, 2010 7:19 AM
        To: sv-ec@eda.org; sv-bc@eda.org
        Cc: Bijoy Gopal Nandy
        Subject: [sv-ec] Is instance constant allowed outside class?
         
        Hi,
        "8.18 Constant class properties" of SV 2009 LRM defines two
types of
        constants - global constant (initialization is must) and
instance
        constant (initialization is missing). Is it allowed to use that
            

instance
  

        constant syntax in non-class scope? For e.g.:
        module top;
            const int x; // Is it allowed?
        endmodule
         
        OR
        module top;
            class C;
               function f;
                  const int x; // Is it allowed
               endfunction
            endclass
        endmodule
         
        Some standard tools pass both the cases. Also OVM 2.1.1 has 2nd
type
            

of
  

        syntax usage in its source. Please let me know.
         
        --
        Regards
        Surya
         
         
         
         
        --
        This message has been scanned for viruses and
        dangerous content by MailScanner, and is
        believed to be clean.
            

 
 
  

 

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed Mar 31 21:48:43 2010

This archive was generated by hypermail 2.1.8 : Wed Mar 31 2010 - 21:48:52 PDT