private PortProtoId getPortIdByIndex(NodeProtoId nodeProtoId, int portIndex) { if (nodeProtoId instanceof CellId) { return snapshot.getCell((CellId) nodeProtoId).cellRevision.exports.get(portIndex).exportId; } else { return techPool.getPrimitiveNode((PrimitiveNodeId) nodeProtoId).getPort(portIndex).getId(); } }
private int getNumPorts(NodeProtoId nodeProtoId) { if (nodeProtoId instanceof CellId) { return snapshot.getCell((CellId) nodeProtoId).cellRevision.exports.size(); } else { return techPool.getPrimitiveNode((PrimitiveNodeId) nodeProtoId).getNumPorts(); } }
private int getPortIndex(PortProtoId portId) { if (portId instanceof ExportId) { ExportId exportId = (ExportId) portId; return snapshot .getCell(exportId.getParentId()) .cellRevision .getExportIndexByExportId(exportId); } else { return techPool.getPrimitivePort((PrimitivePortId) portId).getPortIndex(); } }
/** * Method to tell whether this NodeInst is an icon of its parent. Electric does not allow * recursive circuit hierarchies (instances of Cells inside of themselves). However, it does allow * one exception: a schematic may contain its own icon for documentation purposes. This method * determines whether this NodeInst is such an icon. * * @return true if this NodeInst is an icon of its parent. */ private boolean isIconOfParent(ImmutableNodeInst n) { if (!(n.protoId instanceof CellId)) { return false; } CellBackup subCell = snapshot.getCell((CellId) n.protoId); CellId subCellId = subCell.cellRevision.d.cellId; return subCellId.isIcon() && cellId.isSchematic() && subCellId.libId == cellId.libId && subCell.cellRevision.d.groupName.equals(cellRevision.d.groupName); }
private void localConnections(int netMap[]) { // Exports for (int k = 0; k < numExports; k++) { ImmutableExport e = exports.get(k); int portOffset = portOffsets[k]; Name expNm = e.name; int busWidth = expNm.busWidth(); int drawn = drawns[k]; int drawnOffset = drawnOffsets[drawn]; for (int i = 0; i < busWidth; i++) { ImmutableNetLayout.connectMap( netMap, portOffset + i, drawnOffset + (busWidth == drawnWidths[drawn] ? i : i % drawnWidths[drawn])); GenMath.MutableInteger nn = netNames.get(expNm.subname(i)); ImmutableNetLayout.connectMap(netMap, portOffset + i, netNamesOffset + nn.intValue()); } } // PortInsts for (int k = 0; k < numNodes; k++) { ImmutableNodeInst n = nodes.get(k); if (isIconOfParent(n)) { continue; } // NodeProto np = ni.getProto(); if (n.protoId instanceof PrimitiveNodeId) { // Connect global primitives Global g = globalInst(n); if (g != null) { int drawn = drawns[ni_pi[k]]; ImmutableNetLayout.connectMap(netMap, globals.indexOf(g), drawnOffsets[drawn]); } if (n.protoId == schem.wireConNode.getId()) { connectWireCon(netMap, n); } continue; } IconInst iconInst = iconInsts[k]; if (iconInst == null || iconInst.iconOfParent) { continue; } assert iconInst.nodeInst == n; CellId subCellId = (CellId) n.protoId; assert subCellId.isIcon() || subCellId.isSchematic(); EquivalentSchematicExports iconEq = iconInst.eq; EquivalentSchematicExports schemEq = iconEq.implementation; assert schemEq != null; Name nodeName = n.name; int arraySize = nodeName.busWidth(); int numPorts = getNumPorts(n.protoId); CellBackup subCell = snapshot.getCell(subCellId); for (int m = 0; m < numPorts; m++) { ImmutableExport e = subCell.cellRevision.exports.get(m); Name busExportName = e.name; int busWidth = busExportName.busWidth(); int drawn = drawns[ni_pi[k] + m]; if (drawn < 0) { continue; } int width = drawnWidths[drawn]; if (width != busWidth && width != busWidth * arraySize) { continue; } for (int arrayIndex = 0; arrayIndex < arraySize; arrayIndex++) { int nodeOffset = iconInst.netMapOffset + arrayIndex * iconInst.numExtendedExports; int busOffset = drawnOffsets[drawn]; if (width != busWidth) { busOffset += busWidth * arrayIndex; } for (int j = 0; j < busWidth; j++) { Name exportName = busExportName.subname(j); int portOffset = schemEq.getExportNameMapOffset(exportName); if (portOffset < 0) { continue; } ImmutableNetLayout.connectMap(netMap, busOffset + j, nodeOffset + portOffset); } } } } // Arcs for (int arcIndex = 0; arcIndex < numArcs; arcIndex++) { ImmutableArcInst a = arcs.get(arcIndex); int drawn = drawns[arcsOffset + arcIndex]; if (drawn < 0) { continue; } if (!a.isUsernamed()) { continue; } int busWidth = drawnWidths[drawn]; Name arcNm = a.name; if (arcNm.busWidth() != busWidth) { continue; } int drawnOffset = drawnOffsets[drawn]; for (int i = 0; i < busWidth; i++) { GenMath.MutableInteger nn = netNames.get(arcNm.subname(i)); ImmutableNetLayout.connectMap(netMap, drawnOffset + i, netNamesOffset + nn.intValue()); } } // Globals of proxies for (IconInst iconInst : iconInsts) { if (iconInst == null || iconInst.iconOfParent) { continue; } Set<Global> excludeGlobals = null; if (iconInstExcludeGlobals != null) { excludeGlobals = iconInstExcludeGlobals.get(iconInst); } for (int k = 0; k < iconInst.nodeInst.name.busWidth(); k++) { EquivalentSchematicExports eq = iconInst.eq.implementation; assert eq.implementation == eq; int numGlobals = eq.portOffsets[0]; if (numGlobals == 0) { continue; } int nodableOffset = iconInst.netMapOffset + k * iconInst.numExtendedExports; for (int i = 0; i < numGlobals; i++) { Global g = eq.globals.get(i); if (excludeGlobals != null && excludeGlobals.contains(g)) { continue; } ImmutableNetLayout.connectMap(netMap, this.globals.indexOf(g), nodableOffset + i); } } } ImmutableNetLayout.closureMap(netMap); }
void calcDrawnWidths() { Arrays.fill(drawnNames, null); Arrays.fill(drawnWidths, -1); for (int i = 0; i < numExports; i++) { int drawn = drawns[i]; Name name = exports.get(i).name; int newWidth = name.busWidth(); int oldWidth = drawnWidths[drawn]; if (oldWidth < 0) { drawnNames[drawn] = name; drawnWidths[drawn] = newWidth; continue; } if (oldWidth != newWidth) { reportDrawnWidthError( /*cell.getPort(i), null,*/ drawnNames[drawn].toString(), name.toString()); if (oldWidth < newWidth) { drawnNames[drawn] = name; drawnWidths[drawn] = newWidth; } } } for (int arcIndex = 0; arcIndex < numArcs; arcIndex++) { ImmutableArcInst a = arcs.get(arcIndex); int drawn = drawns[arcsOffset + arcIndex]; if (drawn < 0) { continue; } Name name = a.name; if (name.isTempname()) { continue; } int newWidth = name.busWidth(); int oldWidth = drawnWidths[drawn]; if (oldWidth < 0) { drawnNames[drawn] = name; drawnWidths[drawn] = newWidth; continue; } if (oldWidth != newWidth) { reportDrawnWidthError(/*null, ai,*/ drawnNames[drawn].toString(), name.toString()); if (oldWidth < newWidth) { drawnNames[drawn] = name; drawnWidths[drawn] = newWidth; } } } for (int arcIndex = 0; arcIndex < numArcs; arcIndex++) { int drawn = drawns[arcsOffset + arcIndex]; if (drawn < 0) { continue; } ImmutableArcInst a = arcs.get(arcIndex); Name name = a.name; if (!name.isTempname()) { continue; } int oldWidth = drawnWidths[drawn]; if (oldWidth < 0) { drawnNames[drawn] = name; if (a.protoId != busArc.getId()) { drawnWidths[drawn] = 1; } } } for (int i = 0; i < numNodes; i++) { ImmutableNodeInst n = nodes.get(i); // NodeProto np = ni.getProto(); if (n.protoId instanceof PrimitiveNodeId) { PrimitiveNode pn = techPool.getPrimitiveNode((PrimitiveNodeId) n.protoId); if (pn.getFunction().isPin()) { continue; } if (pn == Schematics.tech().offpageNode) { continue; } } int numPortInsts = getNumPorts(n.protoId); for (int j = 0; j < numPortInsts; j++) { PortInst pi = new PortInst(n.nodeId, getPortIdByIndex(n.protoId, j)); int drawn = drawns[pi.getPortInstOffset()]; if (drawn < 0) { continue; } int oldWidth = drawnWidths[drawn]; int newWidth = 1; if (n.protoId instanceof CellId) { CellBackup subCell = snapshot.getCell((CellId) n.protoId); CellId subCellId = subCell.cellRevision.d.cellId; if (subCellId.isIcon() || subCellId.isSchematic()) { int arraySize = subCellId.isIcon() ? n.name.busWidth() : 1; int portWidth = subCell.cellRevision.exports.get(j).name.busWidth(); if (oldWidth == portWidth) { continue; } newWidth = arraySize * portWidth; } } if (oldWidth < 0) { drawnWidths[drawn] = newWidth; continue; } if (oldWidth != newWidth) { String msg = "Network: Schematic " + cellId + " has net <" + drawnNames[drawn] + "> with width conflict in connection " + pi.n.name + " " + pi.portId; System.out.println(msg); // networkManager.pushHighlight(pi); // networkManager.logError(msg, NetworkTool.errorSortNetworks); } } } for (int i = 0; i < drawnWidths.length; i++) { if (drawnWidths[i] < 1) { drawnWidths[i] = 1; } if (DEBUG) { System.out.println( "Drawn " + i + " " + (drawnNames[i] != null ? drawnNames[i].toString() : "") + " has width " + drawnWidths[i]); } } }