port method
- String portRefString
Creates a port reference from a string representation with advanced parsing.
This method handles both simple ports and complex port references including:
- Simple port names: "clk", "reset_n"
- Bit ranges and indices: "data
7:0
", "addr5
" - Struct member access: "mystruct.field" (using structMap lookup)
- Renamed ports: automatically resolves to original port names
For struct ports (containing '.'), the method looks up the actual bit slice in structMap. For renamed ports, it automatically resolves to the original port name while preserving any range specification.
Returns a PortReference that can be used for connections and operations.
Throws an Exception if a struct port is not found in structMap.
Implementation
PortReference port(String portRefString) {
if (portRefString.contains('.')) {
// this is a struct port, special handling
if (!structMap.containsKey(portRefString)) {
throw RohdBridgeException(
'Struct port $portRefString not found in $name');
}
// ignore: parameter_assignments
return structMap[portRefString]!;
} else {
final portRefComponents =
SlicePortReference.extractPortAccessSliceComponents(portRefString);
if (renamedPorts.containsKey(portRefComponents.portName)) {
return PortReference.fromString(
this,
portRefString.replaceFirst(
portRefComponents.portName,
renamedPorts[portRefComponents.portName]!,
));
} else {
return PortReference.fromString(this, portRefString);
}
}
}