gets method
- PortReference other
Connects this port to be driven by other
.
This establishes a connection where the signal from other
drives this
port. The connection respects the hierarchical nature of the modules and
handles directionality of ports appropriately.
Implementation
void gets(PortReference other) {
final relativeLocation = _relativeLocationOf(other);
if (relativeLocation == _RelativePortLocation.sameModule &&
(other is InterfacePortReference || this is InterfacePortReference)) {
throw RohdBridgeException(
'Connections involving interface ports on the same module'
' ${module.name} should be done using port maps.');
}
if (relativeLocation == _RelativePortLocation.sameLevel &&
direction == other.direction &&
(direction != PortDirection.inOut)) {
throw RohdBridgeException(
'Cannot connect two ports with the same direction'
' on sibling modules.');
}
if (relativeLocation == _RelativePortLocation.thisAboveOther &&
direction == PortDirection.input &&
other.direction == PortDirection.input) {
throw RohdBridgeException(
'A submodule (${other.module}) input ($other) cannot drive a parent '
'module ($module) input ($this).');
}
if (relativeLocation == _RelativePortLocation.otherAboveThis &&
direction == PortDirection.output &&
other.direction == PortDirection.output) {
throw RohdBridgeException(
'A parent module (${other.module}) output ($other) cannot drive a '
'submodule ($module) output ($this).');
}
if (direction == PortDirection.output &&
other.direction == PortDirection.input &&
relativeLocation != _RelativePortLocation.sameModule) {
throw RohdBridgeException(
'Cannot use an input $other from ${other.module}'
' to drive $this, an output of $module.');
}
if (relativeLocation == _RelativePortLocation.sameModule &&
direction == PortDirection.input) {
throw RohdBridgeException(
'An port $other on module ${other.module} cannot drive an'
' input $this on the same module');
}
if (relativeLocation == _RelativePortLocation.otherAboveThis &&
direction == PortDirection.input &&
other.direction == PortDirection.output) {
throw RohdBridgeException(
'A parent module (${other.module}) output ($other) cannot drive a '
'submodule ($module) input ($this).');
}
if (relativeLocation == _RelativePortLocation.thisAboveOther &&
direction == PortDirection.input &&
other.direction == PortDirection.output) {
throw RohdBridgeException(
'A submodule (${other.module}) output ($other) cannot drive a '
'parent module ($module) input ($this).');
}
getsInternal(other);
}