SlicePortReference.fromString constructor
- BridgeModule module,
- String portAccessString
Creates a slice port reference from a port access string.
Parses the portAccessString
to create the appropriate slice reference.
The string must contain either array indexing (e.g., [3]
) or slicing
(e.g., [7:0]
) or both.
Throws an exception if the string doesn't contain any slicing or dimension access, as that would be a simple StandardPortReference.
Implementation
factory SlicePortReference.fromString(
BridgeModule module, String portAccessString) {
final components = extractPortAccessSliceComponents(portAccessString);
final portName = components.portName;
final sliceLowerIndex = components.sliceLowerIndex;
final sliceUpperIndex = components.sliceUpperIndex;
final dimensionAccess = components.dimensionAccess;
if (sliceUpperIndex == null &&
sliceLowerIndex == null &&
dimensionAccess == null) {
throw RohdBridgeException(
'SlicePortReference must have either slicing or dimension access.');
}
return SlicePortReference(module, portName,
dimensionAccess: dimensionAccess,
sliceUpperIndex: sliceUpperIndex,
sliceLowerIndex: sliceLowerIndex);
}