📄 netschem.java
字号:
System.out.println(msg); networkManager.pushHighlight(ni); networkManager.logError(msg, NetworkTool.errorSortNetworks); return; } } if (ai2 == null || ai1 == ai2) return; int large = getArcDrawn(ai1); int small = getArcDrawn(ai2); if (large < 0 || small < 0) return; if (drawnWidths[small] > drawnWidths[large]) { int temp = small; small = large; large = temp; } for (int i = 0; i < drawnWidths[large]; i++) Netlist.connectMap(netMap, drawnOffsets[large] + i, drawnOffsets[small] + (i % drawnWidths[small])); } private void internalConnections(int[] netMapF, int[] netMapP, int[] netMapA) { int numNodes = cell.getNumNodes(); for (int k = 0; k < numNodes; k++) { NodeInst ni = cell.getNode(k); int nodeOffset = ni_pi[k]; NodeProto np = ni.getProto(); if (!ni.isCellInstance()) { PrimitiveNode.Function fun = ni.getFunction(); if (fun == PrimitiveNode.Function.RESIST) { Netlist.connectMap(netMapP, drawnOffsets[drawns[nodeOffset]], drawnOffsets[drawns[nodeOffset + 1]]); Netlist.connectMap(netMapA, drawnOffsets[drawns[nodeOffset]], drawnOffsets[drawns[nodeOffset + 1]]); } else if (fun.isPolyOrWellResistor()) { Netlist.connectMap(netMapA, drawnOffsets[drawns[nodeOffset]], drawnOffsets[drawns[nodeOffset + 1]]); } continue; } NetCell netCell = networkManager.getNetCell((Cell)np); if (nodeOffsets[k] < 0) continue; for (int i = 0, numPorts = netCell.equivPortsN.length; i < numPorts; i++) { int di = drawns[nodeOffset + i]; if (di < 0) continue; int jN = netCell.equivPortsN[i]; if (i != jN) { int dj = drawns[nodeOffset + jN]; if (dj >= 0) Netlist.connectMap(netMapF, drawnOffsets[di], drawnOffsets[dj]); } int jP = netCell.equivPortsP[i]; if (i != jP) { int dj = drawns[nodeOffset + jP]; if (dj >= 0) Netlist.connectMap(netMapP, drawnOffsets[di], drawnOffsets[dj]); } int jA = netCell.equivPortsA[i]; if (i != jA) { int dj = drawns[nodeOffset + jA]; if (dj >= 0) Netlist.connectMap(netMapA, drawnOffsets[di], drawnOffsets[dj]); } } } for (int k = 0; k < nodeProxies.length; k++) { Proxy proxy = nodeProxies[k]; if (proxy == null) continue; NodeProto np = proxy.getProto(); NetSchem schem = (NetSchem)networkManager.getNetCell((Cell)np); int[] eqF = schem.equivPortsN; int[] eqP = schem.equivPortsP; int[] eqA = schem.equivPortsA; for (int i = 0; i < eqF.length; i++) { int io = proxy.nodeOffset + i; int jF = eqF[i]; if (i != jF) Netlist.connectMap(netMapF, io, proxy.nodeOffset + jF); int jP = eqP[i]; if (i != jP) Netlist.connectMap(netMapP, io, proxy.nodeOffset + jP); int jA = eqA[i]; if (i != jA) Netlist.connectMap(netMapA, io, proxy.nodeOffset + jA); } } if (cell.libDescribe().equals("spiceparts:Ammeter{ic}")) { int mapOffset0 = getNetMapOffset(cell.getPort(0), 0); int mapOffset1 = getNetMapOffset(cell.getPort(1), 0); Netlist.connectMap(netMapP, mapOffset0, mapOffset1); Netlist.connectMap(netMapA, mapOffset0, mapOffset1); } } private void buildNetworkLists(int[] netMapF) { netlistN = new NetlistImpl(this, equivPortsN.length, netMapF); int equivPortIndex = 0; for (int i = 0; i < globals.size(); i++) { Global global = globals.get(i); int netIndex = netlistN.getNetIndex(global); netlistN.addUserName(netIndex, global.getNameKey(), true); netlistN.setEquivPortIndexByNetIndex(equivPortIndex++, netIndex); } for (Iterator<Export> it = cell.getExports(); it.hasNext(); ) { Export e = it.next(); for (int busIndex = 0; busIndex < e.getNameKey().busWidth(); busIndex++) netlistN.setEquivPortIndexByNetIndex(equivPortIndex++, netlistN.getNetIndex(e, busIndex)); } for (Map.Entry<Name,GenMath.MutableInteger> e: netNames.entrySet()) { Name name = e.getKey(); int index = e.getValue().intValue(); if (index < 0 || index >= exportedNetNameCount) continue; netlistN.addUserName(netlistN.getNetIndexByMap(netNamesOffset + index), name, true); } for (Map.Entry<Name,GenMath.MutableInteger> e: netNames.entrySet()) { Name name = e.getKey(); int index = e.getValue().intValue(); if (index < exportedNetNameCount) continue; netlistN.addUserName(netlistN.getNetIndexByMap(netNamesOffset + index), name, false); } // add temporary names to unnamed nets int numArcs = cell.getNumArcs(), arcIndex = 0; for (Iterator<ArcInst> it = cell.getArcs(); arcIndex < numArcs; arcIndex++) { ArcInst ai = it.next(); int drawn = drawns[arcsOffset + arcIndex]; if (drawn < 0) continue; for (int j = 0; j < drawnWidths[drawn]; j++) { int netIndexN = netlistN.getNetIndex(ai, j); if (netIndexN >= 0 && netlistN.hasNames(netIndexN)) netIndexN = -1; if (netIndexN < 0) continue; if (drawnNames[drawn] == null) continue; String netName; if (drawnWidths[drawn] == 1) netName = drawnNames[drawn].toString(); else if (drawnNames[drawn].isTempname()) { int busIndex = NetworkTool.isBusAscendingInNetlistEngine() ? j : drawnWidths[drawn]-1-j; netName = drawnNames[drawn].toString() + "[" + busIndex + "]"; } else netName = drawnNames[drawn].subname(j).toString(); if (netIndexN >= 0) netlistN.addTempName(netIndexN, netName); } } // add temporary names to unconnected ports for (Iterator<Nodable> it = getNodables(); it.hasNext();) { Nodable no = it.next(); NodeProto np = no.getProto(); for (int i = 0, numPorts = np.getNumPorts(); i < numPorts; i++) { PortProto pp = np.getPort(i); for (int k = 0, busWidth = pp.getNameKey().busWidth(); k < busWidth; k++) { int netIndexN = netlistN.getNetIndex(no, pp, k); if (netIndexN >= 0 && !netlistN.hasNames(netIndexN)) netlistN.addTempName(netIndexN, no.getName() + "." + pp.getNameKey().subname(k)); } } } // add temporary names to unconnected ports for (int n = 0, numNodes = cell.getNumNodes(); n < numNodes; n++) { NodeInst ni = cell.getNode(n); NodeProto np = ni.getProto(); int arraySize = ni.getNameKey().busWidth(); for (int i = 0, numPorts = np.getNumPorts(); i < numPorts; i++) { PortProto pp = np.getPort(i); int drawn = drawns[ni_pi[n] + i]; if (drawn < 0) continue; int busWidth = pp.getNameKey().busWidth(); int drawnWidth = drawnWidths[drawn]; for (int l = 0; l < drawnWidth; l++) { int netIndexN = netlistN.getNetIndexByMap(drawnOffsets[drawn] + l); if (netIndexN >= 0 && !netlistN.hasNames(netIndexN)) { int arrayIndex = (l / busWidth) % arraySize; int busIndex = l % busWidth; netlistN.addTempName(netIndexN, ni.getNameKey().subname(arrayIndex) + "." + pp.getNameKey().subname(busIndex)); } } } } // check names and equivPortIndexByNetIndex map for (int i = 0, numNetworks = netlistN.getNumNetworks(); i < numNetworks; i++) { assert netlistN.hasNames(i); assert netlistN.isExported(i) == (i < netlistN.getNumExternalNetworks()); if (netlistN.isExported(i)) { int equivPortInd = netlistN.getEquivPortIndexByNetIndex(i); assert equivPortInd >= 0 && equivPortInd < equivPortIndex; } } /* // debug info System.out.println("BuildNetworkList "+cell); for (int kk = 0; kk < 2; kk++) { Netlist netlist; if (kk == 0) { netlist = netlistF; System.out.println("NetlistF"); } else { netlist = netlistT; System.out.println("NetlistT"); } int i = 0; for (int l = 0; l < netlist.networks.length; l++) { Network network = netlist.networks[l]; if (network == null) continue; String s = ""; for (Iterator<String> sit = network.getNames(); sit.hasNext(); ) { String n = sit.next(); s += "/"+ n; } System.out.println(" "+i+" "+s); i++; for (int k = 0; k < globals.size(); k++) { if (netlist.nm_net[netlist.netMap[k]] != l) continue; System.out.println("\t" + globals.get(k)); } int numPorts = cell.getNumPorts(); for (int k = 0; k < numPorts; k++) { Export e = (Export) cell.getPort(k); for (int j = 0; j < e.getNameKey().busWidth(); j++) { if (netlist.nm_net[netlist.netMap[portOffsets[k] + j]] != l) continue; System.out.println("\t" + e + " [" + j + "]"); } } for (int k = 0; k < numDrawns; k++) { for (int j = 0; j < drawnWidths[k]; j++) { int ind = drawnOffsets[k] + j; int netInd = netlist.netMap[ind]; if (netlist.nm_net[netlist.netMap[drawnOffsets[k] + j]] != l) continue; System.out.println("\tDrawn " + k + " [" + j + "]"); } } for (Iterator<NetName> it = netNames.values().iterator(); it.hasNext();) { NetName nn = it.next(); if (netlist.nm_net[netlist.netMap[netNamesOffset + nn.index]] != l) continue; System.out.println("\tNetName " + nn.name); } } } */ } /** * Update map of equivalent ports newEquivPort. */ private boolean updateInterface() { boolean changed = false; for (int i = 0; i < equivPortsN.length; i++) { if (equivPortsN[i] != netlistN.netMap[i]) { changed = true; equivPortsN[i] = netlistN.netMap[i]; } if (equivPortsP[i] != netlistP.netMap[i]) { changed = true; equivPortsP[i] = netlistP.netMap[i]; } if (equivPortsA[i] != netlistA.netMap[i]) { changed = true; equivPortsA[i] = netlistA.netMap[i]; } } return changed; } @Override boolean redoNetworks1() {// System.out.println("redoNetworks1 on " + cell); int numPorts = cell.getNumPorts(); if (portOffsets.length != numPorts + 1) portOffsets = new int[numPorts + 1]; /* Set index of NodeInsts */ if (drawnNames == null || drawnNames.length != numDrawns) { drawnNames = new Name[numDrawns]; drawnWidths = new int[numDrawns]; drawnOffsets = new int[numDrawns]; } calcDrawnWidths(); boolean changed = initNodables(); // Gather port and arc names int mapSize = netNamesOffset + netNames.size();// HashMap/*<Cell,Netlist>*/ subNetlistsF = new HashMap/*<Cell,Netlist>*/();// for (Iterator it = getNodables(); it.hasNext(); ) {// Nodable no = it.next();// if (!no.isCellInstance()) continue;// Cell subCell = (Cell)no.getProto();// subNetlistsF.put(subCell, networkManager.getNetlist(subCell, false));// } int[] netMapF = Netlist.initMap(mapSize); localConnections(netMapF);// HashMap/*<Cell,Netlist>*/ subNetlistsT = new HashMap/*<Cell,Netlist>*/();// for (Iterator<Nodable> it = getNodables(); it.hasNext(); ) {// Nodable no = it.next();// if (!no.isCellInstance()) continue;// Cell subCell = (Cell)no.getProto();// subNetlistsT.put(subCell, networkManager.getNetlist(subCell, true));// } int[] netMapP = netMapF.clone(); int[] netMapA = netMapF.clone(); internalConnections(netMapF, netMapP, netMapA); buildNetworkLists(netMapF); assert equivPortsP.length == equivPortsN.length; netlistP = new NetlistShorted(netlistN, Netlist.ShortResistors.PARASITIC, netMapP); assert equivPortsA.length == equivPortsN.length; netlistA = new NetlistShorted(netlistN, Netlist.ShortResistors.ALL, netMapA); if (updatePortImplementation()) changed = true; if (updateInterface()) changed = true; return changed; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -