-
Notifications
You must be signed in to change notification settings - Fork 484
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
Simplify VpiArrayObjHdl::initialise #3624
base: master
Are you sure you want to change the base?
Conversation
e8d01a5
to
4177293
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3624 +/- ##
=======================================
Coverage 72.67% 72.67%
=======================================
Files 49 49
Lines 8050 8044 -6
Branches 2212 2201 -11
=======================================
- Hits 5850 5846 -4
+ Misses 1689 1678 -11
- Partials 511 520 +9 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this fix your issue simply because only Questa/ModelSim, which you aren't using, need pseudo-regions, which you've segregated into ifdef's? So the problem of supporting get_handle_by_name
from the root on Questa, if there are multiple indexes, is still present, correct? But this commit removes this logic, which isn't necessary for the other simulators?
What tests exist in the regression which test this?
@marlonjames Do you have any concerns here?
Yeah we have use cases where we query objects from the root handle, but the logic for searching through the brackets causes issues. Are we okay with adding tests specifically for the simulator module? I think a good test case would be iterating through handles in a large design and asserting that subhdl == roothdl.get_handle_by_name(subhdl._path), and can be skipped on questa for now. |
Oh absolutely! I encourage it.
That's fine. We can maybe open an upstream ticket or at least track it in an issue if you could open that with the particulars that I'm not yet groking. |
I added it to the iteration test case, but ideally it would test on all of the designs, with multiple arrays in the path. Also, while looking at the iteration tests, I think I found that these test tags were removed on accident? db1cce7#diff-1082c9445dd85ec000286580d8e757077f81782e15cd253a1279b956a3cad2cb |
I will try to take a look at this soon. |
5df1c83
to
183f539
Compare
Unfortunately I don't think there's anything we can do until the private CI job hang is resolved. So sorry if we don't look at this sooner. |
That's resolved now, sorry for the disruption. |
cea9cb5
to
e1ce4ed
Compare
d5c234e
to
3602f6a
Compare
@marlonjames Could you have a look? |
@@ -52,25 +53,35 @@ async def recursive_discovery(dut): | |||
else: | |||
pass_total = 265 | |||
|
|||
# Icarus doesn't support array indexes like get_handle_by_name("some_path[x]") | |||
SKIP_HANDLE_ASSERT = cocotb.SIM_NAME.lower().startswith(("riviera", "icarus")) or cocotb.LANGUAGE in ["vhdl"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SKIP_HANDLE_ASSERT = cocotb.SIM_NAME.lower().startswith(("riviera", "icarus")) or cocotb.LANGUAGE in ["vhdl"] | |
SKIP_HANDLE_ASSERT = SIM_NAME.startswith(("riviera", "icarus")) |
Makefile skips this test for VHDL, and SIM_NAME is already defined above.
m_indexable = true; | ||
|
||
int range_idx = 0; | ||
|
||
/* Need to determine if this is a pseudo-handle to be able to select the | ||
* correct range */ | ||
#ifdef MODELSIM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::string hdl_name = vpi_get_str(vpiName, hdl);
should be pulled out of the #ifdef
, and the non-Modelsim case should enforce that hdl_name == name
so that we get an error if there is another VPI simulator that needs pseudo-regions for multi-dimensional arrays.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm don't think name != hdl_name always implies this? In Verilator when there's a generate scope, hdl_name = 'my_mod.scope' and name = 'scope', but maybe that's another issue for fix on the Verilator side...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vpiName
should be the local name of the object, vpiFullName
should be the full hierarchical name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because pseudo-regions use the handle of the parent (there is no proper VPI object with a handle), the names should mismatch.
That is how it works now. Pseudo-regions should be re-worked to preserve more context, right now the checking for and handling of pseudo-regions is scattered across the GPI codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be a follow on then? One thing at a time with a PR. Maybe open an issue for future investigation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think verilator needs a test case for just iterating through the tree and printing the handle info. Maybe we can add that to cocotb to measure simulator vpi compatibility, since the infrastructure for running different sims is already there? Or maybe that would belong on https://chipsalliance.github.io/sv-tests-results/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original issue for me was that in create_gpi_obj_from_handle, name is assumed to be the vpiName of the object, but it's not the case if calling the get_handle_by_name from a handle that isn't the direct parent handle. Would it be possible to add some flag there to not create pseudo handles, or not create them if we're querying down further than just the children?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey following up on this, if the pseudo handle check here is only needed for modelsim, wouldn't we rather have it only create handles for that sim?
Also, I made the vpi dump verilator test case, and it looks like the scopes are generated, so we may just need to add pseudo-handle code specific to verilator https://github.com/verilator/verilator/pull/4838/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I think I have a better understanding now.
So your problem came from passing a hierarchy to SimHandleBase._handle.get_handle_by_name()
rather than just the name of a direct child object.
There is no analysis of the name
passed into native_check_create()
, it is just concatenated with the name of the parent
handle and looked up via vpi_handle_by_name()
. The possibly-a-hierarchy name is then passed through to create_gpi_obj_from_handle()
, which also has the assumption that it is the name of the object. Finally, that is passed to initialise()
as if it is the name.
I think we need to either fix the code making the assumptions, or provide a separate function to call when looking up a handle that is not a direct child (e.g. we recommend using _id()
with a hierarchical path for some cases where simulators have problems with generates, etc, but that could hit this problem as well).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I did some more testing and this ifdef should actually be included. The one below does seem to be verify specific to modelsim though
3e7303f
to
a52b88b
Compare
I'll take another look at this soon. Please don't merge until then. |
Re-running CI. |
# Icarus doesn't support array indexes like get_handle_by_name("some_path[x]") | ||
SKIP_HANDLE_ASSERT = cocotb.SIM_NAME.lower().startswith( | ||
("riviera", "icarus") | ||
) or cocotb.LANGUAGE in ["vhdl"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cocotb.LANGUAGE
was removed.
a52b88b
to
6c53e80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. @marlonjames?
} | ||
|
||
#endif | ||
vpi_free_object(iter); // Need to free iterator since exited early |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If rangeHdl
is null, the iterator handle is no longer valid so must not be freed here.
|
||
while ((rangeHdl = vpi_scan(iter)) != NULL) { | ||
if (idx == range_idx) { | ||
#ifdef MODELSIM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code isn't Modelsim specific.
The problem in recursive_discovery
test has to do with dut._handle.get_handle_by_name(subpath)
as detailed in #3710.
I had issues with range_idx being calculated incorrectly, so I wanted to see what simulators actually require this, if at all. It gets calculated incorrectly when using get_handle_by_name() with a fully qualified name (not from handle.py) with brackets in other parts of the path. I didn't see range_idx being actually used in testing on Xcelium. It doesn't look like there were any tests when it was put in 54d2965