Skip to content

Commit a761834

Browse files
committed
Amend RFC #2 to add Signature.flatten.
1 parent 6e3c582 commit a761834

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

text/0002-interfaces.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ Interfaces are described using an enumeration, `amaranth.lib.wiring.Flow`, and t
394394
}).freeze()
395395
```
396396
* `signature.flip()` returns a signature where every member is `member.flip()`ped. The exact object returned is a proxy object that overrides the methods and attributes defined here such that the flow is flipped, and otherwise forwards attribute accesses untouched. That is, `signature.x = <value>` and `signature.flip().x = <value>` both define an attribute on the original `signature` object, and never on the proxy object alone. When calling method `signature.f` as `signature.flip().f`, `self` is the flipped signature.
397+
* `signature.flatten(object)` returns an iterator yielding a `path, member, value` tuples for each of the ports recursively contained in the signature, where:
398+
- `path` is a tuple of strings or integers indicating the sequence of attribute or index accesses that were used to retrieve `value` from `object`
399+
- `member` is the port member corresponding to `value`, with the flow flipped as appropriate
400+
- `value` is a value-castable object corresponding to the port (usually but not always a `Signal`)
397401
* `signature.is_compliant(object)` checks whether an arbitrary Python object is compliant with this signature. To be compliant with a signature:
398402
- for every member of the signature, the object must have a corresponding attribute
399403
- if the member is a port, the attribute value must be a value-castable such that `Value.cast(object.attr)` method returns a `Signal` or a `Const` that has the same width and signedness, and for signals, is not reset-less and has the same reset value as the member

0 commit comments

Comments
 (0)