connectDownTo method

void connectDownTo(
  1. InterfaceReference<PairInterface> other, {
  2. Set<String>? exceptPorts,
})

Establishes a hierarchical "downward" connection to a child interface.

Connects this interface to other, where other represents the same interface in a child module. This sets up the proper signal flow based on the interface role, with signals flowing from parent to child.

The other must be on a sub-module of this module.

Implementation

void connectDownTo(InterfaceReference other, {Set<String>? exceptPorts}) {
  // TODO(mkorbel1): remove restriction that it must be adjacent (https://github.com/intel/rohd-bridge/issues/13)
  if (other.module.parent != module) {
    throw RohdBridgeException(
        "The other interface must be on a child module of this interface's"
        ' module.');
  }

  if (internalInterface == null) {
    _introduceInternalInterface();
  }

  _connectAllPortMaps(exceptPorts: exceptPorts);
  other._connectAllPortMaps(exceptPorts: exceptPorts);

  switch (role) {
    case (PairRole.provider):
      internalInterface!
        .._driveOtherExcept(
            other.interface,
            const [
              PairDirection.fromConsumer,
              PairDirection.sharedInputs,
              PairDirection.commonInOuts,
            ],
            exceptPorts: exceptPorts)
        .._receiveOtherExcept(
            other.interface,
            const [
              PairDirection.fromProvider,
            ],
            exceptPorts: exceptPorts);
    case (PairRole.consumer):
      internalInterface!
        .._driveOtherExcept(
            other.interface,
            const [
              PairDirection.fromProvider,
              PairDirection.sharedInputs,
              PairDirection.commonInOuts,
            ],
            exceptPorts: exceptPorts)
        .._receiveOtherExcept(
            other.interface,
            const [
              PairDirection.fromConsumer,
            ],
            exceptPorts: exceptPorts);
  }
}