Skip to content

feat(sv): support $sformatf and $sformat - #2402

Open
tignear wants to merge 1 commit into
masterfrom
stack/tignear/feat/sv-uvm-string-format/support-sformatf-sformat--fe5fd5bc
Open

tignear wants to merge 1 commit into
masterfrom
stack/tignear/feat/sv-uvm-string-format/support-sformatf-sformat--fe5fd5bc

Conversation

@tignear

@tignear tignear commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Implement formatting to a string (IEEE 1800-2023 21.3.3). The analyzer binds
$sformatf(format, args...) as a string operation, so it is typed string
wherever a string value is valid: assignments, function results, arguments,
concatenations and conditional operands. $sformat(output, format, args...)
assigns the same value to a string variable, a function's return variable or
a string class property.

A call with conversions is a synchronous host request of the scheduled
process. The host renders the format with the $display renderer, so every
conversion, field width, X/Z digit and %m scope matches $display, and
interns the text as the result. A literal format is fixed at compile time and
its %t values are scaled as the analyzer scales those of $display; a
string or integral format is read when the call runs and the host scales
its %t values. A literal without conversions or arguments is a constant.
Integral outputs, %p and the $swrite family remain unsupported.

A host request in a later input of a subroutine call would otherwise lose the
registers computed for earlier inputs across the suspension, so those inputs
are kept, converted to their formals, in temporaries; operands of string,
object and container operations are materialized as the heap helpers already
do. A cached transitive check finds subroutines
that make host requests, including in the defaults of omitted arguments. A
format read at run time keeps bytes that are not UTF-8.
$display now resolves every string-valued argument, not only string
identifiers, so a string conditional prints its text.

The shared string_format cases compare $sformatf and $sformat with
$display on all backends and in a native image. Verilator 5.052 passes all
of them (the four-state case is unsupported there); Icarus 13.0 limitations
(string conditional crash, class-property output, integral format) and an
xezim 0.11.3 integral-format bug are retained with evidence.

@tignear

tignear commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(sv): support $sformatf and $sformat #2402 👈
2 feat(sv): support the $swrite family #2403
3 feat(sv): support %p for integral, string, handle and container values #2423

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-28T17:55:36.202429Z 242cd1f 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: 290e01820f

ℹ️ 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-sv/src/lowering/procedural.rs
Comment thread crates/celox/src/simulator/host/format.rs Outdated
@mergify

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

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

@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-string-format/support-sformatf-sformat--fe5fd5bc branch from 290e018 to 27e5a3d Compare October 28, 2026 08:40
@tignear

tignear commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 290e018 2026-10-28 08:40 UTC
2 content 290e018 → 27e5a3d Address Codex review 5679124714: check omitted-argument defaults (and nested defaults) when deciding whether a call can make a host request, evaluate subroutine inputs before a later host request, an… 2026-10-28 08:40 UTC
3 content 27e5a3d → d484bec 2026-10-28 10:18 UTC
4 content d484bec → 3703011 2026-10-28 11:31 UTC
5 content 3703011 → f7aeb22 Sync with master after #2322: Format host requests use family 7 (Process took 6), and $sformatf bypasses the new operand materialization in string_call, which truncated its format literal to 32 bits. 2026-10-28 12:53 UTC
6 content f7aeb22 → 5ab0f09 2026-10-28 13:52 UTC
7 content 5ab0f09 → bfa9061 2026-10-28 16:23 UTC
8 content bfa9061 → 242cd1f 2026-10-28 17:51 UTC

@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: 27e5a3d152

ℹ️ 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-sv/src/lowering/ff.rs Outdated
@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-string-format/support-sformatf-sformat--fe5fd5bc branch from 27e5a3d to d484bec Compare October 28, 2026 10:19

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

ℹ️ 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-sv/src/lowering/ff.rs Outdated
@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-string-format/support-sformatf-sformat--fe5fd5bc branch from d484bec to 3703011 Compare October 28, 2026 11:32

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

ℹ️ 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-sv/src/lowering/ff.rs Outdated
Comment thread crates/celox-frontend-sv/src/lowering/ff.rs Outdated
@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-string-format/support-sformatf-sformat--fe5fd5bc branch from 3703011 to f7aeb22 Compare October 28, 2026 12:54
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 28, 2026
@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-string-format/support-sformatf-sformat--fe5fd5bc branch from f7aeb22 to 5ab0f09 Compare October 28, 2026 13:52
@mergify mergify Bot added the queued Mergify queue entry label Oct 28, 2026
@mergify

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

