Skip to content

feat(veryl)!: run #[test] initial blocks as process kernels - #1161

Draft
tignear wants to merge 184 commits into
feature/1123-clock-waitsfrom
feature/1123-veryl-kernels
Draft

tignear wants to merge 184 commits into
feature/1123-clock-waitsfrom
feature/1123-veryl-kernels

Conversation

@tignear

@tignear tignear commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #1160, part of #1123. Veryl test initial blocks compile to timed process kernels; testbench_kernels(false) retains the bytecode runner. Kernels preserve helper order, short-circuit/four-state behavior, copy-back, suspended storage, clock/reset waits and assertion output. Terminating expression arms contribute no continuation or dirtiness to a join, while writing arms that return still settle before reads.

Pending display/write bytes are forwarded before later component/file host requests, retaining assertion and finish events for normal draining. Completed clock-release settles are reused by clean continuations. Generated clocks reset and derived inputs settle before component initialization; an interrupted reset restores release targets before the next run while preserving first-run reset counts. Existing component expectations remain unchanged.

Internal/component/release settles capture transient FF occurrences before continuations can erase them. Ordinary Finish stops immediately; Veryl FinishAfterPublication preserves the final publication boundary. The inherited SV loop budget resumes the same process immediately, and interrupted/zero-count continuations retain runnable work. Rust host writes share readiness/edge publication across modify and direct setters, including eager runtime-event drain settling and intervening reads/evaluation. Host readiness uses a checkpointed explicit marker, and all backends retain Finish independently of diagnostic-ring overflow.

Native container32 validates counters, offsets, testbench boundaries, clocks, releases, host requests, tick-loop eligibility and the new Finish header ABI. Attachment requires a trusted whole artifact, including code and ABI metadata. Host paths retain declared bytes/strict UTF-8, outgoing values are snapshotted before reentrant selectors, and suspended values retain X/Z. Ordered preprocessing, typed external drivers and cross-file package initializer probes are integrated from #1159; zero-trip dependency proofs retain executed headers while excluding unreachable bodies/steps.

Validation: library288, SV3156 (20 existing exclusions), checkpoint30, component63, SDK13, concurrent initial/runtime99 and stepping7 pass. NAPI is freshly rebuilt; all437 JavaScript tests plus types/lint pass. Formatting and affected all-target clippy pass. Public API regressions reproduce the pre-fix readiness failures and check actual execution across four backends; portable zero-trip and cross-file initializer cases are wired into the shared harness. The128-case independent timing comparison passes124 Icarus and126 Verilator cases with only existing exclusions/limitations, and all10 live adapter integrations pass. Imported CI/queue configuration passes47 script tests; this import changes no product/test/dependency inputs, so successful product validation is reused. Retained reports/exclusions were not refreshed. Full platform and latest-head CI remain required before merge.

The initial blocks of a Veryl `#[test]` module are compiled into process
kernels and run by the timed scheduler instead of the testbench bytecode
interpreter, which stays as a fallback behind
`SimulatorBuilder::testbench_kernels(false)`.

The frontend lowers each block with the procedural expression lowering
over the elaborated instance's stable state. Loop counters and bounds
live in state so a wait inside a loop can suspend; each block owns a copy
of the function-local variables; a hierarchical reference is a synthetic
variable addressing the child's state. Clock waits become clock waits
with fused ticks, `rst.assert` a clock wait with a release, random
numbers and component methods host requests served through scratch
state, and a read of design state after a store settles the
combinational logic first through the new `Settle` status.

The scheduler applies releases as events of their domain, fires the
falling and rising edges of a time together after the processes ran,
treats an edge from an unknown four-state value as an edge, and stops
resuming processes once the tick budget is spent. Hash maps embedded in
native images serialize in key order so a build cache round trip
reproduces the image.

BREAKING CHANGE: `%t` in a testbench and the time a component's finish
hook observes are the scheduler time, in which the default process clock
has period 2; single-process testbenches previously saw the tick count.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 9, 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-15T19:27:42.295861Z acfd080 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: e24dae3def

