createPort method
- String portName,
- PortDirection direction, {
- int width = 1,
Creates a new port with the specified characteristics.
This is a convenience method that creates a port of the given direction
and width
, then returns a PortReference for immediate use in
connections and operations.
The portName
must be unique within the module, direction
specifies the
port direction (input, output, or inOut), and width
sets the bit width
of the port.
Returns a PortReference that can be used for connections and slicing.
Implementation
PortReference createPort(String portName, PortDirection direction,
{int width = 1}) {
switch (direction) {
case PortDirection.input:
addInput(portName, null, width: width);
case PortDirection.output:
addOutput(portName, width: width);
case PortDirection.inOut:
addInOut(portName, null, width: width);
}
return port(portName);
}