renamePort method
Creates a logical alias for an existing port without affecting RTL generation.
This method establishes a name mapping that allows newName
to be used in
place of currentName
for connections and references. The original port
name remains unchanged in the generated SystemVerilog, but the new name
can be used throughout the ROHD Bridge API.
The currentName
must be an existing port name that exists in this
module, and newName
provides the new alias name to use for the port.
This is mostly useful for supporting migration from flows that expect renaming -- usually this is not a good practice.
Both names become reserved and cannot be reused for other renames. The port must exist before renaming can be performed.
Throws an Exception if either name has already been used in a rename operation or the current port name doesn't exist in this module.
Implementation
void renamePort(String currentName, String newName) {
if (_renamedPorts.containsKey(currentName) ||
_renamedPorts.containsValue(currentName) ||
_renamedPorts.containsKey(newName) ||
_renamedPorts.containsValue(newName)) {
throw RohdBridgeException(
'Port name $currentName has already been associated with a rename'
' and cannot be used again in $name');
} else {
if ((tryInput(currentName) == null) &&
(tryOutput(currentName) == null) &&
(tryInOut(currentName) == null)) {
throw RohdBridgeException('Port $currentName does not exist in $name.');
}
_renamedPorts[newName] = currentName;
}
}