-
Notifications
You must be signed in to change notification settings - Fork 32
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
Add annotations for memory maps, wishbone and CSR primitives. #58
base: main
Are you sure you want to change the base?
Conversation
Updated, mainly to track changes in amaranth-lang/amaranth#978:
|
""" | ||
if not isinstance(element, Element): | ||
raise TypeError(f"Element must be a csr.Element object, not {element!r}") | ||
if element.signature != self: |
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 check should probably be in Signature.annotations
.
""" | ||
if not isinstance(interface, Interface): | ||
raise TypeError(f"Interface must be a csr.Interface object, not {interface!r}") | ||
if interface.signature != self: |
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.
Same as above.
@@ -264,7 +269,8 @@ def add_resource(self, resource, *, name, size, addr=None, alignment=None): | |||
Arguments | |||
--------- | |||
resource : object | |||
Arbitrary object representing a resource. | |||
Arbitrary object representing a resource. It must have a 'signature' attribute that is |
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.
must be an interface object
?
}, | ||
"alignment": { | ||
"type": "integer", | ||
"minimum": 0, |
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.
You should add a comment here explaining what the value means. (It is a power of 2, right? Where the alignment in words is 1 << alignment
.)
"type": "integer", | ||
"minimum": 0, | ||
}, | ||
"ratio": { |
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 would benefit from a comment as well.
if not isinstance(interface, Interface): | ||
raise TypeError(f"Interface must be a wishbone.Interface object, not {interface!r}") | ||
if interface.signature != self: | ||
raise ValueError(f"Interface signature is not equal to this signature") |
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.
Same as above.
Depends on PR amaranth-lang/amaranth#978.
MemoryMap
resources (e.g.csr.Element
s) are now assumed to have a.signature
property, which lets them hold annotations. I am not sure whether we should enforce this inMemoryMap.add_resource()
, or introduce a base class instead.