Re: [sv-bc] non local function can be used as constant function?

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Wed Mar 14 2007 - 10:32:45 PDT
Neil Korpusik wrote:
> Hi Gord,
> 
> I am wondering if you misread that portion of the LRM that you are
> quoting from. Doesn't it say that "Hierarchical names are allowed"?

I did say:

 > [...] your example is not legal since "constant function"
 > explicitly excludes heirarchical references.  The "heirarchical
 > names" would, I think, only apply to non-function names.


Constant functions have their own definition and allowing a
hierarchical call contradicts the definition of a constant
function call.  Yes, you could interpret the "hierarchical name"
as applying to such calls and overriding the meaning of
"constant function call" but I don't think that is really
the right direction in any case.

The reason that a hierarchical call was made non-constant to
begin with was to avoid nasty design elab relationships for parameters.
Since those issues don't apply for "const" declarations, there is no
reason to not just remove all initial value restrictions and treat a
"const" declaration as a normal variable declaration with the only
restriction being that the initializer is the only way to assign a
value.  This is essentially how a "const" formal for a task/function
behaves so such a relaxation would reduce the number of conceptual
variants of constantness.  We would end up with "constant" values
(i.e. values compatible with assignment to a parameter) and
"immutable" values (i.e. values that get an initial value and don't
change after that).

Gord.



> Neil
> 
> 
> 
> 
> Gordon Vreugdenhil wrote On 03/14/07 06:45,:
>> P1800-2005, 6.3.5 lists the following:
>>
>>     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.
>>
>> By this definition, your example is not legal since "constant function"
>> explicitly excludes heirarchical references.  The "heirarchical
>> names" would, I think, only apply to non-function names.  Strictly
>> speaking, a constant couldn't even be defined in terms of another
>> static constant since that isn't listed.
>>
>> That said, I think the paragraph is too restrictive.  There is
>> no design consistency issues that arise when you allow arbitrary
>> expressions (as there would be for parameters).  I think that
>> SV should clean this up to make this a "non-assignable variable"
>> and allow any initialization expression.
>>
>> As a side note, in 1364, "constant" essentially means "a value that
>> is legal for a parameter".  SV has broadened "constant" to include
>> values that are  not legal as the value of a parameter.
>>
>> I am beginning to see a fair amount of user confusion about the
>> two kinds of "constant" expressions.  Perhaps the traditional
>> 1364 term should change to "elaboration constant" or perhaps
>> "parametric".
>>
>> Gord.
>>
>> Dhiraj Kumar Prasad wrote:
>>
>>> Hi,
>>>
>>> can you tell me that a non local function i.e function is defined
>>> in some module and used in other module, can be used as constant
>>> function i.e like this
>>> const shortint myConst2 = botMod.myFunc(3,2);
>>> where myFunc is defined in a module named botMod.
>>>
>>> Thanks,
>>> Dhiraj
>>>
>>>
> 

-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com


-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Wed Mar 14 10:33:03 2007

This archive was generated by hypermail 2.1.8 : Wed Mar 14 2007 - 10:33:15 PDT