Skip to content

[ImportVerilog] Cannot compile forward decleared string type #8283

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

Open
Max-astro opened this issue Feb 28, 2025 · 3 comments
Open

[ImportVerilog] Cannot compile forward decleared string type #8283

Max-astro opened this issue Feb 28, 2025 · 3 comments

Comments

@Max-astro
Copy link
Contributor

I want to support this sv-tests-results/string_concat_op feature, but not sure how to fix it properly.

module top();

string str;

initial begin
    str = "Hello";
end

endmodule

circt-verilog has the following complaints when compiling the string.sv file:

string str;
       ^
s.sv:3:8: note: see current operation: %0 = "moore.variable"() <{name = "str"}> : () -> !moore.ref<string>

This error is due to MooreToCore's lack of string-type conversion. It only has StringConstantOpConv and Format*OpConversion; none of these conversions can handle the string type.

@chenbo-again
Copy link
Contributor

I found hw dialect has HWStringType, and maybe it's a proper target for lowering moore.string.

@fabianschuiki
Copy link
Contributor

Thanks for working on this, @Max-astro! HW doesn't have very good string support -- it's limited mostly to fixed-sized strings or strings that can be passed to module instances as parameter. There has been a recent effort in the Sim dialect, which collects simulation-related things, to come up with ways to do string formatting and representing format string literals. I think the Sim dialect would be a great place to add a type for dynamic strings such as Verilog's string type, and also have operations like concatenation, casting, and indexing. Maybe that would be a way forward for you?

@Max-astro
Copy link
Contributor Author

I think the Sim dialect would be a great place to add a type for dynamic strings such as Verilog's string type, and also have operations like concatenation, casting, and indexing.

Thank you for your advice, I'll take a look at the Sim dialect and see if it's easy to add a dynamic string type.

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

No branches or pull requests

3 participants