Skip to content

[ImportVerilog]add support for String literal operations #8309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ChenXo0
Copy link

@ChenXo0 ChenXo0 commented Mar 10, 2025

https://chipsalliance.github.io/sv-tests-results/tests/chapter-11/11.10.1--string_compare.sv.html
add support like display(a) and $display(":assert:('%s' == 'testtesttesttest')", str);
string is available to be used in display function

@ChenXo0 ChenXo0 marked this pull request as draft March 10, 2025 11:06
@ChenXo0 ChenXo0 changed the title add support for String literal operations [ImportVerilog]add support for String literal operations Mar 11, 2025
@terapines-osc-1
Copy link
Member

The string type will be transformed into the bit type starting at 0 in the slang AST if I remember correctly. And if you want to solve string assignment ops, I think we have completed that. Please check the related test cases (https://github.com/llvm/circt/blob/main/test/Conversion/ImportVerilog/basic.sv). 😃

@ChenXo0
Copy link
Author

ChenXo0 commented Mar 11, 2025

The string type will be transformed into the bit type starting at 0 in the slang AST if I remember correctly. And if you want to solve string assignment ops, I think we have completed that. Please check the related test cases (https://github.com/llvm/circt/blob/main/test/Conversion/ImportVerilog/basic.sv). 😃

Maybe I didn't explain it clearly. Currently, when import-verilog processes strings, it converts the bit vector to the !moore.string type through convertOp. When display(str), because str is of string type, it does not match the input of display, so I add another convertOp to convert string to bit vector , as well as support for NamedValueExpression and ConcatenationExpression in display (previously, display function could only process stringliteral types).
for example:

string c = "hello";

will be translate as:

    %0 = moore.string_constant "hello" : i40
    %1 = moore.conversion %0 : !moore.i40 -> !moore.string
    %c = moore.variable %1 : <string>

I add correspond test case at the bottom of basic.sv

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.

2 participants