-
Notifications
You must be signed in to change notification settings - Fork 177
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
make Record inherit from UserValue #357
Conversation
Codecov Report
@@ Coverage Diff @@
## master #357 +/- ##
==========================================
+ Coverage 82.36% 82.50% +0.14%
==========================================
Files 35 35
Lines 5846 5950 +104
Branches 1205 1210 +5
==========================================
+ Hits 4815 4909 +94
- Misses 868 873 +5
- Partials 163 168 +5
Continue to review full report at Codecov.
|
Another thing that came to my mind just now is, that we maybe want to somehow mark "things that are somehow a bundle". This would help to implement genlib.record.iter_flat() without the assumption that Record is the only bundle. Do you have any ideas of how to achive that? |
As described elsewhere, I don't think this is a good idea, and nMigen's built-in records will not support |
okay |
To add to this, I think it is important to examine the use cases of But I don't currently see a convincing case for having a core interoperability mechanism for flat iteration. |
I have some utility function to measure the size of a Module (/Elaboratable) by synthesizing it with Yosys and pulling some output from the stat command. To generate the rtlil for this, I use a similar function to extract all nMigen Value like things and add them to the io ports. But maybe this usecase is a bit too unimportant / hacky to be supported ;). |
Take a look at the Yosys |
ah nice thanks :) |
Oh, and although the Yosys |
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 good, should be OK to merge with the test added.
self.__lowered = Value.cast(self.lower()) | ||
lowered = self.lower() | ||
if isinstance(lowered, UserValue): | ||
lowered = lowered._lazy_lower() |
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.
Could you please write a test for lowering of a UserValue
that returns another UserValue
?
self.assertEqual(uv.shape(), unsigned(1)) | ||
self.assertIsInstance(uv.shape(), Shape) | ||
uv.lowered = 2 | ||
uv.lowered = lower_to(2) | ||
self.assertEqual(uv.shape(), unsigned(1)) | ||
self.assertEqual(uv.lower_count, 1) |
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 test is a bit hard to understand--could you duplicate the code rather than calling test_shape
below? It's not much and it makes it much more clear what's going on.
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.
k
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
Thanks for the PR! |
closes #354