Comments (6)
You have a race in your code. At time 105 there are two processes (threads) waiting for the rising edge of MPC_LCLK. One is the task foo, the other is the always block that assigns to addr. A simulator can legitimately choose either of these to execute first. In this case Icarus is choosing the task, which proceeds to assign to mpc_address, MPC_LA, and MPC_LALE before relinquishing control to wait for the next clock edge. Icarus then executes the always block, which samples the current state of MPC_LA. Because you used blocking assignments in the task, MPC_LA has already been updated with the new value. Change the blocking assignments to non-blocking assignments, and you will get the behaviour you expect.
Closing as invalid.
from iverilog.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Martin is 100% correct, your example had a race and it is not
a problem with Icarus Verilog. Whenever you mix blocking and
non-blocking assignments in synchronous logic, you run the risk
of races. The offending assignments in your example are in the
"foo" task. Rework that code to use non-blocking assignments,
and you should see better results.
On 07/08/2015 02:26 AM, Simuc wrote:
I show an example, it's a loop-left shifter.
|reg [7:0] q; always @(posedge clk) q <= {q[6:0], q[7]}; |
As you know, q[i] change after the clk event, and get a value which
was the data from q[i-1] at the time BEFORE the clk event.I hope that you can understand what I mean.
— Reply to this email directly or view it on GitHub
#74 (comment).
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
iEYEARECAAYFAlWdOk4ACgkQrPt1Sc2b3ikxRgCgq2ucVS6zmFzM3BEGs3aHCk2c
9mQAoIqX43urnhSxbav7h7SpKRnkX6Hf
=vVxA
-----END PGP SIGNATURE-----
from iverilog.
Maybe you miss a understanding.
For circuit simulation, generally "non-blocking assignments" is used for synchrous simulation. e.g. always @(posedge clk) q <= d; it means q got value d BEFORE events, i.e. setup time is 0 before posedge clk.
Generally "blocking assignments" is used for Asynchrous simulation. e.g. @(posedge clk) q = d; it means q got value d AFTER events, i.e. firstly event 'posedge clk', then do 'q = d'.
One is before evnet, and the other is after event. So that is a accurary behaviorial description, simulator can NOT choose at random !!
from iverilog.
No, your understanding is wrong. "@(event) statement;" means wait for "event" then execute "statement", regardless of what "statement" is. So if you write
always @(posedge clk) statement1;
always @(posedge clk) statement2;
a simulator can choose to execute either statement1 or statement2 first (and can choose differently each time the event occurs).
If the statement is a non-blocking assignment, the RHS expression is evaluated after waiting for the event, not before.
For a more thorough explanation, try Cliff Cumming's paper: http://www.sunburst-design.com/papers/CummingsSNUG2000SJ_NBA.pdf
from iverilog.
I show an example, it's a loop-left shifter.
reg [7:0] q;
always @(posedge clk) q <= {q[6:0], q[7]};
As you know, q[i] change after the clk event, and get a value which was the data from q[i-1] at the time BEFORE the clk event.
I hope that you can understand what I mean 'before'.
from iverilog.
By 'before' you mean before any updates caused by non-blocking assignments triggered by that event. This is correct. But the problem in your original test case is that you used a blocking assignment which causes an immediate update, creating a timing race. This is equivalent to a hold-time violation in a real circuit.
If you don't understand this, read the Cliff Cummings paper.
from iverilog.
Related Issues (20)
- Undetected error when a whole array is both procedurally and continuously assigned. HOT 1
- Improve error message in module instantiation when `wire` array given to `output` array with wrong lengths
- Support for "inside" statements HOT 2
- Incorrect uninitialised value and force/release behaviour when variable is partly driven by a continuous assignment
- Question on AMS support HOT 2
- Override parameters in top-level Verilog HOT 2
- Array depth defined with the num method of an enum where the variable name is identical to part of the enum instance name causes an error HOT 5
- unsigned port connection sign extends HOT 4
- fork..join_none inside automatic task fails assertion
- iverilog doesn't exit with an error code when an include file is missing. HOT 4
- Add support for `assert( l_c === 1'b0 );` syntax HOT 3
- Support implicit named port connections HOT 5
- Bug: accessing parameters by upward hierarchial name HOT 1
- Replication operator in literal array assignment pattern is not supported HOT 1
- vpi_put_value() at T0 is overridden HOT 2
- No error reported when an invalid or non-existent argument is passed to $bits
- vvp: array.cc:1561: void compile_array_alias(char*, char*, char*): Assertion `mem' failed.
- I think a signal goes up one clock cycle too early HOT 3
- Possible Data Transfer Anomaly HOT 8
- Nested generate statement not reported as syntax error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iverilog.