Fix #1317: Variable written in an always_ff should not driven by other process#1374
Open
MrCookieeeee wants to merge 1 commit into
Open
Fix #1317: Variable written in an always_ff should not driven by other process#1374MrCookieeeee wants to merge 1 commit into
MrCookieeeee wants to merge 1 commit into
Conversation
larsclausen
reviewed
May 25, 2026
larsclausen
reviewed
May 25, 2026
larsclausen
reviewed
May 25, 2026
Contributor
Author
|
Hi, I have updated the code and resubmitted the PR. The changes are:
Thanks. |
larsclausen
reviewed
May 27, 2026
Contributor
Author
|
Copy, i will fix it real quick. |
…ven by other process
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fix #1371
This PR adds a check for variables written by
always_ffprocesses, following the SystemVerilog single-writer rule foralways_ff.Implementation
First, it scans all
always_ffprocesses and collects theNexusobjects written by each process throughnex_output(). A map is used to record whichalways_ffprocess first writes eachNexus. If anotheralways_ffprocess writes the sameNexus, an error is reported.Second, it scans the remaining non-
always_ffprocesses and checks whether any of them also write aNexusthat was already written by analways_ffprocess. If so, an error is reported. Compiler-scheduled initialization processes marked with_ivl_schedule_initare skipped, so declaration initializers are not treated as conflicting procedural writers.Overhead
For time complexity, this check walks the process list twice and calls
nex_output()once for each relevant process. The map/set lookups are logarithmic, so the cost is roughly proportional to the total number of procedural write targets, withlog(N)overhead from the containers. I think this should be acceptable for normal elaboration-time checking, but I would appreciate feedback if there is a better or more idiomatic way to do this in Icarus.Discussion
One limitation is that this check currently works at the
Nexuslevel and does not explicitly distinguish disjoint bit/part-select writes. For example:I did not add special handling for this case yet. Please let me know whether this is necessary. If so, I could add some check on it. :D