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>[];
while (port.isArrayMember) {
dimAccesses.add('[${port.arrayIndex!}]');
port = port.parentStructure!;
}
return PortReference.fromString(port.parentModule! as BridgeModule,
port.name + dimAccesses.reversed.join());
}