Re: [sv-ec] ERR-4


Subject: Re: [sv-ec] ERR-4
From: Dave Rich (David.Rich@synopsys.com)
Date: Thu Aug 21 2003 - 23:10:47 PDT


Steven,

As we discussed in Monday's SV-EC meeting, these fork-join any and none
constructs create situations that don't exist in Verilog, so there is
nothing to be consistent with. The spawned process created by these
forks have lifetimes that do not co-inside with the scopes they are
defined in, and the existing rules for automatic variables no longer
cover all the situations.

Look at this complete example:

module top();
initial mytask(2,1);
task automatic mytask(input integer n, m);
begin
   fork #n $display(n);
   join_none
#m;
endtask
endmodule

The task "mytask" is invoked at time 0, does the fork, and returns all
at time 1. Then the $display is executed at time 2. It references "n",
but what is the value? The task has ended and "n" has been deallocated
by the time the $display executes.

The V2K spec says "Because variables declared in automatic tasks are
deallocated at the end of the task invocation, they shall not be used in
certain constructs that might refer to them after that point." That is
OK in V2K because you can't refer to automatic variables outside their
scope, and any automatic variable referenced from within a fork/join is
guaranteed to be still active. In SV, "might" will require clarification
as the above example shows.
 
I see at least 2 alternative proposals in addition to the original one
Arturo and I made.

1. Disallow references to any automatic variables outside the scope of a
fork/join_any/none. The would make it extremely difficult to pass any
data to a forked process from a re-entrant task or using a variable from
a loop iterating statement. It basically requires setting up a mailbox
for each piece of automatic data used by the forked process(es).

2. End the lifetime of each variable when the last process that
references it dies. This could get quit involved to implement. And still
this does not solve the problem created by a fork/join_none in a looping
block.

If I were to modify the above example to use a normal fork/join, the
user would see 1,2,3 displayed. I think that is the behavior the user
expects for fork/join_any/join_none, and that is what the original
proposal gives the user.

Dave

Steven Sharp wrote:

>Dave,
>
>Are you suggesting that fork-join_none should treat automatic variables
>completely differently from fork-join (and from all other treatment of
>variables and scopes in the language)? This is clearly inconsistent with
>existing Verilog.
>
>Steven Sharp
>sharp@cadence.com
>
>
>
>

-- 
--
David.Rich@Synopsys.com
Technical Marketing Consultant
http://www.SystemVerilog.org
tele:  650-584-4026
cell:  510-589-2625



This archive was generated by hypermail 2b28 : Thu Aug 21 2003 - 23:12:24 PDT