Re: Is this a race?
- From: sharp@xxxxxxxxxxx
- Date: 12 Apr 2006 14:13:14 -0700
The #0 will cause the execution of the statement to be deferred, much
like an actual delay would. This is actually specified in the LRM,
though not completely correctly. The history is presumably something
like the following.
Verilog-XL apparently did not just throw a delay control of #0 away,
but handled it like any other delay control. It suspended the process
and re-scheduled it on the time queue for a time 0 away from now, i.e.
the current time queue. This deferred it to the end of the current
time queue (or perhaps put it on a new time queue to be executed
immediately after the current one, which has a similar effect). The
result was that a delay control of #0 would cause the current process
to be deferred until after all the other processes that were triggered
by the same inputs. Users started relying on the bad practice of
inserting #0 in their procedural code to try to resolve race conditions
(or if that wasn't sufficient, #0 #0 or #0 #0 #0).
So much legacy code relied on this, that a guarantee was put into the
LRM to try to ensure that this bad code would continue to work. In the
section on deterministic and nondeterministic event ordering, they
essentially needed to specify that #0 would defer a process to the end
of the event queue. But since the specification of nondeterministic
event ordering allowed processing the events on the queue in any order,
that wouldn't have helped. So they specified that it would go onto a
separate "inactive" queue until the "active" queue was processed, and
then the "inactive" queue would become the "active" queue.
The problem with this way of specifying it is that it is too strong.
There was never really a separate "inactive" queue; it was just a way
of saying "after the currently scheduled events". If taken literally,
the way it is specified implies that #0 not only defers until after the
currently scheduled events, but also after any events scheduled later
for the current time, as long as those events don't go onto the
"inactive" queue also. For example, it implies that a #0 delay is
bigger than an arbitrary number of continuous assignment delays in
series, which was not true in Verilog-XL.
Then the SystemVerilog committees got the idea that this "inactive"
queue was an actual separate queue that guaranteed this much stronger
ordering, and started building more elaborate things that assumed it.
Not good.
.
- References:
- Is this a race?
- From: Chris F Clark
- Re: Is this a race?
- From: John_H
- Is this a race?
- Prev by Date: Re: Is this a race?
- Next by Date: Re: Is this a race?
- Previous by thread: Re: Is this a race?
- Next by thread: Re: Is this a race?
- Index(es):
Relevant Pages
|