# self.properties["SIDE"] = properties.get("SIDE", 'center')# self.properties["OFFSET"] = properties.get("OFFSET", 0)@propertydefis_input(self):returnself.direction==self.Direction.IN@propertydefis_output(self):returnself.direction==self.Direction.OUT@propertydefis_inout(self):returnself.direction==self.Direction.INOUT@propertydefsize(self):''' Returns number of pins in the port Returns: int: Returns size of port '''returnsuper().sizedefsplit(self,get_name=None):get_name=get_nameor(lambdax:f"{self.name}_{x}")ifself._pins[0].wire:self._pins[0].wire.cable.split(get_name)forindx,pininenumerate(self._pins[::-1]):new_port=self.definition.create_port(get_name(indx),direction=self.direction)self._pins.remove(pin)pin._port=Nonenew_port.add_pin(pin)self.definition.remove_port(self)
[docs]defchange_name(self,name):''' Change name of the port and corrosponding cable args: name (str): Name of the ports '''ifself.definition:port_cable=next(self.definition.get_cables(self.name),None)else:port_cable=Noneforpininself.pins:ifpin.wire:pin.wire.cable.name=nameelifport_cable:port_cable.name=nameself.name=name