gets method
- PortReference other, {
- SameModuleConnectionType? sameModuleConnectionType,
- String? intermediateSignalName,
- bool allowIntermediateSignalNameUniquification = true,
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.
When connecting two ports on the same module where the connection type is
ambiguous (at least one port is PortDirection.inOut and neither is
PortDirection.input), a sameModuleConnectionType must be provided to
disambiguate.
If intermediateSignalName is provided, an intermediate signal with that
name is inserted on sibling-level and same-module connections. See
_insertIntermediateSignalIfNeeded for details on when the name is
applied and when it is silently ignored.
Set allowIntermediateSignalNameUniquification to false to reserve the
exact name. Incompatible reserved-name collisions fail during synthesis.
This has no effect when no intermediate name is applied. An incompatible
cached intermediate is left intact; new fan-out receivers and net fan-in
can use a separate strict alias. Replacing an already-connected non-net
receiver's intermediate or using an unsupported custom clone throws
RohdBridgeException. See connectPorts for aggregate restrictions.
Implementation
void gets(PortReference other,
{SameModuleConnectionType? sameModuleConnectionType,
String? intermediateSignalName,
bool allowIntermediateSignalNameUniquification = true}) {
final relativeLocation = _relativeLocationOf(other);
if (relativeLocation == _RelativePortLocation.sameModule) {
_validateSameModuleInterfacePortMap();
other._validateSameModuleInterfacePortMap();
if (_isMappedTo(other) || other._isMappedTo(this)) {
_connectSameModuleInterfacePortMaps();
other._connectSameModuleInterfacePortMaps();
return;
}
if (sameModuleConnectionType == null &&
(_requiresExplicitSameModuleConnectionType ||
other._requiresExplicitSameModuleConnectionType)) {
throw RohdBridgeException(
'Same-module connections involving interface ports require an '
'explicit SameModuleConnectionType.');
}
}
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 &&
other.direction == PortDirection.input) {
throw RohdBridgeException(
'An input 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).');
}
if (relativeLocation != _RelativePortLocation.sameModule &&
sameModuleConnectionType != null) {
throw RohdBridgeException(
'SameModuleConnectionType should only be provided when connecting'
' ports on the same module, but $this is on $module'
' and $other is on ${other.module}.');
}
// Same-module connection type validation
var resolvedConnectionType = sameModuleConnectionType;
if (relativeLocation == _RelativePortLocation.sameModule) {
resolvedConnectionType =
_validateSameModuleConnectionType(other, sameModuleConnectionType);
_connectSameModuleInterfacePortMaps();
other._connectSameModuleInterfacePortMaps();
}
_connectOverlappingInterfacePortMaps();
other._connectOverlappingInterfacePortMaps();
getsInternal(other,
sameModuleConnectionType: resolvedConnectionType,
intermediateSignalName: intermediateSignalName,
allowIntermediateSignalNameUniquification:
allowIntermediateSignalNameUniquification);
}