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
More handle cleanup #3733
More handle cleanup #3733
Conversation
1f54f33
to
a9a948a
Compare
So currently the issue is with Issues with scalarsWhen a Currently there is an Issues with multi-dimensional packed arraysWhen a multi-dimensional packed logic array is seen in Verilog, we can't assume we can index it, as simulators can assume that it's an indivisible object. This means that it also isn't iterable. But Another issue is that the length of the object is the number of total bits in the object, so a SolutionsIMO, we should separate scalars, single-dimension packed arrays (and Scalars would not have a range and getting/setting the value would use Single-dimension packed arrays would have a range and getting the value would return a Multi-dimensional packed arrays would ideally return some composite range object. Getting the value would return an Failing the above answer, multi-dimensional packed arrays could return a range of 0 to length-1, which I feel would be valid because flattened values don't necessarily have a valid range, so it can be whatever. Getting and setting the value would work like single-dimension packed arrays at that point. The single-dimension and simple multi-dimension solution could be combined if we can ensure that at the GPI level, the range of packed objects is listed as 0 to length-1 rather than the range of the first dimension. |
a9a948a
to
46c05d6
Compare
I decided to split this PR up. The previous comment no longer applies to this PR. |
b90736d
to
2919e74
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3733 +/- ##
==========================================
- Coverage 68.88% 68.64% -0.25%
==========================================
Files 49 49
Lines 7640 7648 +8
Branches 2204 2215 +11
==========================================
- Hits 5263 5250 -13
- Misses 1301 1326 +25
+ Partials 1076 1072 -4 ☔ 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.
A first look, will go over it again later.
2919e74
to
b25d28e
Compare
@cmarqu Take your time. This module needs lots of attention wrt documentation. |
b25d28e
to
654c55b
Compare
654c55b
to
47e24dc
Compare
The inheritance diagram at https://cocotb--3733.org.readthedocs.build/en/3733/library_reference.html#simulation-object-handles is now outdated. It could be regenerated by locally reverting the change in https://github.com/cocotb/cocotb/pull/3457/files and overwriting the SVG with the image gotten from a browser. |
@cmarqu It's outputting SVG, but not displaying the image, just the code. Any ideas? |
Works for me (and doesn't have the size problem described in #3457 (comment)). Do you have a file like Anyway, the output looks a bit "wilder" than before, maybe we should draw it by hand anyway... |
Yeah, it definitely needs to be done by hand. There is ABC and Generic and a few other base classes we really don't need to show. Ideally though, we wouldn't document the inheritance hierarchy and instead document only each concrete class. I don't expect many users understand inheritance at any level. |
47e24dc
to
fdc233e
Compare
I'm going to leave the diagram unfinished for now, as there will be another follow on commit that changes the hierarchy (bye bye IndexableValueObjectBase). |
I'm fine with just removing the diagram. |
I think as long as we are documenting inheritance, it's valuable. But if we don't, obviously it isn't. |
Considering I'm putting off the diagram update until the next PR, can I get a final review @cocotb/maintainers? |
@@ -1104,11 +1285,10 @@ def SimHandle( | |||
"""Factory function to create the correct type of `SimHandle` object. |
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.
Not sure why but the docs show the parameters and return type twice https://cocotb--3733.org.readthedocs.build/en/3733/library_reference.html#cocotb.handle.SimHandle
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 because SimHandleBase
is both a return type annotation and a reference in the "Returns:" part of the docstring?
It's not duplicated in the old version, https://docs.cocotb.org/en/latest/library_reference.html#cocotb.handle.SimHandle
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 ran into this in other cases as well, like on the value
getters and setters. It's a bug in Sphinx that has something to do with the cache AFAICT. A rebuild fixed the errors that I saw locally, let's see if it does the same here.
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.
Looks like still an issue but I'm fine with merging and seeing if it is fixed on master.
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 there's something up with the cache. I fixed the missing "
character from your last comment, but it's still missing from the documentation. Maybe master will fix itself. I wonder if there's a way to clear or not use the cache that we can set in .readthedocs.yml
NonHierarchyObject -> ValueObjectBase NonHierarchyIndexableObjectBase -> IndexableValueBase ModifiableObject -> UnitValueObjectBase NonhierarchyIndexableObject -> ArrayObject
Added typing to the rest of cocotb.handle. No type checker liked referencing the parent object's property getter for .value, so `_get_value` was introduced so the property was only defined once. The type checker didn't really like how SetActions were set up, so that was refactored. `_set_value` now takes an action enum value rather than the action wrapped value. The wrapped values only existed to work with the value setting property syntax, so that translation is done there. The name `call_sim` was changed to `schedule_writes` which should be easier to understand. The args to the `schedule_writes` callback are now packed into a sequence rather than using varargs, since that is easier to type. `_call_now` and `_cocotb.scheduler._schedule_writes` have been updated accordingly.
This works the same as setting the value via the property, but the function definition allows correct typing to be used.
The only thing it provided was the drivers() and loads() methods, which apparently didn't work in any simulator as the only test of the functionality was set to expect failure in all cases.
fdc233e
to
1efbc9a
Compare
This should be the final PR. Closes #3548.
This PR:
ModifiableObject
and the non-functionaldrivers
andloads
methods (closes ChangeModifiableObject.drivers
andModifiableObject.loads
to be Python iterables #3678)set
method to set values in a type-safe way