ℹ️ 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-frontend-veryl/src/lowering/process.rs
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs Outdated
Comment thread crates/celox-runtime/src/simulation.rs Outdated
Comment thread crates/celox/src/testbench/kernels.rs Outdated
Comment thread crates/celox-runtime/src/simulation.rs Outdated
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs
@codspeed

codspeed Bot commented Oct 9, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

⚠️ 3 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 4 untouched benchmarks


Comparing feature/1123-veryl-kernels (d2310ea) with feature/1123-clock-waits (cf4c82e)

Open in CodSpeed

- Track the dirty state per branch side and merge it at the join, so a
  read after a branch whose one side stored and whose other side waited
  settles the logic.
- Settle the logic a component's output writes feed before the kernel
  resumes.
- Plan scratch state like the lowering: a side a constant condition
  keeps out, and a loop over a constant-empty range, take none.
- Resume a process at once after its host request is served, as the
  `Host` status documents; no other process runs inside the statement.
- A `$finish` of the design's own logic completes the kernel run and
  is not reported as a tick limit.
- Four-state edge detection follows IEEE 1800-2023 Table 9-2 in both
  edge paths: changes into x or z from 0 or 1 are edges too.
- Validate the index and select geometry of a hierarchical destination
  like a local one.

@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: d2310eaf54

ℹ️ 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/src/testbench/kernels.rs Outdated
Comment thread crates/celox/src/testbench/kernels.rs Outdated
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs
Comment thread crates/celox-runtime/src/simulation.rs Outdated
Comment thread crates/celox-runtime/src/simulation.rs
Comment thread crates/celox/src/testbench/kernels.rs
Comment thread crates/celox/src/ir.rs Outdated
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs Outdated
Comment thread crates/celox/src/testbench/kernels.rs

@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: 3659b4d86d

ℹ️ 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/src/simulator.rs Outdated
Comment thread crates/celox-runtime/src/simulation.rs
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs Outdated
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs

@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: 2b75903230

ℹ️ 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/src/testbench/kernels.rs
Comment thread crates/celox/src/testbench/kernels.rs
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs Outdated

@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: a0d0eee9cd

ℹ️ 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-frontend-veryl/src/lowering/process.rs
Comment thread crates/celox-runtime/src/simulation.rs Outdated
# Conflicts:
#	crates/celox-runtime/src/simulation.rs
#	crates/celox/tests/processes.rs
- A kernel yields to the host every 256 runtime events, and the executor
  takes the events out of the ring at each yield, so an uninterrupted block
  with many `$assert`s or `$display`s loses none.
- A block that ends right after a store settles first.
- `clk.next(0)` continues at once; a reset release settles before the
  released process reads.
- The runner starts every process clock low, reads a component's
  completion request before the teardown, tears the components down when
  the initial settling fails, and runs as kernels only when the schema
  marks a Veryl testbench (`RuntimeSchema::testbench_kernels`), which also
  keeps a design's own processes among the RTL writers.

@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: 1973cd9636

ℹ️ 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/src/simulation.rs Outdated
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs Outdated
@tignear
tignear added this pull request to stack #1173 October 10, 2026 10:11
@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.

@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: 16def71364

ℹ️ 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-frontend-veryl/src/testbench.rs Outdated
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs Outdated

@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: e11fe79983

ℹ️ 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-frontend-veryl/src/lowering/process.rs Outdated

@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: aa866fef70

ℹ️ 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-frontend-veryl/src/lowering/process.rs
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs Outdated
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs
Comment thread crates/celox-frontend-veryl/src/lowering/process.rs Outdated
@tignear
tignear added this pull request to the merge queue Oct 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Oct 10, 2026

@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: 47f2473a28

ℹ️ 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/src/testbench/kernels.rs

@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: c1fc27533f

ℹ️ 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-runtime/src/simulation.rs
Comment thread crates/celox/src/simulation.rs

@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: 45437174c2

ℹ️ 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-frontend-veryl/src/lowering/process/expressions.rs Outdated
Comment thread crates/celox/src/testbench/kernels.rs
@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 commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

Converted to draft: superseded by the redesign in #1123 (comment). Kept as a reference implementation; it will be closed when its replacement merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant