Skip to content

[Moore][ImportVerilog] Replace $sformat/$swrite string dispatch with ksn#10557

Open
VecoMr wants to merge 1 commit into
llvm:mainfrom
VecoMr:import-verilog-refacto-sformat-swrite
Open

[Moore][ImportVerilog] Replace $sformat/$swrite string dispatch with ksn#10557
VecoMr wants to merge 1 commit into
llvm:mainfrom
VecoMr:import-verilog-refacto-sformat-swrite

Conversation

@VecoMr
Copy link
Copy Markdown
Contributor

@VecoMr VecoMr commented May 28, 2026

Move $sformat/$swrite handling from the fallback path in visit(ExpressionStatement) into visitSystemCall, replacing string comparisons with ksn::KnownSystemName dispatch already used for all other system tasks.

This also adds the previously missing $swrite[boh] variants with corresponding tests in basic.sv.

Move $sformat/ handling from the fallback path in visit(ExpressionStatement) into visitSystemCall, replacing string comparisons with ksn::KnownSystemName dispatch already used for all other system tasks.
This also adds the previously missing $swrite[boh] variants with corresponding tests in basic.sv.

Signed-off-by: adouard <alexandre.douard@ens-lyon.fr>
@circt-bot
Copy link
Copy Markdown

circt-bot Bot commented May 28, 2026

Results of circt-tests run for 844b19a compared to results for 3e54636: no change to test results.

Copy link
Copy Markdown
Contributor

@fabianschuiki fabianschuiki left a comment

Choose a reason for hiding this comment

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

LGTM! 🥳 Thanks for doing this cleanup! 😄

Copy link
Copy Markdown
Contributor

@TaoBi22 TaoBi22 left a comment

Choose a reason for hiding this comment

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

Thanks! There seems to be a possible crash but LGTM modulo that

// However, Section 21.3.3 explains that the output of $sformat/$swrite
// is assigned as if it were cast from a string literal (Section 5.9),
// so this implementation casts the string to the target value.
if (isSWrite) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we make sure that args contains the expected number of arguments? I'd hoped Slang would handle this but having checked it seems that if we feed in too few arguments we hit a crash.

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.

3 participants