pullUpPort method
- PortReference subModulePort, {
- String? newPortName,
- bool allowPortUniquification = true,
Creates a hierarchical port connection by pulling a port up from a submodule.
This method creates a new port on this module with the same direction and
characteristics as subModulePort
, then establishes the necessary
connections through the module hierarchy to connect them.
The newPortName
provides a preferred name for the new port,
auto-generated if not provided. The allowPortUniquification
controls
whether to allow automatic name resolution.
The method automatically determines the correct connection direction based on port types, creates intermediate ports through the hierarchy as needed, handles name uniquification to prevent conflicts, and establishes the physical connections between all levels.
Returns a reference to the newly created port on this module.
Implementation
PortReference pullUpPort(PortReference subModulePort,
{String? newPortName, bool allowPortUniquification = true}) {
final uniqName = _getUniquePortName(
subModulePort,
initialName: newPortName,
allowNameUniquification: allowPortUniquification,
);
final thisPort = subModulePort.replicateTo(this, subModulePort.direction,
newPortName: uniqName);
PortReference driver;
PortReference receiver;
if (subModulePort.direction == PortDirection.output) {
driver = subModulePort;
receiver = thisPort;
} else {
driver = thisPort;
receiver = subModulePort;
}
connectPorts(
driver,
receiver,
driverPathNewPortName: uniqName,
receiverPathNewPortName: uniqName,
allowDriverPathUniquification: allowPortUniquification,
allowReceiverPathUniquification: allowPortUniquification,
);
return thisPort;
}