|
From: Martin W. <ic...@ma...> - 2019-08-11 07:43:05
|
Galen Seitz wrote:
> On 8/10/19 2:05 AM, Evan Lavelle wrote:
>> On 09/08/2019 19:17, Martin Whitaker wrote:
>>
>>> However, Icarus tries to protect the user against such problems by
>>> preferentially scheduling "always" processes ahead of "initial"
>>> processes at time 0.
>>
>> Wow. Never heard of that before. I wonder if other vendors do that?
>
> For the case that we've been discussing, I don't understand why it isn't
> always deterministic. Given the code below, doesn't the initial block
> generate an update event at time 0, and doesn't that cause the NBA inside
> the always block to be scheduled? If that is true, then when a sequential
> UDP with an initial statement is substituted for the initial block below,
> then doesn't the same logic apply?
>
> reg a;
> reg y;
>
> initial begin
> a = 0;
> end
>
> always @(a) begin
> y <= a;
> end
From the IEEE standard:
"The initial and always constructs are enabled at the beginning of a
simulation. The initial construct shall execute only once, and its activity
shall cease when the statement has finished. In contrast, the always
construct shall execute repeatedly. Its activity shall cease only when the
simulation is terminated. There shall be no implied order of execution
between initial and always constructs. The initial constructs need not
be scheduled and executed before the always constructs."
So if the initial construct executes before the always construct, the
procedural timing control "@(a)" won't have been executed when the
assignment to "a" occurs, so won't be waiting for an update event.
It may help to explain that
always @(a) begin
y <= a;
end
is exactly equivalent to
always begin
@(a) y <= a;
end
i.e. the "@(a)" is part of the first statement executed by the always
construct, not something that is continually active.
Given that other simulators don't suffer from this race, it seems quite
likely that other vendors also prioritise always constructs at the start of
simulation.
|