Skip to content

A type-safe mechanism to connect PairInterfaces #613

@mkorbel1

Description

@mkorbel1

Motivation

Currently, when you connect two modules with a PairInterface, they both receive an instance of the same PairInterface and call pairConnectIO with the appropriate PairRole. If both sides would like to play the same role, then you will not find out until runtime when signals on the interface find multiple drivers. It would be nice if we could statically resolve the role before runtime.

Desired solution

Create a mechanism to "split" a PairInterface into two typed portions, so that arguments to the modules' constructors can specify the direction using the type.

For example something kind of like:

(PairProvider<IntfType>, PairConsumer<IntfType>) split<IntfType extends PairInterface>(IntfType interface) { ... }

Where PairProvider and PairConsumer have references to (wrap) the original interface, but can then be used with some API in Module like connectPairProvider or connectPairConsumer that only accept the proper type and thus call pairConnectIO with the correct PairRole.

Alternatives considered

No response

Additional details

Thank you to @ethanuppal for the suggestion!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions