Port[] ports = new Port[portLocs.size()];
Instance[] pins = new Instance[portLocs.size()];
int i = -1;
for (Map.Entry<Location, Instance> portLoc : portLocs.entrySet()) {
i++;
Location loc = portLoc.getKey();
Instance pin = portLoc.getValue();
String type = Pin.FACTORY.isInputPin(pin) ? Port.INPUT : Port.OUTPUT;
BitWidth width = pin.getAttributeValue(StdAttr.WIDTH);
ports[i] = new Port(loc.getX(), loc.getY(), type, width);
pins[i] = pin;
String label = pin.getAttributeValue(StdAttr.LABEL);
if (label != null && label.length() > 0) {
ports[i].setToolTip(StringUtil.constantGetter(label));