-
Notifications
You must be signed in to change notification settings - Fork 16
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
IOInterface typing wrapper for lib.data signatures #726
base: master
Are you sure you want to change the base?
Conversation
The boilerplate reduction is nice, but this is a little bit hacky. Maybe, instead of a custom |
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.
For me it looks good.
"master_wb": Out(WishboneSignature(wb_params)), | ||
"slaves": In(WishboneSignature(wb_params)).array(num_slaves), | ||
"master_wb": Out(WishboneInterface(wb_params).signature), | ||
"slaves": Out(WishboneInterface(wb_params).signature).array(num_slaves), |
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.
Why In
was changed to Out
?
] | ||
|
||
|
||
class IOSignal(Value): |
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.
As discussed on the meeting it would be great to have the name changed.
] | ||
|
||
|
||
class IOSignal(Value): |
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.
Doc string will be welcome
Using
amaranth.lib.data
Signatures with typing comes with some boilerplate and repetition :(I came up with a class that can be used both for typing and to get amaranth
Signature
for use inComponent
constructor.It works by crating a class with
IOSignal
fields declared asself.
in constructor, so it can be directly for typechecking.IOSignal
type derivesValue
with additonal shape and direction information.IOInterface
is never used globally, but is intended only for interface typing. Those signals will be filled with actual objects atsuper().__init__(...
Component
constructor (that gets Signature from generatedIOInterface.signature
). NestedIOInterfaces
are supported.It is a bit hacky, but what do you think?