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
Unable to pass strings into C functions in compiled code #747
Comments
Original Redmine Comment Verilator only supports strings in a few limited cases. Might you attempt a patch? This one houldn't be too bad in V3Width 's AstSFormat visitor look for 's' with the corresponding node having a dtypep->basicp of AstBasicDTypeKwd::STRING, change the code to %S, then in V3Emit use %S to mean add a ".c_ptr()" when printing the nodep. |
Original Redmine Comment I spent a little time playing with this and it looks like the code will require quite a bit more work. The problem is that the generated C code assigns integers to string objects. For example, the attached .v file includes the following assignment in the resulting .cpp file:
As you can see, the code is assigning my two strings as integers to the string object. This ends up assigning only the least-significant byte (0x6f) to my string object, not the sequence of bytes. |
Original Redmine Comment I guess V3Width will need to be taught how to do string promotion. It's best if you wait until my present set of edits is in. Then you'd see that there's a dtype of string being assigned a dtype of a number, and would convert to a AstConstString. |
Original Redmine Comment Fixed in git towards 3.867. |
Original Redmine Comment In 3.868. |
Disable dependabot
Author Name: Glen Gibb
Original Redmine Issue: 747 from https://www.veripool.org
Original Date: 2014-04-21
Original Assignee: Wilson Snyder (@wsnyder)
gcc produces the following error when I try to pass a Verilog string into a $display statement:
(This error is generated for the attached t_string_print.v file.)
The text was updated successfully, but these errors were encountered: