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
Problems attempting to redefine VL_PRINTF #1598
Comments
Original Redmine Comment Originally VL_PRINTF was intended to be overridden in a .mk file which overrode the default verilator.mk file. For this reason VL_PRINTF is also defined in verilated.mk, hence the GCC warning about multiple definitions of it. That overriding also edited the make rules to insert a special #include. What you are doing is perfectly reasonable, and probably a better way. Please try removing VL_PRINTF from verilated.mk.in, and reinstall verilator (or just hack verilated.mk yourself.) Then you have the missing definition problem... For that I'd suggest we add to the top of verilatedos.h
then add -DVL_VERILATED_INCLUDE="foo" If this all works out send a patch and I'll merge it upstream. Thanks. |
Original Redmine Comment Thanks for the pointers, I will persevere with that aproach and try and get a patch out ... |
Original Redmine Comment Did the redefinition etc work for you? if so, can you send back a patch of what worked out? Thanks. |
Original Redmine Comment Just got round to this, yes, the attached patch works when combined with adding the following to the Verilator command line: my_printf.cpp --CFLAGS '-DVL_PRINTF=my_printf -DVL_VERILATED_INCLUDE="my_printf.h" -I..' Thanks PS: I included VL_VERILATED_INCLUDE in verilated.h rather than verilatedos.h since it seems a better fit (given it is intended only for verilated output, not the host side tool itself?) |
Original Redmine Comment Yes, that looks like a fine place. Do you agree this (and future so don't need to ask again) contributions are open sourced as per the Developer Certificate of Origin (https://developercertificate.org/)? |
Original Redmine Comment Yes, Agreed |
Original Redmine Comment Thanks for your work. Pushed to git towards eventual 4.024 release. |
Author Name: Julien Margetts
Original Redmine Issue: 1598 from https://www.veripool.org
Original Assignee: Julien Margetts
I need my verilated model to call something other than printf to perform output $display, and the intended way to do that (according to verilated.h) appears to be to re-define VL_PRINTF
However doing so seems to cause a number of unexpected warnings. It is also unclear what the proper approach should be to make the verilator generated make file 'aware' of the declaration of my new output function (I.e. how do I tell verilator to put "#include "my_printf.h" into the verilated output code)
I'm sure I'm making a schoolboy error here but any pointers would be helpful.
NOTE: I can work around this by overiding printf itself (and not using -DVL_PRINTF=my_printf) by adding my own version of printf as a wrapper for my new output function to the verilator input files, but I would rather use -DVL_PRINTF=xxxx if that was the intended approach.
The text was updated successfully, but these errors were encountered: