replicateTo method

  1. @override
PortReference replicateTo(
  1. BridgeModule newModule,
  2. PortDirection direction, {
  3. String? newPortName,
})
override

Creates a new port in the specified module with the given direction.

This creates a port in newModule with the specified direction and optionally renames it to newPortName. The new port will have the same width and array dimensions as this port reference.

If this is a sliced reference, only the subset dimensions are replicated.

Implementation

@override
PortReference replicateTo(BridgeModule newModule, PortDirection direction,
    {String? newPortName}) {
  newPortName ??= portName;
  if (port is LogicArray) {
    final portArr = port as LogicArray;
    newModule.createArrayPort(newPortName, direction,
        dimensions: portArr.dimensions, elementWidth: portArr.elementWidth);
  } else {
    newModule.createPort(newPortName, direction, width: port.width);
  }

  return PortReference.fromString(newModule, newPortName);
}