Skip to content

feat(sv): implement $urandom - #1294

Merged
mergify[bot] merged 5 commits into
masterfrom
feature/sv-urandom
Oct 16, 2026
Merged

mergify[bot] merged 5 commits into
masterfrom
feature/sv-urandom

Conversation

@tignear

@tignear tignear commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Implements $urandom, $urandom() and $urandom(seed) in clocked processes, initial, always_comb, always @*, and their subroutines (IEEE 1800-2023 18.13.1 and 18.14). Results are unsigned 32-bit values. Integral seed expressions, including zero, reproduce the sequence without modifying the argument. Narrow signed seeds retain their sign extension when converted to the 32-bit seed formal; subroutines share the caller’s stream.

Each process owns a persistent RNG and receives its default seed in elaborated static-process creation order. Variable declaration initializers participate in seed allocation and execute before ordinary initial blocks; synthetic parameter-storage initialization consumes no process seed. Calls execute in statement order, short circuits skip draws, and separate calls in a select remain distinct. Checkpoints and state files restore both the sequence and combinational activation state. Combinational procedures advance their stream only on activation: always_comb also runs at time zero after initial procedures start; always @* waits for a sensitivity change. Untimed Simulator marks its omitted initial kernels completed so they cannot block combinational activation; timed Simulation retains the initial-start ordering gate. Repeated evaluation with unchanged inputs consumes no draws. Four-state sensitivity includes mask-only changes, static selections and reads in pruned branches. Process output scheduling preserves activation atomicity in parallel backends and precise downstream observer notifications.

Each module instance owns an initialization RNG starting from the implementation-defined default seed (IEEE 1800-2023 18.14.1). Equivalent processes in sibling instances may therefore start with equal values. Their relocated RNG states advance independently, including when sibling clocks run in a different order.

The compiler lowers the generator to ordinary arithmetic and state stores using a full-period 32-bit LCG. The sequence and default seeds are implementation-defined. Constant-value contexts reject random calls; unevaluated return-type queries remain valid. Both language guides describe supported behavior.

Validation:

  • Local specification and diff review completed, covering distinct select calls, unified process seed order, signed seed conversion and untimed versus timed initial startup.
  • Full affected Rust/frontend/backend/common suite: 11,896 passed, 281 existing skips. After the final observer corrections, the complete SV and observer suites also passed: 3,294 tests, 52 existing skips. The 76 focused random regressions cover time-zero ordering, function sensitivity, source-order seed stability, random declaration initialization, parameter-storage neutrality, independent sibling streams, partial/dynamic/array observers, four-state inputs, all five backends, interpreter execution and checkpoint/state-file replay. The unit suite also checks SIR control-flow imports.
  • Latest initializer-origin review fixes: 2,592 SV/initial consumer tests passed, 30 existing skips; 343 analyzer/frontend unit tests passed, 4 existing skips. The preceding public-runtime fixes also passed 3,596 runtime/SV consumers, covering timed simulation, checkpoint/state-file restoration, concurrent initials and observers.
  • Frontend/analyzer/SIR unit suite: 385 passed, 4 existing skips. Formatting, diff checks, affected all-target clippy, retained external evidence contract tests and affected doctests pass.
  • NAPI rebuilt after the review fixes: 400 JS simulator tests, 122 Vite-plugin tests, and all fixture/watch integration tests pass.
  • Pinned sv-tests: all 923 expectations match (409 pass, 457 fail, 57 no top), without baseline changes.
  • New combinational statement-order case passes both Verilator 5.052 and Icarus 13.0. The distinct-select-call regression passes Icarus; generated Verilator C++ removes/reorders its seeded calls, so that reviewed failure is added to the existing Verilator statement-order limitation group. Assertions remain intact. The signed-seed case retains all 256 8-bit patterns: Verilator hits its known zero-seed failure and Icarus rejects seed variables narrower than 32 bits. A standalone check of all 255 nonzero patterns passes Verilator and reproduces the Icarus width rejection. These reviewed external failures remain documented in verification/repros/sv_urandom.json; passing and unrelated historical evidence is unchanged.

Earlier standalone Veryl jobs reported a nested Cargo.lock update under --locked and a retained proof coverage/identity mismatch; the restored focused CI policy is now included in this branch. No Veryl cases, lockfiles or proof manifests are changed by the SV implementation.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 15, 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-16T07:34:40.895511Z 8d6470f Manual request
ℹ️ 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: ba5ef4be17

ℹ️ 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".

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

ℹ️ 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".

@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: 193524d68c

ℹ️ 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".

@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: 89317ff36d

ℹ️ 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".

@tignear tignear changed the title feat(sv): implement $urandom feat(sv): implement $urandom Oct 15, 2026
@tignear tignear changed the title feat(sv): implement $urandom feat(sv): implement $urandom Oct 15, 2026
@mergify

mergify Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

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

Allocate process seeds to declaration initializers while excluding synthetic
array-parameter storage initialization. Preserve the origin through AST scope
copies and IR conversion, and retain initializer execution ordering.

Verify default-stream stability and independent sibling state. IEEE 1800-2023
18.14.1 initializes each scope's initialization RNG with the default seed, so
matching default values across sibling scopes remain intentional.
@tignear

tignear commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Hooray!

Reviewed commit: 8d6470fe54

ℹ️ 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".

@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

This pull request spent 1 hour 25 minutes 44 seconds in the queue, including 1 hour 24 minutes 19 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 4d8fde6 into master Oct 16, 2026
26 checks passed
@mergify
mergify Bot deleted the feature/sv-urandom branch October 16, 2026 09:07
@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