amaranth
amaranth copied to clipboard
Specifying logical signal direction for ports of an elaboratable
Issue by ZirconiumX
Monday Sep 30, 2019 at 12:53 GMT
Originally opened as https://github.com/m-labs/nmigen/issues/243
This came up on IRC a while back, and I thought I'd write it down for the sake of posterity.
Signals should have an optional must_read and must_write parameter for linting purposes. This would be used to mark Signals intended for external use by other Elaboratables, and warn (error?) when they are not used correctly; for example, a FIFO's input would be marked must_write and its output would be marked must_read, because if the input was not written to, or the output not read from, the FIFO would be useless.
I would suggest semantics for these as must_read and must_write producing a warning if they are never used as the source, or destination of a connection between Signals (I don't know the nMigen term for this).
Perhaps one could go further and warn if an Elaboratable does not declare any of its Signals must_read or must_write, as their linting purpose is unhelpful if all signals are optional. This would likely be quite noisy on an established nMigen codebase however.
Comment by whitequark
Monday Sep 30, 2019 at 12:56 GMT
I think attaching these attributes to Signals is probably not the right approach. I think it makes more sense to attach them to Elaboratables, perhaps as Python 3.7 type annotations, such that documentation can take those into account where currently Signal, in is written explicitly. This feature should also interact with #213.
This was done as a part of RFC 2.