punchUpTo method
- BridgeModule parentModule, {
- String? newPortName,
Creates a matching port in the parent module and connects them.
This "punches up" the port to parentModule
, creating a port with the
same direction and optionally renaming it to newPortName
. The new port
is automatically connected to this port.
Throws an exception if parentModule
is not actually a parent of this
port's module
.
Implementation
PortReference punchUpTo(BridgeModule parentModule, {String? newPortName}) {
if (parentModule.getHierarchyDownTo(module) == null) {
throw RohdBridgeException(
'Cannot punch up to a module that is not a parent.');
}
if (!parentModule.subModules.contains(module)) {
return parentModule.pullUpPort(this, newPortName: newPortName);
}
// make a new port in the same direction on new module
final newPortRef =
replicateTo(parentModule, direction, newPortName: newPortName);
if (direction == PortDirection.output) {
newPortRef.gets(this);
} else {
gets(newPortRef);
}
return newPortRef;
}