M
Michael Katelman
Guest
On Apr 8, 11:16 am, Stephen Williams <spamt...@icarus.com> wrote:
originally, although the standard suggests your x is correct y is
incorrect interpretation is valid, which is equivalent to one of the
cases in my original post, it JUST FEELS "wrong". That is, as if the
standard shouldn't allow it. This is a great thread , it's really
helping me with the work that I'm doing.
Along these lines, Marco and Muzaffer's back-and-forth on
always @(a or b) begin
x = a + b;
end
is really the key question, at least in my mind. If you think of each
always block as having a sort of "program counter", then the question
is where are the legal spots for it to point? If I understand
correctly, Marco's interpretation is that there are two spots, the @(a
or b) and the x = a + b, and Muzaffer is treating the @(a or b) begin
x = a + b end as a single spot. Again, one FEELS like the standard
should not allow x and y to end up with different values, Muzaffer's
interpretation, but Marco's interpretation seems sensible to me based
on 11.4.2 etc.
Honestly, I really don't know what the standard intends here. However,
I was wondering what Marco, Muzaffer, etc. think about the following
sentence from 11.4.2:
"Another source of nondeterminism is that statements without time-
control constructs in behavioral
blocks do not have to be executed as one event."
The subtle thing that I'm wondering about is this: does the above
sentence imply that statements WITH A TIME CONTROL construct must be
executed as a single event? If you look at the syntax definition, @()
begin end is a single statement (A.6.4), while a begin-end block is
defined as a list of statements in the formal syntax ({statement}).
If such a statement must be executed as one event then
@(a or b) begin x = a+b end AND EVEN
@(a or b) begin x = a+b; y = a+b; end
must commit 1 and 2 updates atomically and re-sensitize. Of course,
this also implies that
@(a or b) begin x = a+b; #5 y = a + b; end
must execute as a single event, which doesn't make any sense at all.
All things considered, I tend to agree with the original interleaved
semantics from my first post (and corroborated by others), and I also
agree with Marco's interpretation of
always @(a or b) begin
x = a + b
end
always @(a or b) begin
y = a + b
end
where x and y could differ.
-Mike
ps: I wasn't sure if Steve was commenting specifically on this last
issue?
On Marco's 4-6-2009 7:29 post: This is EXACTLY why I posted-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
This shows up in the -2001 version of the standard as well. I do
not know of any simulator that interrupts a behavioral process at
any time other then at time control constructs. To do so would cause
utter chaos.
The problem is that the atomicity of execution is the only form
of synchronization that a Verilog programmer has. Without it,
cycle-based simulation would be nearly impossible. No compiler
intentionally violates that atomicity, and in the few cases where
Icarus Verilog did, I was handed a plate full of bug reports.
You'll have to ask some committee members why that paragraph is
there, but I think you will find that all the Verilog simulator
implementers are careful to not interrupt execution outside of
timing constructs. If you think you've found an instance, then
please do tell.
hairyotter wrote:
Thank you everybody for all the insights, I am finding this very
interesting as well.
However, I think I might use some clarification.
using the example above:
initial begin
a = 1;
b = 1;
end
always @(a or b) begin
x = a + b;
y = a + b;
end
As already reported, the verilog standard (11.4.2 in 1364-2005)
explicitly states that execution can be suspended, and that the order
of interleaved execution is nondeterministic.
However, I have a "problem" with this.
What if, for whatever reason:
- a = 1 is executed and the initial suspended
- the always process is triggered, the x = a+b executed and then the
process suspended
- the initial is resumed, executes b=1, but the always is no longer
listening to a.
End result, x wrong, y correct.
Please note: I do not see a reason in the world why a simulator would
want to do this, it's just that the verilog standard allows for it, so
I'm wondering how would you get out safely.
Thanks, Marco.
- --
Steve Williams "The woods are lovely, dark and deep.
steve at icarus.com But I have promises to keep,http://www.icarus.com and lines to code before I sleep,http://www..picturel.com And lines to code before I sleep."
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.4-svn0 (GNU/Linux)
Comment: Using GnuPG with SUSE -http://enigmail.mozdev.org
iD8DBQFJ3L/ZrPt1Sc2b3ikRAvFsAKCd0rWL3bM1sKS7GWJaDSTXR/94wgCeMlrd
AlRrXvWrwn4bALzv6Gfw4oY> =bvPC
-----END PGP SIGNATURE-----
originally, although the standard suggests your x is correct y is
incorrect interpretation is valid, which is equivalent to one of the
cases in my original post, it JUST FEELS "wrong". That is, as if the
standard shouldn't allow it. This is a great thread , it's really
helping me with the work that I'm doing.
Along these lines, Marco and Muzaffer's back-and-forth on
always @(a or b) begin
x = a + b;
end
is really the key question, at least in my mind. If you think of each
always block as having a sort of "program counter", then the question
is where are the legal spots for it to point? If I understand
correctly, Marco's interpretation is that there are two spots, the @(a
or b) and the x = a + b, and Muzaffer is treating the @(a or b) begin
x = a + b end as a single spot. Again, one FEELS like the standard
should not allow x and y to end up with different values, Muzaffer's
interpretation, but Marco's interpretation seems sensible to me based
on 11.4.2 etc.
Honestly, I really don't know what the standard intends here. However,
I was wondering what Marco, Muzaffer, etc. think about the following
sentence from 11.4.2:
"Another source of nondeterminism is that statements without time-
control constructs in behavioral
blocks do not have to be executed as one event."
The subtle thing that I'm wondering about is this: does the above
sentence imply that statements WITH A TIME CONTROL construct must be
executed as a single event? If you look at the syntax definition, @()
begin end is a single statement (A.6.4), while a begin-end block is
defined as a list of statements in the formal syntax ({statement}).
If such a statement must be executed as one event then
@(a or b) begin x = a+b end AND EVEN
@(a or b) begin x = a+b; y = a+b; end
must commit 1 and 2 updates atomically and re-sensitize. Of course,
this also implies that
@(a or b) begin x = a+b; #5 y = a + b; end
must execute as a single event, which doesn't make any sense at all.
All things considered, I tend to agree with the original interleaved
semantics from my first post (and corroborated by others), and I also
agree with Marco's interpretation of
always @(a or b) begin
x = a + b
end
always @(a or b) begin
y = a + b
end
where x and y could differ.
-Mike
ps: I wasn't sure if Steve was commenting specifically on this last
issue?