Skip to content

feat(sv): let processes of several instances write a package variable - #1872

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feat/string-class-heap/let-processes-several-instances-write-pkg-var--6361be93
Oct 26, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feat/string-class-heap/let-processes-several-instances-write-pkg-var--6361be93

Conversation

@tignear

@tignear tignear commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

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.

Depends-On: #1850

@tignear

tignear commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(sv)!: support parameterized classes #1796
2 fix(sv): bind derived classes in their own declaration scopes #2093
3 feat(sv)!: support shallow copies of class objects #1810
4 feat(sv): support classes declared in packages and the compilation unit #1850
5 feat(sv): let processes of several instances write a package variable #1872 👈

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-26T00:25:23.895213Z
We couldn’t complete this review. Comment @codex review to try again.
85bb50a New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +1291 to +1295
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"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mergify

mergify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-classes-declared-pkgs-compilation-unit--12b64cde branch from 6de9ff1 to 8ce6209 Compare October 24, 2026 11:46
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/let-processes-several-instances-write-pkg-var--6361be93 branch from a93c2e6 to 3f20562 Compare October 24, 2026 11:46
@tignear

tignear commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial a93c2e6 2026-10-24 11:45 UTC
2 content a93c2e6 → 3f20562 Review: every writer is kept; overlapping writers conflict when one of them must be the only writer, so always_ff against an always of another instance is rejected. 2026-10-24 11:45 UTC
3 rebase 3f20562 → fd7a7c3 (rebase only) Rebased onto the revised #1850. 2026-10-24 18:09 UTC
4 rebase fd7a7c3 → 6fad55b (rebase only) Rebased onto master with class enum randomization (#1859 and earlier); class test files merged and the Verilator/Icarus class reports regenerated. 2026-10-24 21:08 UTC
5 content 5acfbeb → 5d88e53 2026-10-24 23:39 UTC
6 content 5d88e53 → 278db13 Local review: assembly rejects an always_ff/always_comb/always_latch run as a process that overlaps another process's write (mixed-language tops); nonblocking process writes tracked in #1969. 2026-10-25 07:34 UTC
7 content 278db13 → 1cc98fe Review: process writes to package variables are compared by the bits each store writes, so disjoint slices of a restricted process and another writer are accepted. Rebased onto master. 2026-10-25 10:59 UTC
8 content 1cc98fe → 85bb50a Rebased onto master: package-variable writer collection ported to ModuleDrivers. 2026-10-26 00:24 UTC

@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/let-processes-several-instances-write-pkg-var--6361be93 branch from 3f20562 to fd7a7c3 Compare October 24, 2026 18:17
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-classes-declared-pkgs-compilation-unit--12b64cde branch from 8ce6209 to 5e90e35 Compare October 24, 2026 18:17

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines 962 to 965
let local = driver_ranges(
&module.source,
name,
&module.constants,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-classes-declared-pkgs-compilation-unit--12b64cde branch from 5e90e35 to af3f0a8 Compare October 24, 2026 21:08
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/let-processes-several-instances-write-pkg-var--6361be93 branch from fd7a7c3 to 6fad55b Compare October 24, 2026 21:08
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-classes-declared-pkgs-compilation-unit--12b64cde branch from af3f0a8 to 3493193 Compare October 24, 2026 21:18
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/let-processes-several-instances-write-pkg-var--6361be93 branch 2 times, most recently from 5acfbeb to 5d88e53 Compare October 24, 2026 23:40
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-classes-declared-pkgs-compilation-unit--12b64cde branch from 3493193 to 4eb7c7e Compare October 24, 2026 23:40
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-classes-declared-pkgs-compilation-unit--12b64cde branch from 4eb7c7e to 8b00336 Compare October 25, 2026 07:39
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/let-processes-several-instances-write-pkg-var--6361be93 branch from 5d88e53 to 278db13 Compare October 25, 2026 07:39
@tignear

tignear commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Local review (Codex CLI) of this commit:

  • [P2] Mixed-language designs lost the exclusivity check of processes. With a non-SV top, assembly is the only cross-instance check. It now rejects an always_ff, always_comb or always_latch run as a process (identified by its ProcessOrigin) that overlaps a write of another process or a flip-flop. Covered by veryl_instances_do_not_share_a_package_variable_from_always_ff, which fails without the change. Assembly does not yet see nonblocking writes of process kernels, so the nonblocking form stays accepted as it was before this PR; tracked in sv: assembly misses nonblocking package-variable writes of runtime processes #1969.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +502 to +503
if restricted {
restricted_writes.push(((instance, index), address, access));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +502 to +503
if restricted {
restricted_writes.push(((instance, index), address, access));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/let-processes-several-instances-write-pkg-var--6361be93 branch from 278db13 to 1cc98fe Compare October 25, 2026 11:00
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-classes-declared-pkgs-compilation-unit--12b64cde branch from 8b00336 to f03b45c Compare October 25, 2026 11:00
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
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-classes-declared-pkgs-compilation-unit--12b64cde branch from f03b45c to af8df00 Compare October 26, 2026 00:25
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/let-processes-several-instances-write-pkg-var--6361be93 branch from 1cc98fe to 85bb50a Compare October 26, 2026 00:25
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Base automatically changed from stack/tignear/feat/string-class-heap/support-classes-declared-pkgs-compilation-unit--12b64cde to master October 26, 2026 03:13
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 26, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 26, 2026
@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-26 03:15 UTC · Rule: changes · triggered by rule Queue explicitly requested merges
  • ✅ Checks passed · on draft merge queue: checking #1872 on master (1588e70) #2098
  • ✅ Merged — 2026-10-26 03:50 UTC · at a5f411720f22bf82882a652157123110a7a18604 · merge

This pull request spent 34 minutes 26 seconds in the queue, including 32 minutes 44 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • depends-on = celox-sim/celox#1850 [⛓️ feat(sv): support classes declared in packages and the compilation unit #1850]
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Lint & Format
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Windows)
    • check-neutral = @github-actions/NAPI Build (Windows)
    • check-skipped = @github-actions/NAPI Build (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Rust Test & NAPI Build
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Ubuntu)
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Windows)
    • check-neutral = @github-actions/JS Test (Windows)
    • check-skipped = @github-actions/JS Test (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Conventional Commit title
    • check-neutral = @github-actions/Conventional Commit title
    • check-skipped = @github-actions/Conventional Commit title

@mergify mergify Bot mentioned this pull request Oct 26, 2026
43 of 73 tasks
@mergify
mergify Bot merged commit a5f4117 into master Oct 26, 2026
26 of 44 checks passed
@mergify
mergify Bot deleted the stack/tignear/feat/string-class-heap/let-processes-several-instances-write-pkg-var--6361be93 branch October 26, 2026 03:50
@mergify mergify Bot removed the queued Mergify queue entry label Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant