📄 elib.java
字号:
errorMessage += ":" + name; arcProtoError[arcProtoCount] = errorMessage; } arcProtoList[arcProtoCount++] = ap; } } // get the lambda values in the library for(int i=0; i<techCount; i++) { int lambda = techLambda[i]; if (techError[i] != null) continue; Technology tech = techList[i]; // for Electric version 4 or earlier, scale lambda by 20 if (scaleLambdaBy20) lambda *= 20; techScale.put(tech, Double.valueOf(lambda)); String varName = tech.getScaleVariableName(); Variable var = Variable.newInstance(Variable.newKey(varName), new Double(lambda/2), TextDescriptor.EMPTY); realizeMeaningPrefs(tech, new Variable[] { var }); } // read the tool variables for(int i=0; i<toolCount; i++) { Tool tool = toolList[i]; if (tool != null) realizeMeaningPrefs(tool, toolVars[i]); } // read the technology variables for(int i=0; i<techCount; i++) { Technology tech = techList[i]; if (tech != null) realizeMeaningPrefs(tech, techVars[i]);// getTechList(i); } if (onlyProjectSettings) return null; // erase the current database lib.erase(); lib.lowLevelSetUserBits(libUserBits); lib.setFromDisk(); lib.setVersion(version); realizeVariables(lib, libVars); // read the cells HashMap<Cell,Variable[]> originalVars = new HashMap<Cell,Variable[]>(); for(int i=0; i<nodeProtoCount; i++) { if (arcCounts[i] < 0 && nodeCounts[i] < 0) continue; xLibRefSatisfied[i] = true; realizeNodeProto(i, originalVars); } // collect the cells by common protoName and by "nextInCellGroup" relation TransitiveRelation<Object> transitive = new TransitiveRelation<Object>(); HashMap<String,String> protoNames = new HashMap<String,String>(); for(int cellIndex=0; cellIndex<nodeProtoCount; cellIndex++) { Cell cell = nodeProtoList[cellIndex]; if (cell == null || cell.getLibrary() != lib) continue; String protoName = protoNames.get(cell.getName()); if (protoName == null) { protoName = cell.getName(); protoNames.put(protoName, protoName); } transitive.theseAreRelated(cell, protoName); Cell otherCell = null; int nextInCell = cellNextInCellGroup[cellIndex]; if (nextInCell >= 0) otherCell = nodeProtoList[nextInCell]; if (otherCell != null && cell.getLibrary() == lib) transitive.theseAreRelated(cell, otherCell); }// // link the cells// for(int cellIndex=0; cellIndex<nodeProtoCount; cellIndex++)// {// Cell cell = nodeProtoList[cellIndex];// if (cell == null) continue;// cell.lowLevelLink();// } // join the cell groups for (Iterator<Set<Object>> git = transitive.getSetsOfRelatives(); git.hasNext();) { Set<Object> group = git.next(); Cell firstCell = null; for (Object o : group) { if (!(o instanceof Cell)) continue; Cell cell = (Cell)o; if (firstCell == null) firstCell = cell; else cell.joinGroup(firstCell); } } // now read external cells for(int i=0; i<nodeProtoCount; i++) { Cell cell = nodeProtoList[i]; if (cell != null) continue; realizeExternalNodeProto(lib, i); } // warn if any dummy cells were read in for (Iterator<Cell> it = lib.getCells(); it.hasNext(); ) { Cell c = it.next(); if (c.getVar(IO_DUMMY_OBJECT) != null) { System.out.println("WARNING: "+lib+" contains DUMMY cell "+c.noLibDescribe()); } } return originalVars; } @Override Variable[] findVarsOnExampleIcon(Cell parentCell, Cell iconCell) { // get information about this cell int cellIndex; for (cellIndex = 0; cellIndex < nodeProtoList.length; cellIndex++) { if (nodeProtoList[cellIndex] == parentCell) break; } if (cellIndex+1 >= firstNodeIndex.length) return null; int startNode = firstNodeIndex[cellIndex]; int endNode = firstNodeIndex[cellIndex+1]; for (int i = startNode; i < endNode; i++) { NodeProto np = convertNodeProto(nodeTypeList[i]); if (np == iconCell) return nodeInstList.vars[i]; } return null; } // *************************** THE CELL CLEANUP INTERFACE *************************** /** * Method to recursively create the contents of each cell in the library. */ protected void realizeCellsRecursively(Cell cell, HashSet<Cell> recursiveSetupFlag, String scaledCellName, double scale) { // do not realize cross-library references if (cell.getLibrary() != lib) return; // skip if dummy cell, already created boolean dummyCell = (cell.getVar(IO_DUMMY_OBJECT) != null) ? true : false; if (dummyCell) return; // get information about this cell int cellIndex = cell.getTempInt(); if (cellIndex+1 >= firstNodeIndex.length) return; int startNode = firstNodeIndex[cellIndex]; int endNode = firstNodeIndex[cellIndex+1]; // recursively ensure that external library references are satisfied for(int i=startNode; i<endNode; i++) { NodeProto np = nodeInstList.protoType[i]; if (np instanceof PrimitiveNode) continue; Cell subCell = (Cell)np; if (subCell.getLibrary() == lib) continue; // subcell: make sure that cell is setup for(int cI = 0; cI<nodeProtoCount; cI++) { if (nodeProtoList[cI] != subCell) continue; if (xLibRefSatisfied[cI]) break; // make sure that cell is properly built if (!recursiveSetupFlag.contains(subCell)) { LibraryFiles reader = getReaderForLib(subCell.getLibrary()); if (reader != null) reader.realizeCellsRecursively(subCell, recursiveSetupFlag, null, 0); } int startPort = firstPortIndex[cI]; int endPort = startPort + portCounts[cI]; for(int j=startPort; j<endPort; j++) { Object obj = exportList[j]; Export pp = null; Cell otherCell = null; if (obj instanceof Cell) { otherCell = (Cell)obj; pp = (Export)findPortProto(otherCell, exportNameList[j]);// pp = otherCell.findExport(exportNameList[j]); if (pp != null) { exportList[j] = pp; } } } xLibRefSatisfied[cI] = true; break; } } // recursively scan the nodes to the bottom and only proceed when everything below is built scanNodesForRecursion(cell, recursiveSetupFlag, nodeInstList.protoType, startNode, endNode); // report progress if (LibraryFiles.VERBOSE) { if (scaledCellName == null) { System.out.println("Binary: Doing contents of " + cell + " in " + lib); } else { System.out.println("Binary: Scaling (by " + scale + ") contents of " + cell + " in " + lib); } } cellsConstructed++; setProgressValue(cellsConstructed * 100 / totalCells);// if (progress != null) progress.setProgress(cellsConstructed * 100 / totalCells); double lambda = cellLambda[cellIndex]; // if scaling, actually construct the cell if (scaledCellName != null) { Cell oldCell = cell; cell = Cell.newInstance(cell.getLibrary(), scaledCellName); cell.setTempInt(cellIndex); recursiveSetupFlag.add(cell); cell.joinGroup(oldCell); scaledCells.add(cell); lambda /= scale; } else scale = 1; // finish initializing the NodeInsts in the cell: start with the cell-center int xoff = 0, yoff = 0; for(int i=startNode; i<endNode; i++) { NodeProto np = nodeInstList.protoType[i]; if (np == Generic.tech().cellCenterNode) { realizeNode(nodeInstList, i, xoff, yoff, lambda, cell, np); xoff = (nodeInstList.lowX[i] + nodeInstList.highX[i]) / 2; yoff = (nodeInstList.lowY[i] + nodeInstList.highY[i]) / 2; break; } } cellXOff[cellIndex] = xoff; cellYOff[cellIndex] = yoff; // finish creating the rest of the NodeInsts for(int i=startNode; i<endNode; i++) { NodeProto np = nodeInstList.protoType[i]; if (np == Generic.tech().cellCenterNode) continue; if (np instanceof Cell) np = scaleCell(i, lambda, cell, recursiveSetupFlag); realizeNode(nodeInstList, i, xoff, yoff, lambda, cell, np); } // do the exports now realizeExports(cell, cellIndex, scaledCellName); // do the arcs now realizeArcs(cell, cellIndex, scaledCellName, scale);// // restore the node pointers if this was a scaled cell construction// if (scaledCellName != null)// {// int j = 0;// for(int i=startNode; i<endNode; i++)// nodeInstList.theNode[i] = oldNodes[j++];// } cell.loadExpandStatus(); } protected boolean spreadLambda(Cell cell, int cellIndex) { boolean changed = false; int startNode = firstNodeIndex[cellIndex]; int endNode = firstNodeIndex[cellIndex+1]; double thisLambda = cellLambda[cellIndex]; for(int i=startNode; i<endNode; i++) { NodeProto np = nodeInstList.protoType[i]; if (np instanceof PrimitiveNode) continue; Cell subCell = (Cell)np; // ignore dummy cells, they are created in the default lambda if (subCell.getVar(IO_DUMMY_OBJECT) != null) continue; LibraryFiles reader = this; if (subCell.getLibrary() != lib) { reader = getReaderForLib(subCell.getLibrary()); if (reader == null) continue; } int subCellIndex = subCell.getTempInt();// if (subCellIndex < 0 || subCellIndex >= reader.cellLambda.length)// {// System.out.println("Index is "+subCellIndex+" but limit is "+reader.cellLambda.length);// continue;// } double subLambda = reader.cellLambda[subCellIndex]; if (subLambda < thisLambda && cell.isSchematic() && subCell.isIcon()) { reader.cellLambda[subCellIndex] = thisLambda; changed = true; } } return changed; } protected void computeTech(Cell cell, Set uncomputedCells) { uncomputedCells.remove(cell); int cellIndex = 0; for(; cellIndex<nodeProtoCount && nodeProtoList[cellIndex] != cell; cellIndex++); if (cellIndex >= nodeProtoCount) return; int startNode = firstNodeIndex[cellIndex]; int endNode = firstNodeIndex[cellIndex+1]; // recursively ensure that subcells's technologies are computed for(int i=startNode; i<endNode; i++) { NodeProto np = convertNodeProto(nodeTypeList[i]); nodeInstList.protoType[i] = np; if (!uncomputedCells.contains(np)) continue; Cell subCell = (Cell)np; LibraryFiles reader = getReaderForLib(subCell.getLibrary()); if (reader != null) reader.computeTech(subCell, uncomputedCells); } int startArc = firstArcIndex[cellIndex]; int endArc = firstArcIndex[cellIndex+1]; ArcProto[] arcTypes = new ArcProto[endArc - startArc]; for (int i = 0; i < arcTypes.length; i++) arcTypes[i] = convertArcProto(arcTypeList[i]); Technology cellTech = Technology.whatTechnology(cell, nodeInstList.protoType, startNode, endNode, arcTypes); cell.setTechnology(cellTech);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -