S
Stephen Williams
Guest
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Here's a snippet of code that reflects what I found in some modules
in the wild. It turns out that it seems to work for some compilers,
and it will work for Icarus Verilog too if the order of the assignments
after the #100 are switched, but this strikes me as a race condition
plain and simple. I can't find anything in the LRM that justifies
and expectation that this program can possibly be correct.
Here's the snippet:
~ time period;
~ reg lock_period;
~ initial begin
~ period = 0;
~ lock_period = 0;
~ #100 ;
~ lock_period <= 1;
~ period <= 250;
~ end // initial begin
~ assign #(period) lock_period_dly = lock_period;
~ assign lock_period_pulse = lock_period && !lock_period_dly;
Note that the process does a non-blocking assign to both the
"period" and the "lock_period" variables. The period is then
used as a delay for the lock_period propagating through the
continuous assignment to lock_period_dly.
This screams "Race!" to me. Can anybody else find rules that
justify this code?
- --
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
iD8DBQFIUVEXrPt1Sc2b3ikRArBXAJ9rCClwTlqmqoUJ7Y3FXSeDrtFYLwCfbApf
NrE6YVUbBfgHNCcJyQFzHPY=
=HF0f
-----END PGP SIGNATURE-----
Hash: SHA1
Here's a snippet of code that reflects what I found in some modules
in the wild. It turns out that it seems to work for some compilers,
and it will work for Icarus Verilog too if the order of the assignments
after the #100 are switched, but this strikes me as a race condition
plain and simple. I can't find anything in the LRM that justifies
and expectation that this program can possibly be correct.
Here's the snippet:
~ time period;
~ reg lock_period;
~ initial begin
~ period = 0;
~ lock_period = 0;
~ #100 ;
~ lock_period <= 1;
~ period <= 250;
~ end // initial begin
~ assign #(period) lock_period_dly = lock_period;
~ assign lock_period_pulse = lock_period && !lock_period_dly;
Note that the process does a non-blocking assign to both the
"period" and the "lock_period" variables. The period is then
used as a delay for the lock_period propagating through the
continuous assignment to lock_period_dly.
This screams "Race!" to me. Can anybody else find rules that
justify this code?
- --
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
iD8DBQFIUVEXrPt1Sc2b3ikRArBXAJ9rCClwTlqmqoUJ7Y3FXSeDrtFYLwCfbApf
NrE6YVUbBfgHNCcJyQFzHPY=
=HF0f
-----END PGP SIGNATURE-----