Repository navigation
Conversation
Several plain always blocks may write one variable, such as a shared loop index (IEEE 1800-2023 6.5, 9.2.2); only always_comb, always_latch and always_ff restrict it to one process. always @* blocks that write a common variable now run as processes waiting on their implicit event expression (9.4.2.2), so their writes wake each other as the standard requires. Blocks that keep waking each other end the run with "does not settle", which now names the processes instead of their indices. The shared_always_temporary diagnostic (error by default) opts into a deviation: with warn or allow, a variable that only such blocks write, each before it reads it, and that nothing else reads is a temporary of each block, as in Icarus. The multiple-driver error names the writers. Closes #2129. BREAKING CHANGE: AnalysisOptions has a new field, shared_always_temporaries, and FrontendWarningKind a new variant, SharedAlwaysTemporary. Change-Id: Id83fadfd087ffacbd71224f39bc3ede1910ee053
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: 60d730a5f7
ℹ️ 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".
| .ff_processes() | ||
| .iter() | ||
| .any(|process| stmts_mention(process.body(), name)) |
There was a problem hiding this comment.
Check edge-event signals before privatizing a shared variable
With shared_always_temporary=warn|allow, a variable used only in another process's edge control is incorrectly considered unobserved because this check examines only FfProcess::body(), not FfProcess::events(). For example, two blocks containing always @* j = a; and always @* j = b; qualify for privatization even when always @(posedge j) q <= 1'b1; observes their writes. Renaming both writers leaves the real j at its initial value, suppressing the edge and changing q. Include event signals in the outside-reader check so this design retains strict behavior.
Useful? React with 👍 / 👎.
| ; here the second block's writes to `j` wake the first one, which reads it, | ||
| ; while the first block's loop writes wake nothing. Which block writes `j` | ||
| ; last is not defined, so the output leaves it out. | ||
| (case level_processes_share_a_written_variable |
There was a problem hiding this comment.
Register the convergent shared-variable case on Celox backends
This new case has no Celox backend test registration: a repository-wide search for level_processes_share_a_written_variable finds only this definition. crates/celox/tests/systemverilog.rs generates executable backend tests from explicit sv_backends! entries, while compiled_scheduler_coverage only builds timed designs without running their assertions. Consequently, ordinary Celox test runs do not verify this case's convergent behavior or expected output; the added Rust tests instead cover non-convergence and the opt-in deviation. Add the corresponding @case registration in the procedural backend tests. AGENTS.md explicitly requires: “Wire shared cases into Celox's backend test harness”.
AGENTS.md reference: AGENTS.md:L102-L104
Useful? React with 👍 / 👎.
| let local = format!("{}$always{driver}", signal.name()); | ||
| module = module.add_local(sv::ir::LocalVariable { | ||
| name: local.clone(), |
There was a problem hiding this comment.
Generate temporary names without colliding with user identifiers
With shared_always_temporary=warn|allow, the generated name can collide with a legal SystemVerilog identifier such as j$always0. procedural::register_locals inserts these names into the same name_to_id map as ports and signals without checking for an existing entry, so privatizing j in combinational process 0 silently replaces the binding of an unrelated input or signal named j$always0. For example, a block containing j = 0; y = j$always0; then reads the generated temporary instead of the input, corrupting y. Allocate a fresh name against the module's existing identifiers before adding each temporary.
Useful? React with 👍 / 👎.
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
Closes #2129. The level-sensitive twin of #1945 (#1950): several plain
always @*blocks may write one variable, such as a shared loop index (IEEE 1800-2023 6.5, 9.2.2). Onlyalways_comb,always_latchandalways_ffrestrict a variable to one process.Semantics (decided on #2129: option C)
Default, strict LRM. Each block waits on the variables it reads, the shared one included (9.4.2.2), so its writes wake the other blocks. Such blocks now run as processes that wait on their implicit event expression (
Module::run_comb_processes_as_processes), which gives exactly that behavior.time T does not settle: processes keep resuming:alwaysat f.sv:7:3 intop,alwaysat f.sv:11:3 intop``. Verilator reportsDIDNOTCONVERGEfor the same design.Opt-in deviation:
shared_always_temporary(--diagnostic shared_always_temporary=warn|allow; the default iserror, meaning strict). The variable becomes a temporary of each block when all of the following hold:always @*blocks write it;Its writes then wake no other block, as in Icarus, and the variable keeps its initial value.
warnreports the variable and the blocks. Documented indocs/guide/celox-toml.md(and the Japanese version) as a deviation, with "declare the variable inside each block" as the standard-conforming alternative.Diagnostics with locations. "multiple variable drivers for
x" now names the writers' locations;always_combblocks sharing a variable are still rejected that way. The run-time "does not settle" and "does not suspend" errors name the processes (RuntimeSchema::process_origins) instead of indices.Tests
procedural::level_processes_share_a_written_variable(strict; one block's writes wake the other once). It passesverify-sv-icarusandverify-sv-verilator, and Celox in two- and four-state.tests/frontends/systemverilog/procedural.rs:1 1in two- and four-state;warnreportsjwith both blocks;always_combsharing is rejected with locations.Validation
celox --no-default-featuresis clean with-D warnings.Effect on rtlmeter HummingbirdV2-E203 (
nodelayconfiguration,DISABLE_SV_ASSERTION,shared_always_temporary=warn)The opt-in applies to 3 variables and E203 gets past the multiple-driver error. It now stops at the scheduler's "Combinational loop detected" through the
always @*processes of the APB SPI controller (u_spictrl:data_to_tx_ready -> rx_clk_en -> u_rxreg.clk_en_o -> ... -> spi_en_tx -> ...), which is a separate gap.