Skip to content

fix(sv): report %t in the smallest time precision of the design - #1825

Merged
mergify[bot] merged 2 commits into
masterfrom
fix/sv-timeformat-default
Oct 24, 2026
Merged

mergify[bot] merged 2 commits into
masterfrom
fix/sv-timeformat-default

Conversation

@tignear

@tignear tignear commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Part of #1123. Fixes #1821.

IEEE 1800-2023 20.4.3, Table 20-3: without $timeformat, %t reports time in the smallest time precision of all the design's time scales, with no fractional digits and a minimum field width of 20. Celox printed the value in the time unit of the calling scope instead.

Under `timescale 1ns/1ps, after #1.5 Before Now (= Icarus 13.0 and Verilator 5.052)
$display("%0t", $realtime) 2 1500
$display("%t", $time) 2 2000
$display("%0t", n) with int n = 7 7 7000
%0t in a 1us/1us module, global precision 1 ps, of 2 2 2000000

Change

  • The analyzer gives $time and $realtime the calling scope's ticks per time unit, where a tick is one unit of the global precision. %t values now get the same factor.
  • When the analyzer builds a $display/$write (and b/o/h forms), $fdisplay/$fwrite, $error/$warning/$info/$fatal or Veryl $assert call, it reads the template's conversions. Each value a %t converts becomes value * 64'd<ticks>.
    • Integral values stay 64-bit.
    • A real such as $realtime is multiplied as a real and printed with precision 0.
  • A scope whose unit equals the global precision (factor 1) is left untouched.
  • A $display in a package subroutine uses the package's unit; checked against Verilator.

Behaviour change: a design without any time scale uses Celox's documented 1 ns / 1 ps defaults, so %t now reports picoseconds there (%t of 7 prints 7000). Icarus prints 7 there only because its own default is 1 s / 1 s. The existing case time_format_consumes_its_expression_argument therefore now states `timescale 1ns/1ns, so all three simulators keep agreeing on it.

$timeformat itself remains unsupported (rejected by name), so there are no overrides to cover.

Perf

Optimized SIR (TraceOptions::post_optimized_sir, hashed Debug text) is byte-identical between base 07999a2 and this branch for 658 of the 660 SV suite cases, timed and untimed. The two that differ are the new cases.

Tests

  • New vtests, both passing on Celox, Icarus and Verilator:
    • time_format_defaults_to_the_smallest_precision (timed, $time, $realtime, an int, the default width)
    • time_format_scales_each_scope_to_the_smallest_precision (1 ns / 1 ps and 1 us / 1 us modules)
  • The retained system_functions.json reports gain only the two records.
  • --test systemverilog: 4286 passed. The analyzer, frontend-sv and test-suite tests and retained_reports pass; sv-tests matches expected.tsv.
  • Docs (EN/JA): "Time and precision".

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 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-24T03:28:25.539741Z f2c286d 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: 5bc3b03cc9

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

@mergify

mergify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

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

@tignear
tignear force-pushed the fix/sv-timeformat-default branch from 5bc3b03 to d4c98a3 Compare October 23, 2026 12:35

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

ℹ️ 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 force-pushed the fix/sv-timeformat-default branch from d4c98a3 to a2dcd97 Compare October 23, 2026 14:12

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

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

%t printed its value in the time unit of the calling scope. Without
$timeformat, IEEE 1800-2023 20.4.3 (Table 20-3) reports it in the
smallest time precision of the design, in which the simulation counts its
time. The analyzer now scales each value a %t of a display, file output
or severity task converts by its scope's ticks per time unit, as it does
for $time; a scope whose unit is the global precision is unchanged.
`#1.5` under `timescale 1ns/1ps then $display("%0t", $realtime) prints
1500, as Icarus and Verilator do, instead of 2.

A string literal converts as its packed bytes and keeps any literal form; a
signed value keeps its sign. A string variable has no time to report and is
rejected instead of printing its storage handle.

Fixes #1821

Change-Id: Ied354a869434803679f082169c0fdca8028a653f
Change-Id: Ia98f17bfaa1c302d8af5cbe9a143c2c42990face
@tignear
tignear force-pushed the fix/sv-timeformat-default branch from a2dcd97 to f2c286d Compare October 24, 2026 03:26
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 24, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 24, 2026
@mergify

mergify Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

This pull request spent 1 hour 16 minutes 14 seconds in the queue, including 51 minutes 57 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 ac3f6ca into master Oct 24, 2026
30 checks passed
@mergify
mergify Bot deleted the fix/sv-timeformat-default branch October 24, 2026 06:07
@mergify mergify Bot removed the queued Mergify queue entry label Oct 24, 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: %t prints the module time unit instead of the smallest precision

1 participant