Skip to content

feat(cli): save state files at chosen cycles or times of a SystemVerilog run - #2030

Merged
mergify[bot] merged 1 commit into
masterfrom
feat/cli-save-state-cycles
Oct 25, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
feat/cli-save-state-cycles

Conversation

@tignear

@tignear tignear commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

Refs #2025 (the SystemVerilog part; Veryl testbenches follow in a separate PR).

Summary

New celox run options save path-keyed state files (Simulation::save_state, read by celox state dump/diff) during a SystemVerilog run, on every backend:

Option Meaning
--save-state-on SIGNAL Count the cycles of SIGNAL, a hierarchical path such as tb.clk or tb.cpu[1].clk. The top module's name may be included or left out.
--save-state-at N[,M...] Save after cycles N, M, ... (counted from 1) as <SIGNAL>-<N>.state.
--save-state-at-time T[,U...] Save as time-<T>.state, in units of the global time precision.
--save-state-dir DIR Output directory (default .; created if missing).

When a file is saved, defined so that two runs or simulators can be diffed:

  • Cycle: a time step at whose end the signal is 1 (and not X) while it was not at the end of the previous time step, or after the initial settle. The file is written right after that time step, once every region of the time is done, so the cycle's nonblocking updates are in it.
  • Time T: the state after everything due at times up to T, saved before the run advances past T. A T after the run's last activity gives the final state.
  • Cycle never reached: if the run ends before a requested cycle, that is an error that names the cycle count reached.

Veryl runs reject the options for now. A Veryl testbench runs its ticks in batches inside testbench.rs, so it needs a separate hook there, which comes in the follow-up PR.

The implementation is in the CLI's step loop (StateSaves in celox.rs). The library change is only a Simulation::try_child_signal that resolves the path without panicking.

Tests

  • sv_saves_state_files_at_cycles_and_times (run_cli.rs): a counter clocked by always #5 clk = ~clk, run with the tiered, interpreter and native backends. It saves at cycles 2 and 5 and at time 32, then checks with celox state dump that the files hold count = 2 at time 15, count = 5 at time 45, and count = 3 at time 30. A cycle that is never reached fails the run.
  • The whole celox-vpi test suite with --features systemverilog passes, and clippy is clean with and without the feature.

Docs

  • docs/guide/cocotb.md has a new "Save state files during a SystemVerilog run" table (Japanese too).
  • checkpoints.md points to it from the state file section (both languages).

…log run

Refs #2025

Change-Id: Ib71719ee9f5f4d322b2b673915f907156e26e1a0
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 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-25T14:04:43.719189Z eef1fe6 PR opened
ℹ️ 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: eef1fe6538

ℹ️ 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 +435 to +438
.collect::<Result<Vec<_>, _>>()?;
simulation
.try_child_signal(&instances, var)
.map_err(|error| format!("--save-state-on {path}: {error}"))

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 Resolve interface member clocks without assuming module instances

For an interface clock such as Top.c.clk, this resolver treats c as a module instance and passes only clk as the variable path. However, the SV frontend's restore_interface_member_paths stores interface members as multi-segment variable paths within the enclosing module, and RuntimeProgram::instance_addr distinguishes those paths from instance paths. Consequently, a valid interface clock cannot be selected with --save-state-on, even when preserved with --live-signal. Resolve the complete reflected signal path, or distinguish the variable-path suffix from the module-instance prefix.

Useful? React with 👍 / 👎.

@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 25, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 25, 2026
@mergify

mergify Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 26 minutes 3 seconds in the queue, including 24 minutes 37 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • 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 merged commit 32fa7a5 into master Oct 25, 2026
23 checks passed
@mergify
mergify Bot deleted the feat/cli-save-state-cycles branch October 25, 2026 14:50
@mergify mergify Bot removed the queued Mergify queue entry label Oct 25, 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