Skip to content

feat(sv): simulate program blocks - #1897

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feature/feat/1862-sv-program-blocks/simulate-program-blocks--3e6817bd
Oct 24, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feature/feat/1862-sv-program-blocks/simulate-program-blocks--3e6817bd

Conversation

@tignear

@tignear tignear commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

The analyzer accepts program declarations and their instances (IEEE
1800-2023 24.3). It rejects always procedures, module instances and
nested units inside a program, and reports a program nested in a module
as unsupported. A program's initial procedures are not folded into
initial state: they lower to kernels that name the program instance, so
they run in the reactive region set, and $exit in a program ends its
initial procedures (24.7).

Continuous assignments of a program are evaluated with the design.
Nested and anonymous programs, the implicit program top, and final and
clocking blocks in programs are not supported yet.

The shared suite's program cases are checked against xezim 0.11.3. Icarus
13.0 and Verilator 5.052 run program procedures in the active region set
and do not end the simulation when the programs end; their exclusions
record the pre-exclusion results.

Depends-On: #1896

Closes #1862.

Validation (rebased on c430061)

  • 10 shared-suite cases in program.vtest. Rust tests cover a program continued after $stop and saved to a state file, and design processes that a program wakes reading pre-NBA values.
  • With CI's features, nextest over the affected crates passes 15241 tests, and the SV integration binary with CELOX_SCHEDULER=differential passes 4594.
  • The release sv_tests example (sv-tests c4229f3b) matches the expected.tsv this PR updates: chapter-24/24.3--program.sv goes from fail to pass in both modes.
  • xezim 0.11.3 agrees on every case except two:
    • The flip-flop that a program write clocks: xezim runs it before the program's #0 and Re-NBA.
    • The implicit $finish when every program has ended (24.3): xezim doesn't do it.
  • Icarus 13.0 and Verilator 5.052 run program procedures in the active region set. Their exclusions are sv_program_reactive_region, sv_program_completion, sv_icarus_program_exit, sv_verilator_program_exit and sv_verilator_program_items, with the pre-exclusion results in verification/sv/limitations/programs-*.json and the retained reports in verification/sv/{icarus,verilator}/program.json. With the exclusions: Icarus 7 ignored, 2 rejected, 1 passed; Verilator 9 ignored, 1 passed.
  • Documented deviation (follow-up feat(sv): hold design combinational logic until the reactive region set is empty #1917): design combinational logic that a program drives settles while the reactive region set runs. Icarus, Verilator and xezim do the same; 4.5 holds it back.

@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(runtime)!: run program kernels in the reactive region set #1896
2 feat(sv): simulate program blocks #1897 👈

@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 ✅ Completed 2026-10-24T20:18:19.870847Z — 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: 354a8713be

ℹ️ 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 scoped = tree.scoped(handle)?;
let unit = scoped.root_unit()?;
if unit.kind != celox_sv_syntax::UnitKind::Module
if !unit.kind.is_module_like()

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 programs in interface-port planning

When an instantiated program has an interface port, such as program Probe(Bus b), it is now indexed as a module-like unit, but interface planning still excludes it: Design::collect_selected in ast/interfaces.rs collects only UnitKind::Module, and plan_interfaces_with_member_paths likewise scans interface-port contracts only for modules. Consequently, no port expansion is created for the program, and its interface port reaches ordinary data-type lowering and is rejected instead of connecting to the design's interface. Include programs in those planning paths as well so the newly supported program ports work with interfaces.

Useful? React with 👍 / 👎.

Comment on lines +2876 to +2878
if self.m.program && self.kernel.is_some() {
self.with_kernel(ProcessKernelBuilder::exit);
return Ok(false);

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 Exclude declaration initializer kernels from program exit

When a program's static variable initializer calls a function containing $exit and a runtime operation such as $display, the initializer falls back to a process kernel. This condition treats that kernel as a program thread even though lower_initial_processes deliberately leaves initializer kernels' slots.program as None. Executing the resulting ProcessStatus::Exit then reaches SimulationState::exit_program, which requires a program identity and returns InternalError, preventing simulation initialization. Check that the kernel actually belongs to a program's initial procedure; calls from declaration initializers should follow the ignored-call warning path instead.

Useful? React with 👍 / 👎.

@tignear
tignear force-pushed the stack/tignear/feature/feat/1862-sv-program-blocks/simulate-program-blocks--3e6817bd branch from 354a871 to b6cf3ff Compare October 24, 2026 16:14
@tignear

tignear commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 354a871 2026-10-24 16:11 UTC
2 content 354a871 → b6cf3ff Folded the sv-tests expected.tsv update (formerly #1898) and the retained Icarus/Verilator program reports into this commit so the PR passes CI on its own. 2026-10-24 16:11 UTC
3 content b6cf3ff → 9bb235a 2026-10-24 20:11 UTC

@mergify

mergify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

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

The analyzer accepts program declarations and their instances (IEEE
1800-2023 24.3). It rejects always procedures, module instances and
nested units inside a program, and reports a program nested in a module
as unsupported. A program's initial procedures are not folded into
initial state: they lower to kernels that name the program instance, so
they run in the reactive region set, and $exit in a program ends its
initial procedures (24.7).

Continuous assignments of a program are evaluated with the design.
Nested and anonymous programs, the implicit program top, and final and
clocking blocks in programs are not supported yet.

The shared suite's program cases are checked against xezim 0.11.3. Icarus
13.0 and Verilator 5.052 run program procedures in the active region set
and do not end the simulation when the programs end; their exclusions
record the pre-exclusion results.

Change-Id: I3e6817bd4b94f04465a90ecb9ef4155ee3e582da
@tignear
tignear force-pushed the stack/tignear/feature/feat/1862-sv-program-blocks/simulate-program-blocks--3e6817bd branch from b6cf3ff to 9bb235a Compare October 24, 2026 20:14
@tignear
tignear force-pushed the stack/tignear/feature/feat/1862-sv-program-blocks/run-program-kernels-reactive-region-set--6c899de1 branch from dee80f0 to 883befe Compare October 24, 2026 20:14
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 24, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 24, 2026
@mergify

mergify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 1 hour 12 minutes 6 seconds in the queue, including 24 minutes 14 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • depends-on=celox-sim/celox#1896 [⛓️ feat(runtime)!: run program kernels in the reactive region set #1896 [stack]]
  • 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

Base automatically changed from stack/tignear/feature/feat/1862-sv-program-blocks/run-program-kernels-reactive-region-set--6c899de1 to master October 24, 2026 23:40
@mergify
mergify Bot merged commit c89a0f3 into master Oct 24, 2026
45 of 62 checks passed
@mergify
mergify Bot deleted the stack/tignear/feature/feat/1862-sv-program-blocks/simulate-program-blocks--3e6817bd branch October 24, 2026 23:40
@mergify mergify Bot removed the queued Mergify queue entry label Oct 24, 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.

feat(sv): program blocks and the reactive region set

1 participant