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
Trying to cast non-static DPI export functions to (void *) #1391
Comments
Original Redmine Comment I should also add that just hacking the code to add 'static' to all dpi declarations doesn't work, as they really aren't static.. they use this->__PVT__signal to get a signal value, while the static ones use vlSymsp->path.__PVT__signal to get to it, where vlSymsp is a parameter passed to them. |
Original Redmine Comment It seems like the internal isStatic is getting not set or lost on the bad functions for some reason. I don't see anything obvious in the code. Please run with --debug and look for "CFUNC.*STATIC" in the .tree files. Either they won't get created on the bad ones or will get lost; the file in which this happens will indicate where to look. You'll need the git version, or apply this patch:
|
Original Redmine Comment It looks like step 061, "descope", is the one that lost the [STATIC]. design_060_trace.tree shows "[STATIC] [DPIX]" for the bad function, and design_061_descope.tree shows "[DPIX]" only. |
Original Redmine Comment Apologies for jumping on to this thread, but would this be the same as this issue? I now see this when I have a submodule (that has exported DPI functions) that is instantiated multiple times in the next level up of hierarchy. Think instantiated ways of a cache and each way is an instantiated array and each array has its own DPI. Apologies for hi-jacking if its something different...
|
Original Redmine Comment Yeah, that's exactly the problem. I thought it was as simple as "if you have multiple instances of a block that has DPI exports", but when I tried to reproduce it with a simple testcase, verilator correctly generated separate static DPI calls for each of the instances. It seems to be some kind of a corner-case optimization in the 'descope' step. I've tried to randomly thrown in some "if !isDpi()" into the V3Descope.cpp to avoid setting m_needThis to true (which turns off the static qualifier), but that caused all kinds of havoc :). I think I'll have to leave it to Wilson to figure it out. |
Original Redmine Comment Thanks for the additional sighting, now I know the module and think that inlining is involved, with these hints I'll try to make a test case & fix. |
Original Redmine Comment No problem, and thanks for looking at this. Apologies, I don't know the internals anywhere near enough to go digging. In this case I was able to work around by commenting out the DPI export in the leaf module, and moving it up a level and using a case statement switched with the way - so essentially explicitly selecting the array elements per way that I want to access versus setting the scope to the individual array and using the leaf module DPI. This is somewhat painful as the number of ways is parameterizable and the DPI is now essentially hardcoded to a single configuration, and in some cases there are multiple levels of heirarchy that can be involved. l2_directory_dpi.svh:
snippet from l2_directory.sv:
|
Original Redmine Comment Fixed in git towards 4.010. Please give it a try. |
Original Redmine Comment This seems to fix what I was seeing. I will undo some additional workarounds later today and check as well. Thanks much. |
Original Redmine Comment I can confirm that it works for me, too. Thank you! |
Original Redmine Comment In 4.010. |
Author Name: Stan Sokorac
Original Redmine Issue: 1391 from https://www.veripool.org
Original Assignee: Wilson Snyder (@wsnyder)
I've been using about a year old version of Verilator, and when I try to switch to the latest stable, I'm running into this problem...
The design__Syms.cpp file contains a number of "exportInsert" calls for each of the DPI functions that I have scattered all over the design:
There's a few hundred of these, and each of these lines is trying to cast the address of a function to (void *) pointer. I run into compile problems here because some of these functions it is trying to cast are static, and those are fine to get an address of like this, and some are not static and can't be cast to (void *) without an instance of the object. I can't figure out why Verilator would generate some of these as static and some not... Every one of my DPI functions is the same, auto-generated code that looks like:
I can't see any pattern in which ones are chosen to be static and which are not....
In the ~1 year old version that I was previously using, I've checked that all DPI functions were generated as static member functions, and hence I had no compile problems.
The text was updated successfully, but these errors were encountered: