connectDownTo method

void connectDownTo(
  1. InterfaceReference<PairInterface> other
)

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) {
  // 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: null);
  other._connectAllPortMaps(exceptPorts: null);

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