|
| 1 | +- Start Date: 2025-06-09 |
| 2 | +- RFC PR: [amaranth-lang/rfcs#77](https://github.com/amaranth-lang/rfcs/pull/77) |
| 3 | +- Amaranth Issue: [amaranth-lang/amaranth#1615](https://github.com/amaranth-lang/amaranth/issues/1615) |
| 4 | + |
| 5 | +# Stream port name conventions |
| 6 | + |
| 7 | +## Summary |
| 8 | +[summary]: #summary |
| 9 | + |
| 10 | +Settle on and document name conventions for stream components. |
| 11 | + |
| 12 | +## Motivation |
| 13 | +[motivation]: #motivation |
| 14 | + |
| 15 | +Having a name convention for stream ports makes stream components easier to work with and allows automating the connection of pipelines like this: |
| 16 | + |
| 17 | +``` |
| 18 | +pipeline = [component_a, component_b, component_c] |
| 19 | +for upstream, downstream in itertools.pairwise(pipeline): |
| 20 | + wiring.connect(m, upstream.o, downstream.i) |
| 21 | +``` |
| 22 | + |
| 23 | +## Guide- and reference-level explanation |
| 24 | +[guide-level-explanation]: #guide-level-explanation |
| 25 | + |
| 26 | +Document the following conventions: |
| 27 | + |
| 28 | +- Whenever the name of a stream member of the component interface includes an indication of its direction, the indication must match one of the following forms: |
| 29 | + - For `In` members, either the complete name is `i` (for components that have one primary input), or the name must start with `i_` (for more complex components). |
| 30 | + - For `Out` members, either the complete name is `o` (for components that have one primary input), or the name must start with `o_` (for more complex components). |
| 31 | + |
| 32 | +- It is also acceptable to have a name that doesn't indicate directionality explicitly, e.g. `requests` or `packets`. |
| 33 | + |
| 34 | +Update existing stream components to follow these conventions. |
| 35 | + |
| 36 | +## Drawbacks |
| 37 | +[drawbacks]: #drawbacks |
| 38 | + |
| 39 | +None. |
| 40 | + |
| 41 | +## Rationale and alternatives |
| 42 | +[rationale-and-alternatives]: #rationale-and-alternatives |
| 43 | + |
| 44 | +Without a common convention, components will be written with different naming schemes, requiring more care when interconnecting them. |
| 45 | + |
| 46 | +## Prior art |
| 47 | +[prior-art]: #prior-art |
| 48 | + |
| 49 | +Stream ports in LiteX components are conventionally named `sink` and `source`. |
| 50 | + |
| 51 | +## Unresolved questions |
| 52 | +[unresolved-questions]: #unresolved-questions |
| 53 | + |
| 54 | +None. |
| 55 | + |
| 56 | +## Future possibilities |
| 57 | +[future-possibilities]: #future-possibilities |
| 58 | + |
| 59 | +A `connect_pipeline()` function can be added that takes an iterable of components and connects them in sequence like shown above. |
0 commit comments