📄 topology.java
字号:
} if (isAggregateNamesSupported()) { printWriter.println("** Have " + cni.cellAggregateSignals.size() + " aggregate signals:"); for(CellAggregateSignal cas : cni.cellAggregateSignals) { printWriter.print("** Name="+cas.name+", export="+cas.pp+" descending="+cas.descending); if (cas.indices != null) { printWriter.print(", indices="); for(int i=0; i<cas.indices.length; i++) { if (i != 0) printWriter.print(","); printWriter.print(cas.indices[i]); } printWriter.println(); } else { printWriter.println(", low="+cas.low+", high="+cas.high); } } } printWriter.println("********DONE WITH " + cell); } return cni; } private CellNetInfo doGetNetworks(Cell cell, boolean quiet, String paramName, boolean useExportedName, HierarchyEnumerator.CellInfo info) { // create the object with cell net information CellNetInfo cni = new CellNetInfo(); cni.cell = cell; cni.paramName = paramName; // get network information about this cell cni.netList = info.getNetlist(); Global.Set globals = cni.netList.getGlobals(); int globalSize = globals.size(); // create a map of all nets in the cell cni.cellSignals = new HashMap<Network,CellSignal>(); for(Iterator<Network> it = cni.netList.getNetworks(); it.hasNext(); ) { Network net = it.next(); // special case: ignore nets on transistor bias ports that are unconnected and unexported if (!net.isExported() && !net.getArcs().hasNext()) { Iterator<PortInst> pIt = net.getPorts(); if (pIt.hasNext()) { PortInst onlyPI = pIt.next(); PortProto pp = onlyPI.getPortProto(); if (pp instanceof PrimitivePort && !pIt.hasNext()) { // found just one primitive port on this network if (((PrimitivePort)pp).isWellPort()) continue; } } } CellSignal cs = new CellSignal(); cs.pp = null; cs.descending = !NetworkTool.isBusAscending(); cs.power = false; cs.ground = false; cs.net = net; // see if it is global cs.globalSignal = null; for(int j=0; j<globalSize; j++) { Global global = globals.get(j); if (cni.netList.getNetwork(global) == net) { cs.globalSignal = global; break; } } // name the signal if (cs.globalSignal != null) { cs.name = getGlobalName(cs.globalSignal); } else { cs.name = net.getName(); } // save it in the map of signals cni.cellSignals.put(net, cs); } // look at all busses and mark directionality, first unnamed busses, then named ones for(int j=0; j<2; j++) { for(Iterator<ArcInst> aIt = cell.getArcs(); aIt.hasNext(); ) { ArcInst ai = aIt.next(); if (ai.getNameKey().isTempname()) { // temp names are handled first, ignore them in pass 2 if (j != 0) continue; } else { // real names are handled second, ignore them in pass 1 if (j == 0) continue; } int width = cni.netList.getBusWidth(ai); if (width < 2) continue; Network [] nets = new Network[width]; String [] netNames = new String[width]; for(int i=0; i<width; i++) { nets[i] = cni.netList.getNetwork(ai, i); netNames[i] = null; if (j != 0) { String preferredName = ai.getNameKey().subname(i).toString(); for(Iterator<String> nIt = nets[i].getNames(); nIt.hasNext(); ) { String netName = nIt.next(); if (netName.equals(preferredName)) { netNames[i] = netName; break; } } } if (netNames[i] == null) netNames[i] = nets[i].getNames().next(); } setBusDirectionality(nets, netNames, cni); } } // mark exported networks and set their bus directionality for(Iterator<Export> it = cell.getExports(); it.hasNext(); ) { Export pp = it.next(); // mark every network on the bus (or just 1 network if not a bus) int portWidth = cni.netList.getBusWidth(pp); for(int i=0; i<portWidth; i++) { Network net = cni.netList.getNetwork(pp, i); CellSignal cs = cni.cellSignals.get(net); if (cs == null) continue; // if there is already an export on this signal, make sure that it is wider if (cs.pp != null) { if (isChooseBestExportName()) { int oldPortWidth = cni.netList.getBusWidth(cs.pp); if (isAggregateNamesSupported()) { // with aggregate names, the widest bus is the best, so that long runs can be emitted if (oldPortWidth >= portWidth) continue; } else { // without aggregate names, individual signal names are more important if (oldPortWidth == 1) continue; if (portWidth != 1 && oldPortWidth >= portWidth) continue; } } else { if (TextUtils.STRING_NUMBER_ORDER.compare(cs.pp.getName(), pp.getName()) <= 0) continue; } } // save this export's information cs.pp = pp; cs.ppIndex = i; if (useExportedName) { String rootName = pp.getName(); if (portWidth == 1) { cs.name = rootName; } int openPos = rootName.indexOf('['); if (openPos > 0) { rootName = rootName.substring(0, openPos); for(Iterator<String> nIt = net.getExportedNames(); nIt.hasNext(); ) { String exportNetName = nIt.next(); String exportRootName = exportNetName; openPos = exportRootName.indexOf('['); if (openPos > 0) { exportRootName = exportRootName.substring(0, openPos); if (rootName.equals(exportRootName)) { cs.name = rootName + exportNetName.substring(openPos); } } } } } } if (portWidth <= 1) continue; Network [] nets = new Network[portWidth]; String [] netNames = new String[portWidth]; for(int i=0; i<portWidth; i++) { nets[i] = cni.netList.getNetwork(pp, i); String preferredName = pp.getNameKey().subname(i).toString(); netNames[i] = null; for(Iterator<String> nIt = nets[i].getNames(); nIt.hasNext(); ) { String netName = nIt.next(); if (netName.equals(preferredName)) { netNames[i] = netName; break; } } if (netNames[i] == null) netNames[i] = nets[i].getNames().next(); } setBusDirectionality(nets, netNames, cni); } // find power and ground cni.pwrNet = cni.gndNet = null; boolean multiPwr = false, multiGnd = false; for(Iterator<PortProto> eIt = cell.getPorts(); eIt.hasNext(); ) { Export pp = (Export)eIt.next(); int portWidth = cni.netList.getBusWidth(pp); if (portWidth > 1) continue; Network subNet = cni.netList.getNetwork(pp, 0); if (pp.isPower()) { if (cni.pwrNet != null && cni.pwrNet != subNet && !multiPwr) { if (!quiet) System.out.println("Warning: multiple power networks in " + cell); multiPwr = true; } cni.pwrNet = subNet; } if (pp.isGround()) { if (cni.gndNet != null && cni.gndNet != subNet && !multiGnd) { if (!quiet) System.out.println("Warning: multiple ground networks in " + cell); multiGnd = true; } cni.gndNet = subNet; } } for(Iterator<Network> it = cni.netList.getNetworks(); it.hasNext(); ) { Network net = it.next(); CellSignal cs = cni.cellSignals.get(net); if (cs == null) continue; if (cs.globalSignal != null) { if (cs.globalSignal == Global.power) { if (cni.pwrNet != null && cni.pwrNet != net && !multiPwr) { if (!quiet) System.out.println("Warning: multiple power networks in " + cell); multiPwr = true; } cni.pwrNet = net; } if (cs.globalSignal == Global.ground) { if (cni.gndNet != null && cni.gndNet != net && !multiGnd) { if (!quiet) System.out.println("Warning: multiple ground networks in " + cell); multiGnd = true; } cni.gndNet = net; } } } for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); ) { NodeInst ni = it.next(); PrimitiveNode.Function fun = ni.getFunction(); if (fun == PrimitiveNode.Function.CONPOWER || fun == PrimitiveNode.Function.CONGROUND) { for(Iterator<Connection> cIt = ni.getConnections(); cIt.hasNext(); ) { Connection con = cIt.next(); ArcInst ai = con.getArc(); Network subNet = cni.netList.getNetwork(ai, 0); if (fun == PrimitiveNode.Function.CONPOWER) { if (cni.pwrNet != null && cni.pwrNet != subNet && !multiPwr) { if (!quiet) System.out.println("Warning: multiple power networks in " + cell); multiPwr = true; } cni.pwrNet = subNet; } else { if (cni.gndNet != null && cni.gndNet != subNet && !multiGnd) { if (!quiet) System.out.println("Warning: multiple ground networks in " + cell); multiGnd = true; } cni.gndNet = subNet; } } } } if (cni.pwrNet != null) { CellSignal cs = cni.cellSignals.get(cni.pwrNet); String powerName = getPowerName(cni.pwrNet); if (powerName != null) cs.name = powerName; cs.power = true; } if (cni.gndNet != null) { CellSignal cs = cni.cellSignals.get(cni.gndNet); String groundName = getGroundName(cni.gndNet); if (groundName != null) cs.name = groundName; cs.ground = true; } // make an array of the CellSignals cni.cellSignalsSorted = new ArrayList<CellSignal>(); for(CellSignal cs : cni.cellSignals.values()) cni.cellSignalsSorted.add(cs); // sort the networks by characteristic and name Collections.sort(cni.cellSignalsSorted, new SortNetsByName(isSeparateInputAndOutput(), isAggregateNamesSupported())); // create aggregate signals if needed if (isAggregateNamesSupported()) { // organize by name and index order cni.cellAggregateSignals = new ArrayList<CellAggregateSignal>(); int total = cni.cellSignalsSorted.size(); for(int i=0; i<total; i++) { CellSignal cs = cni.cellSignalsSorted.get(i); CellAggregateSignal cas = new CellAggregateSignal(); cas.name = unIndexedName(cs.name); cas.pp = cs.pp; cas.ppIndex = cs.ppIndex; cas.supply = cs.power | cs.ground; cas.descending = cs.descending; cas.flags = 0; cs.aggregateSignal = cas; if (cs.name.equals(cas.name)) { // single wire: set range to show that cas.low = 1; cas.high = 0; cas.signals = new CellSignal[1]; cas.signals[0] = cs; } else { boolean hasGaps = false; cas.high = cas.low = TextUtils.atoi(cs.name.substring(cas.name.length()+1)); int start = i; for(int j=i+1; j<total; j++) { CellSignal csEnd = cni.cellSignalsSorted.get(j); if (csEnd.descending != cs.descending) break;// if (cell.isSchematic() && csEnd.pp != cs.pp) break; if (csEnd.globalSignal != cs.globalSignal) break; String endName = csEnd.name; String ept = unIndexedName(endName); if (ept.equals(endName)) break; if (!ept.equals(cas.name)) break; int index = TextUtils.atoi(endName.substring(ept.length()+1)); // make sure export indices go in order if (index != cas.high+1) { if (!isAggregateNameGapsSupported()) break; hasGaps = true; } if (index > cas.high) cas.high = index; i = j; csEnd.aggregateSignal = cas; } cas.signals = new CellSignal[i-start+1]; if (hasGaps) cas.indices = new int[i-start+1]; for(int j=start; j<=i; j++) { CellSignal csEnd = cni.cellSignalsSorted.get(j); if (hasGaps) { String endName = csEnd.name; String ept = unIndexedName(endName); cas.indices[j-start] = TextUtils.atoi(endName.substring(ept.length()+1)); } cas.signals[j-start] = csEnd; } } cni.cellAggregateSignals.add(cas); } // give all signals a safe name for(CellAggregateSignal cas : cni.cellAggregateSignals) cas.name = getSafeNetName(cas.name, true); // make sure all names are unique int numNameList = cni.cellAggregateSignals.size(); for(int i=1; i<numNameList; i++) { // single signal: give it that name CellAggregateSignal cas = cni.cellAggregateSignals.get(i); // see if the name clashes for(int k=0; k<1000; k++) { String ninName = cas.name; if (k > 0) ninName = ninName + "_" + k; boolean found = false; for(int j=0; j<i; j++) { CellAggregateSignal oCas = cni.cellAggregateSignals.get(j); if (ninName.equals(oCas.name)) { found = true; break; } } if (!found) { if (k > 0) cas.name = ninName; break; } } } // put names back onto the signals for(CellAggregateSignal cas : cni.cellAggregateSignals) { if (cas.low > cas.high) { CellSignal cs = cas.signals[0]; cs.name = cas.name; } else { if (cas.indices != null) { for(int k=0; k<cas.indices.length; k++) { CellSignal cs = cas.signals[k]; cs.name = getSafeNetName(cas.name + "[" + cas.indices[k] + "]", false); } } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -