Repository navigation
feat(sv): let processes of several instances write a package variable - #1872
Conversation
|
This pull request is part of a Mergify stack:
|
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a93c2e6938
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for process in module.initial_processes().iter().filter(|p| { | ||
| p.repeats() | ||
| && (repeating | ||
| || p.is_scheduled_edge() | ||
| || p.site().is_some_and(|site| site.construct == "always_ff")) |
There was a problem hiding this comment.
Retain ordinary writers when checking exclusive package drivers
When separate modules write the same package variable, filtering ordinary timed always processes out of the driver list also hides conflicts with an always_ff writer. For example, instantiate one module containing always_ff @(posedge clk) p::q <= d; and another containing always #1 p::q = 0;: the package validation now sees only the first writer. The assembly check does not recover this conflict because it compares flip-flop writes against other flip-flop writes, and compares process writes only against combinational drivers. This previously rejected design is consequently accepted despite violating the exclusive-writer restriction retained by this change. Keep ordinary writers in the collected ranges and allow overlapping writers only when neither requires exclusivity.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 3f20562: every writer is kept, marked when it must be the only writer (always_comb, continuous assignment, flip-flop or always_ff processes), and overlapping writers conflict when either is exclusive. Covered by ordinary_processes_do_not_share_a_package_variable_with_always_ff.
|
Queued — the merge queue status continues in this comment ↓. |
6de9ff1 to
8ce6209
Compare
a93c2e6 to
3f20562
Compare
Revision history
|
3f20562 to
fd7a7c3
Compare
8ce6209 to
5e90e35
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fd7a7c3934
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let local = driver_ranges( | ||
| &module.source, | ||
| name, | ||
| &module.constants, |
There was a problem hiding this comment.
Include initial blocks when checking exclusive package writers
When an always_ff containing a host request writes a package variable and another instance writes it from an initial block, removing the assembly-level initial-write conflict check now accepts the conflicting writers. For example, one module can contain always_ff @(posedge clk) begin p::q <= 1; $fwrite(1, "host"); end and another initial p::q = 0;. The host request moves the flip-flop into module.processes, so the remaining ff_writes check cannot catch it, while driver_ranges excludes one-shot initial blocks and therefore supplies no competing writer to the new exclusivity check. Collect initial-block writes as nonexclusive writers too, so an overlapping exclusive writer still causes rejection.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 5d88e53: one-shot initial blocks are collected as writers too. An initial block conflicts with an overlapping writer that the standard restricts to being the only writer (always_ff, always_comb, always_latch, continuous assignment, child output, or such a procedure run as a process), but not with an ordinary always, which may share the variable. Covered by initial_blocks_do_not_share_a_package_variable_with_always_ff (an always_ff with a host request plus an initial in another instance is rejected; always @(posedge) plus initial is accepted).
5e90e35 to
af3f0a8
Compare
fd7a7c3 to
6fad55b
Compare
af3f0a8 to
3493193
Compare
5acfbeb to
5d88e53
Compare
3493193 to
4eb7c7e
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
1 similar comment
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
4eb7c7e to
8b00336
Compare
5d88e53 to
278db13
Compare
|
Local review (Codex CLI) of this commit:
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 278db13c75
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if restricted { | ||
| restricted_writes.push(((instance, index), address, access)); |
There was a problem hiding this comment.
Preserve written bit ranges in restricted-process checks
When a restricted runtime process and another writer in the same instance update disjoint slices of a package variable, the new check incorrectly rejects the design. For example, with p::q declared as logic [1:0], always_ff @(posedge clk) begin p::q[0] = d; $display("host"); end and initial p::q[1] = 0; pass the frontend's range-aware validation, but assembly records the runtime process as writing the entire variable and reports an overlap. Previously the assembly check did not reject initial/process writes within one instance. Retain the actual written ranges when collecting restricted writes so this new comparison does not reject disjoint writers.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 1cc98fe: a restricted process's write now covers the bits its instruction's offset and width give, as ff_writes already does, so disjoint slices written by a restricted process and another writer of the same instance are no longer rejected. Covered by restricted_processes_may_share_disjoint_package_slices.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 278db13c75
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if restricted { | ||
| restricted_writes.push(((instance, index), address, access)); |
There was a problem hiding this comment.
Preserve slice ranges when collecting restricted process writes
When an always_ff runs as a process because it contains a host request, adding its writes to restricted_writes reuses the full-variable range constructed above, so the new check rejects writes to disjoint slices. For example, within one module, initial p::q[7:4] = 0; alongside always_ff @(posedge clk) begin p::q[3:0] = d; $display("host"); end passes the frontend's range-aware validation but now fails assembly with a multiple-driver error. Previously, the assembly check allowed these writes within one instance. Derive the process write's range from the instruction offset and width, as the ff_writes collection already does, rather than treating every restricted write as covering the whole variable.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 1cc98fe: a restricted process's write now covers the bits its instruction's offset and width give, as ff_writes already does, so disjoint slices written by a restricted process and another writer of the same instance are no longer rejected. Covered by restricted_processes_may_share_disjoint_package_slices.
278db13 to
1cc98fe
Compare
8b00336 to
f03b45c
Compare
Any processes may write a variable (IEEE 1800-2023 6.5), so initial blocks and ordinary always processes of several module instances may write one package variable, such as a static property of a package class that constructors in several instances update. A continuous assignment, `always_comb` or `always_ff` that writes a package variable stays its only writer (6.5, 9.2.2), counting every instance, and an initial block of another instance counts as another writer of those; an edge procedure run as a process keeps that rule, and so do flip-flop processes. The SystemVerilog frontend marks which writers of a package variable must be its only writer and reports overlapping writers only when one of them must. Assembly no longer rejects initial writes of two instances, and rejects an `always_ff`, `always_comb` or `always_latch` run as a process that overlaps a write of another process, for designs whose top is not SystemVerilog. Change-Id: I6361be93dc6d359c2f5373da42c6246438ca4349
f03b45c to
af8df00
Compare
1cc98fe to
85bb50a
Compare
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
1 similar comment
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Merge Queue Status
This pull request spent 34 minutes 26 seconds in the queue, including 32 minutes 44 seconds running CI. Required conditions to merge
|
Any processes may write a variable (IEEE 1800-2023 6.5), so initial blocks
and ordinary always processes of several module instances may write one
package variable, such as a static property of a package class that
constructors in several instances update. A continuous assignment,
always_comboralways_ffthat writes a package variable stays its onlywriter (6.5, 9.2.2), counting every instance, and an initial block of
another instance counts as another writer of those; an edge procedure run as
a process keeps that rule, and so do flip-flop processes.
The SystemVerilog frontend marks which writers of a package variable must
be its only writer and reports overlapping writers only when one of them
must. Assembly no longer rejects initial writes of two instances, and
rejects an
always_ff,always_comboralways_latchrun as a processthat overlaps a write of another process, for designs whose top is not
SystemVerilog.
Depends-On: #1850