Neil,
Here are some specific examples of the underspecified behaviors. Assume
the following task for the code below
task t(ref int arg);
$display(arg);
#5 $display(arg);
arg = 1;
#5 $display(arg);
endtask
The key questions are what happens to an argument passed by reference if
the life of the task exceeds the life of the dynamically allocated
element. Is it illegal? The current LRM explicitly states that it is
legal, because this is a purely procedural context. For a queue element,
what reference is passed? Does the reference change when an elements is
added to the queue?
int DA[];
int QA[$];
int AA[*];
module foo;
initial begin
DA = new[3];
DA[2] = 2;
fork
tsk(DA[2]); // what will be displayed by the second $display in t?
#1 DA = new[3] {4,5,6} ; // is the reference still pointing to the
originally allocated array element, but no longer visible outside the task
join
fork
tsk(DA[2]); // what will be displayed by the second and third
$displays in tsk?
#1 DA = new[2] {4,5} ; // again , is the reference still pointing
to the originally allocated array element, but no longer visible outside
the task
// or, is the reference now
out of bounds( meaning that the task had to know it was passed a dynamic
element)
join
QA = {1,2,3,4};
fork
tsk(QA[$]); // what will be displayed by the second and third
$displays in tsk?
#1 QA = {0,QA}; // does t.arg still point to the element that
contains the value '4', or does it now point to the element that
contains '3'?
join
Neil Korpusik wrote:
> It looks like there is some confusion as to how pass by reference works.
> The description of the pass by reference behavior that Dave is
> requesting to
> be added doesn't match my understanding of how pass by reference actually
> works.
>
>> Summary: Pass by reference behavior of dynamically allocated objects
>> Description:
>> Section 10.4.2 needs to document how pass by works with dynamically
>> allocated objects, especially when the dynamic object is modified from
>> outside the scope of the calling task or function.
>
>
> I assume you are referring to pass by reference as stated in the summary
> even though here you just say "pass by".
>
>> If an explicit or implicit 'new' operation occurs after the
>> task/function
>> call, the reference should still point to the old data, which is no
>> longer
>> visible outside the scope of the call. Same functionality for passing an
>> element of an associative array.
>
>
> new() is used with more than one construct.
>
> objects - a call to new() will cause the object handle to refer to a new
> instance of the object. Both the calling scope and the called
> task will both immediately be referring to the new instance
> right
> after the call to new(). The original instance of the object
> will
> be garbage collected unless there is another handle which is
> still
> referring to it.
>
> dynamic array - a call to new[] can be used to change the size of the
> array.
> The old data will or will not be retained depending upon
> whether
> initial values are specified on the call to new[]. In this case
> both scopes continue to refer to the same array. Changes to the
> size and/or contents of the array will be visible to both
> scopes.
>
>> For strings and queues, an algorithm needs to be defined to preserve
>> references when they are modified.
>
>
> I am not sure what you are getting at here. The contents of a string or
> queue can be modified by either scope and those changes will then be
> visible in both scopes. The semantics of pass by reference for these
> constructs is no different than the pass by reference semantics for an
> integer.
>
> Neil
>
>
> -------- Original Message --------
> Subject: [SystemVerilog Errata 0000025]: Pass by reference behavior of
> dynamically allocated objects
> Date: Tue, 31 Aug 2004 10:39:44 -0700 (PDT)
> From: sv@eda.org
>
>
> The following bug has been ASSIGNED.
> ======================================================================
> http://www.eda.org/svdb/bug_view_page.php?bug_id=0000025
> ======================================================================
> Reported By: daver
> Assigned To: neil
> ======================================================================
> Project: SystemVerilog Errata
> Bug ID: 25
> Category: SV-EC
> Reproducibility: always
> Severity: minor
> Priority: immediate
> Status: assigned
> Type: Clarification
> ======================================================================
> Date Submitted: 07-02-2004 15:48 BST
> Last Modified: 08-31-2004 10:39 BST
> ======================================================================
> Summary: Pass by reference behavior of dynamically
> allocated objects
> Description:
> Section 10.4.2 needs to document how pass by works with dynamically
> allocated objects, especially when the dynamic object is modified from
> outside the scope of the calling task or function.
>
> If an explicit or implicit 'new' operation occurs after the task/function
> call, the reference should still point to the old data, which is no
> longer
> visible outside the scope of the call. Same functionality for passing an
> element of an associative array.
>
> For strings and queues, an algorithm needs to be defined to preserve
> references when they are modified.
>
>
> ======================================================================
>
> Bug History
> Date Modified Username Field Change
> ======================================================================
> 07-02-04 15:48 daver New Bug
> 07-02-04 15:48 daver Type => Clarification
> 08-06-04 11:12 pieper Description Updated
> 08-06-04 11:12 pieper Priority normal =>
> immediate
> 08-31-04 10:39 bpierce Assigned To => neil
> 08-31-04 10:39 bpierce Status new => assigned
> ======================================================================
>
-- -- David.Rich@Synopsys.com Technical Marketing Consultant and/or Principal Product Engineer http://www.SystemVerilog.org tele: 650-584-4026 cell: 510-589-2625Received on Mon Sep 13 17:30:30 2004
This archive was generated by hypermail 2.1.8 : Mon Sep 13 2004 - 17:30:35 PDT