Re: [sv-bc] Re: task/function actuals for mode "ref"

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Wed Jan 16 2008 - 10:36:30 PST
Greg Jaxon wrote:
> By excluding slice-selection from t/f ref mode arguments is it your
> intent to limit the kinds of selects available to those with constant
> element indices?   If so, shouldn't dynamic bit selects also be illegal?

Bit selects are illegal (dynamic or not).  You cannot select into
a packed item of any kind.

I certainly don't intend to limit things to constants and my proposal
makes no statement to that effect.  The following should
certainly be legal:
     function automatic void f(ref int x);
       x++;
     endfunction
     int A[10];
     initial for (int i = 0; i < 10; i++) f(A[i]);

What is disallowed is something like the following:
     function automatic void f(ref bit x);
       x = 0;
     endfunction
     bit [15:0] A;
     initial f(A[1]);   // or any other select into A

That restriction is for the same reasons that things like
(expr & 0xf) is illegal in C++ reference passing -- the
"ref" is expected to be implemented as an "address of"
operation and we can't require implementations to address
into a packed value for efficiency reasons.

The upshot is that "ref" cannot *always* be used to replace
inout since some actuals for an inout would be illegal
when used with a "ref" formal.

I disallowed slicing for refs since whether that opens up various
other concerns about "outdated" refs that we had enough problems
with in the direct cases.  One could, in general, argue that an
implementation should be required to handle slices but that would
mean that an implementation *in all cases* would have to ensure
that the "address of" a slice was compatible with the natural
address.  I didn't want to require that at this point in the language
development since there are some situations in which implementations
could conceivably not want to provide that guarantee.

Gord



> In conventional languages, call-by-reference fully evaluates the
> an lvalue's selection expression before entering the task/function.
> The reference that is passed consists of whatever offset, pointer,
> or other access method conventionally refers to a certain fixed location.
> In these languages, dynamic selection expressions are the key discriminant
> between call-by-reference and call-by-name.
> 
> Can you expand on why scalar dynamic indexing is OK, but vector dynamic
> indexing isn't in this case?  Or perhaps I've misunderstood the proposal...
> 
> Greg Jaxon
> 
> Gordon Vreugdenhil wrote:
>> Based on some initial feedback, I've entered this as
>> Mantis 2235 with the proposal attached and set it as
>> a BC issue.
>>
>> Gord
>>
>> Gordon Vreugdenhil wrote:
>>> At the last BC meeting, 2097 was discussed and I observed that
>>> there is language related to ref modes that uses similar
>>> terminology but for which a "wider" interpretation was expected.
>>> I offered to write up a clarification.  I've attached a
>>> first cut clarification below; if there is not objection, I
>>> can enter a Mantis item with the proposal and we can see how/if
>>> this can get into 1800.  At very least I want to make sure that
>>> there is "intent agreement" on this.
>>>
>>> Gord
>>>
>>> ------------------------------------------------------------------------
>>>
>>> Section 13.5.2
>>>
>>> CHANGE:
>>>
>>>  
>>>
>>> The semantics of assignments to variables passed by reference is that
>>> changes are seen outside the subroutine immediately (before the
>>> subroutine returns). Only variables, not nets, can be passed by
>>> reference.  Only variables, not nets, can be passed by reference.
>>>
>>>  
>>>
>>> TO:
>>>
>>> The semantics of assignments to variables passed by reference is that
>>> changes are seen outside the subroutine immediately (before the
>>> subroutine returns). Only variables, not nets, can be passed by
>>> reference.  Only variables, not nets, can be passed by reference.
>>>
>>>  
>>>
>>> Only the following shall be legal to pass by reference:
>>>
>>> ·        a variable
>>>
>>> ·        a member select of a class property or  a member of an
>>> unpacked structure
>>>
>>> ·        a non-slice indexed select of an unpacked array.
>>>
>>> Nets and selects into nets shall not be passed by reference.
>>>
>>>  
>>>
> 

-- 
--------------------------------------------------------------------
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 Jan 16 10:37:03 2008

This archive was generated by hypermail 2.1.8 : Wed Jan 16 2008 - 10:37:30 PST