Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Level sensitive always blocks are executed even when nothing has changed #224

Closed
veripoolbot opened this issue Mar 17, 2010 · 2 comments
Closed

Comments

@veripoolbot
Copy link
Contributor

@veripoolbot veripoolbot commented Mar 17, 2010


Author Name: Byron Bradley (@bbradley)
Original Redmine Issue: 224 from https://www.veripool.org
Original Date: 2010-03-17


The Verilator manual says that code such as "always @ (x) y = x & z;" will be executed if x or z has changed, however it appears to get executed even if nothing has changed. This is a problem for system functions such as $display/$fwrite because it will be called on every eval().

A testcase is attached that passes with VCS.

@veripoolbot
Copy link
Contributor Author

@veripoolbot veripoolbot commented Mar 17, 2010


Original Redmine Comment
Author Name: Wilson Snyder (@wsnyder)
Original Date: 2010-03-17T12:56:40Z


I reworded it

     always @ (x)   y = x & z;

"This will recompute y when there is even a potential for change in x or a
change in z, that is when the flops computing x or z evaluate (which is
what Design Compiler will synthesize.) A compliant simulator would only
calculate y if x changes. Use verilog-mode's /AS/ or Verilog 2001's
always @* to reduce missing activity items. Avoid putting $displays in
combo blocks, as they may print multiple times when not desired, even on
compliant simulators as event ordering is not specified."

The (mis-)functionality itself is core to how code scheduling works and
won't be changed until there's a fundamental rewrite, probably
Verilator 4. That will decrease performance when it does work, though.

@veripoolbot
Copy link
Contributor Author

@veripoolbot veripoolbot commented Mar 17, 2010


Original Redmine Comment
Author Name: Byron Bradley (@bbradley)
Original Date: 2010-03-17T14:25:15Z


Thanks Wilson. I wasn't expecting a change for Verilator 3 (I'd already looked at how V3Active works), but I thought I'd report the difference since it took me a while to track it down.

Manually adding the code to execute the block only on a change reduced performance by almost 10% compared to just deleting the $display, so it is probably best avoided anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.