punchDownTo method
- BridgeModule subModule, {
- String? newPortName,
Creates a matching port in a submodule and connects them.
This "punches down" the port to subModule
, 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 subModule
is not actually a submodule of this
port's module
.
Implementation
PortReference punchDownTo(BridgeModule subModule, {String? newPortName}) {
if (module.getHierarchyDownTo(subModule) == null) {
throw RohdBridgeException(
'Cannot punch down to a module that is not a submodule.');
}
// make a new port in the same direction on new module
final newPortRef =
replicateTo(subModule, direction, newPortName: newPortName);
if (!module.subModules.contains(subModule)) {
if (direction == PortDirection.output) {
connectPorts(newPortRef, this);
} else {
connectPorts(this, newPortRef);
}
return newPortRef;
}
if (direction == PortDirection.output) {
gets(newPortRef);
} else {
newPortRef.gets(this);
}
return newPortRef;
}