Skip to content

fix(sv): scale and round real-valued delays - #1723

Merged
mergify[bot] merged 2 commits into
masterfrom
fix/sv-real-delays
Oct 22, 2026
Merged

mergify[bot] merged 2 commits into
masterfrom
fix/sv-real-delays

Conversation

@tignear

@tignear tignear commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Fixes #1707. Part of #1123.

A real-valued delay used its IEEE bit pattern as an integral delay.

  • shortreal r = 1.5; #r waited 1069547520 ticks.
  • real r = 1.5; #r and #(0.5 + 1) stopped with "simulation delay overflows the simulation time range".

Change

  • Analyzer: Stmt::Delay also carries ticks_per_precision, the global ticks in one precision step of the declaring scope. It comes from the same timescale lookup as ticks_per_unit (time_divisor and the new precision_divisor share one helper).

  • Frontend (ff.rs delay / real_delay): a delay whose amount is real or shortreal is:

    • multiplied into precision steps of its scope (10^(unit − precision));
    • converted with the existing real-to-integer conversion, which rounds ties away from zero (6.12.1), keeps the low 64 bits so a negative value reads as its two's complement (9.4.1), and turns NaN or ±inf into 0;
    • scaled to global ticks with the existing overflow check.

    Integral delays take the same path as before.

  • Analyzer: an unparenthesized real literal such as #1.5 is accepted as a delay value (delay_value ::= real_number, A.2.2.3). It was rejected as "delay value" before; the analyzer test that pinned that rejection is removed.

Tests

  • timing.vtest real_delays_round_at_the_scope_precision (default 1ns/1ps):
    • 2.75 waits 2750 ps;
    • the tie 0.0625 waits 63 ps;
    • shortreal 0.25 waits 250 ps;
    • NaN waits 0;
    • #(r * 2) waits 5.5 ns.
  • negative_real_delays_wait_their_twos_complement: #(-1.5) does not wake before $finish.
  • External simulators: verify-sv-icarus and verify-sv-verilator --fresh pass both cases, and the retained timing.json diffs only add lines.
    • A standalone probe shows that Verilator 5.052 treats a negative real delay as 0 outside the suite harness; inside the harness it passes the case.
    • Icarus 13.0 follows 9.4.1.
    • Both agree on rounding, ties and NaN.
  • Rust real_delays_round_at_scope_precision: exact picosecond times at O0 and O1, in a 1 ns/1 ps scope (2.7505 → 2751 ps) and a 1 ns/100 ps scope (2.75 → 2.8, 1.25 → 1.3, shortreal 0.05 → 0.1).

Docs

The EN and JA SV guide and reference now describe real delays (rounding, negative, NaN) and drop the #1707 links.

Validation

  • --test systemverilog: 3661 passed.
  • The analyzer, frontend-sv and test-suite crates pass.
  • clippy -D warnings and fmt are clean.
  • pnpm docs:build passes.
  • sv-tests conformance (c4229f3bd5) is identical to expected.tsv.

A real delay used its IEEE bit pattern as an integral delay. Scale it to
precision steps of its scope, round ties away from zero (IEEE 1800-2023
3.14.1, 6.12.1), and read a negative result as a two's-complement time
(9.4.1); a NaN delay waits zero. Unparenthesized real literals such as
#1.5 are accepted as delay values.

Fixes #1707.

Change-Id: I3456fc82b11d94301a99a1f26713e53cedc36b02
Change-Id: I16e53bbe8443848786f4d8debb9e84409384645e
@chatgpt-codex-connector

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 ⚠️ Failed 2026-10-22T04:00:42.441673Z
We couldn’t complete this review. Comment @codex review to try again.
3e1f2dd 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

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.

@mergify

mergify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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

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

mergify Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-22 04:56 UTC · Rule: changes · triggered by rule Queue explicitly requested merges
  • ✅ Checks passed · on draft merge queue: checking #1723 on master (3430315) #1727
  • ✅ Merged — 2026-10-22 06:00 UTC · at bf295a3cb978dd950ae6108a30a56502969ddd41 · merge

This pull request spent 1 hour 3 minutes 19 seconds in the queue, including 1 hour 1 minute 6 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 22, 2026
40 of 71 tasks
@mergify
mergify Bot merged commit bf295a3 into master Oct 22, 2026
30 checks passed
@mergify
mergify Bot deleted the fix/sv-real-delays branch October 22, 2026 06:00
@mergify mergify Bot removed the queued Mergify queue entry label Oct 22, 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.

SV: real-valued delays use the IEEE bit pattern as the delay

1 participant