tryPort method
- String portRef
Tries to get a reference to a specific port within this interface.
The portRef can be either a simple port name (e.g., "data") or include
slicing/indexing syntax (e.g., "data7:0", "addr3").
Returns either a StandardInterfacePortReference for simple port names or
a SliceInterfacePortReference for sliced access, or null if the
referenced port access is valid but the interface port does not exist.
Throws an Exception if portRef is not a valid port access string.
Implementation
InterfacePortReference? tryPort(String portRef) {
final portRefComponents =
SlicePortReference.extractPortAccessSliceComponents(portRef);
if (interface.tryPort(portRefComponents.portName) == null) {
return null;
}
if (SlicePortReference._isSliceAccess(portRef)) {
return SliceInterfacePortReference.fromString(this, portRef);
}
if (StandardPortReference._isStandardAccess(portRef)) {
return StandardInterfacePortReference(this, portRef);
}
throw RohdBridgeException('Invalid port access string: $portRef');
}