21 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Wed 28 Oct, 14:50 · rule changes · triggered by rule Queue explicitly requested merges
  • 🚫 Left the queue 15:11 · 5ab0f09

Reason

The pull request conflicts with master

Hint

You should update or rebase your pull request.

If you want to requeue this pull request, you can post a @mergifyio queue comment.

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

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added dequeued Mergify stopped this queue entry; investigate before retrying and removed queued Mergify queue entry labels Oct 28, 2026
@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-string-format/support-sformatf-sformat--fe5fd5bc branch from 5ab0f09 to bfa9061 Compare October 28, 2026 16:23
@mergify mergify Bot removed the dequeued Mergify stopped this queue entry; investigate before retrying label Oct 28, 2026
Implement formatting to a string (IEEE 1800-2023 21.3.3). The analyzer binds
`$sformatf(format, args...)` as a string operation, so it is typed `string`
wherever a string value is valid: assignments, function results, arguments,
concatenations and conditional operands. `$sformat(output, format, args...)`
assigns the same value to a string variable, a function's return variable or
a string class property.

A call with conversions is a synchronous host request of the scheduled
process. The host renders the format with the `$display` renderer, so every
conversion, field width, X/Z digit and `%m` scope matches `$display`, and
interns the text as the result. A literal format is fixed at compile time and
its `%t` values are scaled as the analyzer scales those of `$display`; a
`string` or integral format is read when the call runs and the host scales
its `%t` values. A literal without conversions or arguments is a constant.
Integral outputs, `%p` and the `$swrite` family remain unsupported.

A host request in a later input of a subroutine call would otherwise lose the
registers computed for earlier inputs across the suspension, so those inputs
are kept, converted to their formals, in temporaries; operands of string,
object and container operations are materialized as the heap helpers already
do. A cached transitive check finds subroutines
that make host requests, including in the defaults of omitted arguments. A
format read at run time keeps bytes that are not UTF-8.
`$display` now resolves every string-valued argument, not only string
identifiers, so a string conditional prints its text.

The shared string_format cases compare `$sformatf` and `$sformat` with
`$display` on all backends and in a native image. Verilator 5.052 passes all
of them (the four-state case is unsupported there); Icarus 13.0 limitations
(string conditional crash, class-property output, integral format) and an
xezim 0.11.3 integral-format bug are retained with evidence.

Change-Id: Ife5fd5bc64ccbecb7a73976fc8b68f22e5216d53
@tignear
tignear force-pushed the stack/tignear/feat/sv-uvm-string-format/support-sformatf-sformat--fe5fd5bc branch from bfa9061 to 242cd1f Compare October 28, 2026 17:52

@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: 242cd1fc09

ℹ️ 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 on lines +92 to +93
Ok(sv::ir::Expr::Ident(name))
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve DPI-C inputs across formatting host requests

With sv-dpi enabled, a formatting request in a later DPI-C argument leaves earlier arguments live in registers across suspension. For example, combine(a, formatted_length()), where formatted_length() calls $sformatf and returns the resulting string's length, reaches Ff::dpi_call, which evaluates and retains a in registers before hoisting the second argument (ff.rs:1993–2018). The formatting request resumes through a new kernel invocation, so that earlier register is no longer available when the ExternCall executes. The new input-preservation logic only covers ordinary subroutine calls; apply equivalent formal-type-aware capture and reload to DPI-C arguments as well.

Useful? React with 👍 / 👎.

@mergify mergify Bot added the queued Mergify queue entry label Oct 28, 2026
@mergify

mergify Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

🚫 Left the queue

1 min in the queue, with no time running CI.

So far

  • ✅ Entered the queue Wed 28 Oct, 18:17 · rule changes · triggered by rule Queue explicitly requested merges
  • 🚫 Left the queue 18:18 · 242cd1f

Reason

The pull request conflicts with master

Conflicting file: crates/celox-design/src/lib.rs

Hint

You should update or rebase your pull request.

If you want to requeue this pull request, you can post a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added dequeued Mergify stopped this queue entry; investigate before retrying and removed queued Mergify queue entry labels Oct 28, 2026

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

dequeued Mergify stopped this queue entry; investigate before retrying merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant