|
| 1 | +- Start Date: (fill in with date at which the RFC is merged, YYYY-MM-DD) |
| 2 | +- RFC PR: [amaranth-lang/rfcs#77](https://github.com/amaranth-lang/rfcs/pull/77) |
| 3 | +- Amaranth Issue: [amaranth-lang/amaranth#0000](https://github.com/amaranth-lang/amaranth/issues/0000) |
| 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.output, downstream.input) |
| 21 | +``` |
| 22 | + |
| 23 | +## Guide- and reference-level explanation |
| 24 | +[guide-level-explanation]: #guide-level-explanation |
| 25 | + |
| 26 | +Document the following conventions: |
| 27 | + |
| 28 | +- When a component has a single primary input stream, the port should be named *TBD*. |
| 29 | +- When a component has a single primary output stream, the port should be named *TBD*. |
| 30 | + |
| 31 | +Update existing stream components to follow these conventions. |
| 32 | + |
| 33 | +## Drawbacks |
| 34 | +[drawbacks]: #drawbacks |
| 35 | + |
| 36 | +None. |
| 37 | + |
| 38 | +## Rationale and alternatives |
| 39 | +[rationale-and-alternatives]: #rationale-and-alternatives |
| 40 | + |
| 41 | +Without a common convention, components will be written with different naming schemes, requiring more care when interconnecting them. |
| 42 | + |
| 43 | +## Prior art |
| 44 | +[prior-art]: #prior-art |
| 45 | + |
| 46 | +Stream ports in LiteX components are conventionally named `sink` and `source`. |
| 47 | + |
| 48 | +## Unresolved questions |
| 49 | +[unresolved-questions]: #unresolved-questions |
| 50 | + |
| 51 | +- Which exact names should we settle on? |
| 52 | + - `i` / `o` |
| 53 | + - `input` / `output` |
| 54 | + - `w_stream` / `r_stream` |
| 55 | + - `sink` / `source` |
| 56 | + - Others? |
| 57 | + |
| 58 | +## Future possibilities |
| 59 | +[future-possibilities]: #future-possibilities |
| 60 | + |
| 61 | +A `connect_pipeline()` function can be added that takes an iterable of components and connects them in sequence like shown above. |
0 commit comments