PortReference.fromPort constructor
- Logic port
Creates a PortReference from an existing Logic port.
The port must be a port of a BridgeModule. If the port is an array
member, this will create a PortReference that includes the appropriate
array indexing to access that specific element.
Implementation
factory PortReference.fromPort(Logic port) {
if (!port.isPort) {
throw RohdBridgeException('$port is not a port');
}
final dimAccesses = <String>[];
var currentPort = port;
while (currentPort.isArrayMember) {
dimAccesses.add('[${currentPort.arrayIndex!}]');
currentPort = currentPort.parentStructure!;
}
return PortReference.fromString(currentPort.parentModule! as BridgeModule,
currentPort.name + dimAccesses.reversed.join());
}