Re: [sv-cc] Resolution of open vs dynamic arrays


Subject: Re: [sv-cc] Resolution of open vs dynamic arrays
From: Andrzej Litwiniuk (Andrzej.Litwiniuk@synopsys.com)
Date: Wed Apr 16 2003 - 15:09:03 PDT


Joao,

I'm not sure the proposed changes in wordings are correct.
See my comments.

> For SV 3.1 draft 5, the resolution of the open vs dynamic array issue will be
> as follows:
>
> Change section 26.1.2
>
> FROM:
> A formal argument is an open array when a range of one or more of its dimensions,
> packed or unpacked, is unspecified (denoted by using empty square brackets ([])).
>
> TO:
> A formal argument is an open array when a range of one or more of its dimensions,
> packed or unpacked, is unspecified. An unpacked open array is a multi-dimensional
> dynamic array formal and is thus denoted using the same syntax as dynamic arrays.

The new wordings does not specify the syntax for =packed= part of an open array.
Consider this:
        import "DPI" function foo(bit []i); // open packed array
        import "DPI" function boo(bit []i[10]); // open packed array

Then, I'm not sure I understand the sentence:
 "An unpacked open array is a [...] dynamic array formal".
What does it mean? Does it mean that:
 - only a dynamic arrays can be passed as an actual, without any copying?
 - an array can be modified (reallocated, elements added or deleted) on C side?

I hope this is sheer misunderstanding from my side; otherwise I would say
that a major semantical change happened disguised as a resoltion of syntactical issues.

> This agreement was reached after discussions between Arturo, David and myself.
>
> Basically, for this revision we went with Doug's choice no. 1; however, sv-ec
> has already started talking about relaxing the number of dimensions on dynamic
> arrays (dynamic array of dynamic arrays), which may lead us to a variant of
> choice no. 4.
>
> BTW, also please note that dynamic array formals in SV are really *dynamic* arrays;
> if a static array actual is given to a formal actual, the a new dyamic array is
> created and the contents of the static array are copied into it. From inside the
> function new elements can be added to the formal, elements removed or even the
> entire dynamic array deleted and/or reallocated (not that most users would do
> this, but they *could*)

Again, what does it mean that an open array is a dynamic array formal?
In the light of the above it would mean that open arrays are really *dynamic* arrays!
Such approach defies the original purpose of open arrays, which was to allow
for writing generic yet efficient code that could handle static arrays of
sizes unknown upfront.

Will it be still possible to pass a static array as an actual for an open array
formal of import function, without substantial overhead?

Besides, if a static array is passed as an actual array for =output= formal open array,
then what would happen, if the number of elements of the formal dynamic array
gets changed and does not match the static actual?
  

Frankly, I got totally lost with the new definition/interpretation/intent
of open arrays.
I'm not saying that the proposed resolution is worse (perhaps it really is)
than the originally proposed one, nevertheless all of the sudden it dramatically
changes what has seemed to be accepted long ago.

Regards,
Andrzej

==============================================================================
Andrzej I. Litwiniuk, PhD Principal Engineer VCS R&D
Synopsys, Inc TEL: (508) 263-8056
377 Simarano Drive, Suite 300, FAX: (508) 263-8069
Marlboro, MA 01752, USA
==============================================================================



This archive was generated by hypermail 2b28 : Wed Apr 16 2003 - 15:10:40 PDT