Skip to content

test(suite): add timed script operations and the timing oracle - #1354

Merged
mergify[bot] merged 3 commits into
masterfrom
feature/1123-oracle
Oct 16, 2026
Merged

mergify[bot] merged 3 commits into
masterfrom
feature/1123-oracle

Conversation

@tignear

@tignear tignear commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Step 2 of the #1123 redesign: the timed-design oracle, cut from #1159.

What lands

  • Script ops run_until / run_to_finish, Design::timed, the Backend::run_until / run_to_finish adapter methods, and validation that timed sources keep the injected 1 ns / 1 ps scale (explicit timescale/timeunit/timeprecision/resetall are rejected).
  • timing.vtest: 55 cases (53 kept from test(suite)!: drive timed designs from shared cases #1159, several rewritten, plus 2 new harness cases).
  • Retained evidence verification/sv/{icarus,verilator}/timing.json: Icarus 55/55 pass; Verilator 53 pass, 2 four-state cases unsupported (as in test(suite)!: drive timed designs from shared cases #1159).
  • Celox harness wiring (crates/celox/tests/frontends/systemverilog/timing.rs) with an explicit reason on every exclusion.

Narrowed suite contract (no source rewriter)

timed_ff.rs, timed_initializers.rs and timed_connections.rs are not brought over. Instead:

  • A timed script must begin with run_until or run_to_finish; the parser rejects any other first statement. Inputs keep their fresh values until time zero has been drained, so no case depends on host values staged before time-zero initial blocks, always_ff listeners or variable initializers. A design also does not call $finish at time zero. Documented in the suite README and script/mod.rs.
  • External adapters compile the design sources unchanged. The testbench settles without advancing time: Icarus via a read/write-sync callback ($celox_suite_settle), Verilator via a clocking event sampled in the observed region.
  • Design finish detection without rewriting $finish: Icarus finishes the current time slot after a $finish, so the testbench could still reach its end. The testbench now prints a @suite finishing marker when it reaches run_to_finish. A simulator $finish notice from a staged source before that marker fails the run. After run_to_finish, a delay to RUN_UNTIL_LIMIT keeps an idle design from ending the run by running out of events.
  • Port shapes for timed designs come from a declarations-only copy (preprocessed, with process and task bodies blanked) because the analyzer does not lower timing controls. This copy is used for the analysis only; the tools still compile the sources as written.

Cases changed relative to #1159

  • Dropped (75): cases that only tested staging or rewriting (setup edges, control-name collisions, macro/import/escape handling, initializer staging, early-$fatal continuous drivers). Under the new contract they are either meaningless or time-zero races.
  • Rewritten to start with run_until 0: edge_waits_see_the_signals_the_script_drives, four_state_edges_count_transitions_through_unknown, run_until_drains_target_time_before_later_writes, conditional_writes_…, case_writes_…, negative_repeat_counts_do_not_run_the_body.
  • Time-zero races removed: child outputs observed by @(...) are now bit variables instead of nets. The nine …distinct_activation_times / false_wait… cases arm their observer at time 1 and write at 2 and 3. Icarus counted an extra time-zero wakeup that test(suite)!: drive timed designs from shared cases #1159's staged startup had hidden.
  • New: initial_blocks_run_at_time_zero, host_edges_after_time_zero_clock_flip_flops.

Celox exclusions (removed by step 3/4)

Reason Cases
SV analyzer rejects procedural timing controls (#88) 46
SV analyzer rejects plain always processes (#431) 7
…and also no four-state read in a timed Simulation 2 of the above
a host write to a clock does not trigger its flip-flops in a timed Simulation 1
a timed Simulation builds only the default backend cranelift / native-parallel / cranelift-parallel / wasm for every case

initial_blocks_run_at_time_zero passes on native today. Every excluded test fails when forced with --ignored, so the exclusions are real. No changes to crates/celox/src (runtime and builder work is step 3).

Validation

  • cargo test -p celox --features systemverilog --test systemverilog: 2473 passed, 294 ignored (timing exclusions plus 19 pre-existing).
  • cargo test -p celox-test-suite --features icarus,verilator, including retained_reports.
  • --test oracles -- --ignored and --test timed_protocol -- --ignored: early finish, finish at the run_until target, finish during eval, and idle exhaustion are all rejected by both tools.
  • verify-sv-icarus / verify-sv-verilator --fresh --filter timing::: results above.
  • Untimed sanity checks after the shared adapter change: verify-sv-icarus --fresh --filter system_functions:: matches the retained evidence; Veryl counter:: on both tools.
  • cargo clippy with CI's package and feature set; cargo fmt --check.

Add `run_until`/`run_to_finish` script operations and `Design::timed`, the
`timing` SystemVerilog group, and retained Icarus/Verilator results for it.

A timed script begins with `run_until` or `run_to_finish`, so no case depends
on host inputs staged before time-zero initial blocks, always_ff listeners or
variable initializers. The external adapters compile timed designs unchanged:
the testbench settles with an Icarus read/write callback or a Verilator
clocking event, and a design `$finish` notice before the script reaches
`run_to_finish` fails the run. Port shapes of timed designs come from their
declarations with process bodies blanked for analysis only.

Celox runs the group through a timed `Simulation` with explicit exclusions:
the SV analyzer rejects procedural timing controls and plain `always`, host
clock writes do not trigger flip-flops, there is no four-state timed read, and
only the default backend builds a timed simulation.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 16, 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-16T13:13:54.452268Z f2efa12 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: 99176c3316

ℹ️ 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 thread crates/celox-test-suite/src/verilator.rs Outdated
Comment thread crates/celox-test-suite/src/script/sv.rs Outdated
Comment thread crates/celox-test-suite/src/script/interp.rs
Comment thread crates/celox-test-suite/src/script/sv.rs
@mergify

mergify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

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

- Validate timed sources with the macros each simulator predefines
  (VERILATOR, VERILATOR_TIMING, __ICARUS__), so guarded scale directives
  cannot bypass the rejection.
- Drop the $finish notice after the finishing marker before splicing the
  log, so a partial last line before run_to_finish stays comparable.
- Reject a first run_until target that reads the design: adapters evaluate
  it at different points of time zero.
- Reject final procedures in timed designs; they run in an arbitrary order
  relative to the checks after run_to_finish (IEEE 1800-2023 9.2.3).
@tignear
tignear force-pushed the feature/1123-oracle branch from 1e5cc8b to 25baccf Compare October 16, 2026 12:21

@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: 25baccff1a

ℹ️ 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 thread crates/celox-test-suite/src/script/sv.rs Outdated
Comment thread crates/celox-test-suite/src/sv/verification.rs
- Reject timed sources whose preprocessed text depends on the simulator's
  predefined macros, so the declaration pass that shapes the generated
  testbench sees exactly what each simulator compiles.
- Place the run_to_finish deadline one picosecond past RUN_UNTIL_LIMIT, so
  a design $finish due exactly at the limit runs before the sentinel
  instead of racing it in the same time slot.
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 16, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 16, 2026
@mergify

mergify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-16 13:39 UTC · Rule: changes · triggered by rule Queue explicitly requested merges
  • ✅ Checks passed · on draft merge queue: checking #1354 on master (9c612b4) #1357
  • ✅ Merged — 2026-10-16 14:14 UTC · at ade4b36a53a9bca7cc21108b60d6e18004c33521 · merge

This pull request spent 35 minutes 20 seconds in the queue, including 32 minutes 58 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 mentioned this pull request Oct 16, 2026
38 of 66 tasks
@mergify
mergify Bot merged commit ade4b36 into master Oct 16, 2026
26 checks passed
@mergify
mergify Bot deleted the feature/1123-oracle branch October 16, 2026 14:14
@mergify mergify Bot removed the queued Mergify queue entry label Oct 16, 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