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
[Vpi] Allow using packed struct as a signal on sim module #3608
Conversation
ef44026
to
33a4619
Compare
33a4619
to
d74226c
Compare
I realized when running this that doing
in sequence causes the verilator one to not run and exit early, any idea why this might be the case? I have to make clean before I can run verilator |
d74226c
to
9921626
Compare
Can I get a look at this @marlonjames @ktbarrett. I'm not sure why it's tripping up on vhdl runs |
9921626
to
46cf051
Compare
I'll try to do this tonight. Otherwise it might be a while. |
It looks like vhdl sims actually seg fault when trying to call get_signal_val_binstr, which is why they failed even though expect_fail was set to true. And the verilog ones rn are because of the logicarray change, I'll fix those rq |
46cf051
to
0e471dd
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3608 +/- ##
==========================================
+ Coverage 72.26% 72.63% +0.36%
==========================================
Files 49 49
Lines 8038 8044 +6
Branches 2216 2210 -6
==========================================
+ Hits 5809 5843 +34
+ Misses 1724 1690 -34
- Partials 505 511 +6 ☔ View full report in Codecov by Sentry. |
0e471dd
to
3357fa1
Compare
Just changing structs to arrays is not the right answer here. I'm actually really surprised that the regression passes with this change. Clearly not enough testing is being done. What's needed is a new type that supports both accessing fields and setting the whole value. I don't know what happens when you attempt to set the full value on something that isn't a packed struct, or if most simulators even support differentiating packed vs unpacked structs. Without more testing or more work on supporting both (so we don't have a breaking change), I'm not comfortable with this change. |
It's essentially just adding the signal methods to the gpi handle, whereas before it didn't have these. Changing handle.py to allow both hierarchy and signal will be the tricky part |
This type of feature would at minimum require getting |
Actually now that I've been thinking about this. I think this might be a good idea. Indexing into packed objects, whether that's packed arrays, or packed structs, etc. is not kosher, at least conceptually. I'm now more surprised that what we currently have works. We do need a new type for packed objects that aren't single-dimension packed arrays. Using |
"What's needed is a new type that supports both accessing fields and setting the whole value." - so only VpiSignal provide special extra methods, VpiObjHdl does not. Everything for accessing fields is just operating on the raw vpi handle, so our check for that is simply 'does the vpi throw an error' and relying on handle.py to call it on valid objects. So I can make a VpiStructObjHdl that just extends VpiSignalObjHdl, but it'll add nothing. And I'll add the vpiPacked check as well. It would be nice to also have it extend VpiObjHdl to get defname and deffile, but then we'd have multiple inheritance |
2e84535
to
bc2a34f
Compare
abe99d6
to
60b9dcd
Compare
I'm still trying to figure out a holistic approach to this. In my mind:
I know this is going to require both C++ and Python changes, but I'm uncertain to what extent. Also I'm uncertain if point 4 is even possible.
Yeah... maybe we should forget about accessing fields on the object and only worry about accessing fields on the value coming out. |
Do many simulators support the type spec? For xcelium (and seemingly other sims) it just treats them as unpacked. I think just having this for now supports the old way via an explicit type change. I was originally going to support both .value and child handle access, but with the latest rebase there were some method conflicts between LogicObject and HierarchyObject, so I thought it best to default to the proper way for Packed Structs. (len) especially would be confusing And again, what cpp changes need to be made if we're not inspecting the type spec? The object hierarchy was implemented as methods on GpiObjHdl and VpiImpl, not VpiObjHdl, so it works just fine. |
7a83363
to
4dc359a
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.
So uhhh... yeah I definitely want to go back to the original implementation on this. Let's just remove support for now and try to realize #3857 sooner rather than later.
4dc359a
to
f4cf6d6
Compare
Riviera is failing with Questa is failing with
|
e594d70
to
7aae3d8
Compare
4be32a8
to
0aa6fcd
Compare
@cocotb/maintainers Considering I plan on reintroducing the indexing in a future commit, is this good? |
The purpose of this is to be able to set/get a struct's entire value, rather than just its individual signals, which in turn will allow for more shared user code between verilator and the other environments.
I default packed structs to the new behavior since this is more correct, and allow casting from to the old hierarchy object via asHierarchyObject().
Closes #3623.