📄 libraryfiles.java
字号:
// try the exact path specified in the reference if (originalPath != null) { URL url = TextUtils.makeURLToFile(originalPath); String fileName = url.getFile(); File libFile = new File(fileName); originalPath = libFile.getParent(); URL secondURL = TextUtils.makeURLToFile(originalPath + File.separator + libFileName); if (secondURL != null && !searchedURLs.containsKey(secondURL.getFile())) { exists = TextUtils.URLExists(secondURL, errmsg); if (exists) return secondURL; if (secondURL != null) searchedURLs.put(secondURL.getFile(), secondURL.getFile()); } } if (checkElectricLib) { // try the Electric library area URL url = LibFile.getLibFile(libFileName); exists = TextUtils.URLExists(url, errmsg); if (exists) return url; } return null; } public static void cleanupLibraryInput() { setProgressValue(0); setProgressNote("Constructing cell contents..."); // Compute technology of new cells Set<Cell> uncomputedCells = new HashSet<Cell>(); for(LibraryFiles reader : libsBeingRead) { for(int cellIndex=0; cellIndex<reader.nodeProtoCount; cellIndex++) { Cell cell = reader.nodeProtoList[cellIndex]; if (cell == null) continue; if (cell.getLibrary() != reader.lib) continue; uncomputedCells.add(cell); } } for(LibraryFiles reader : libsBeingRead) { for(int cellIndex=0; cellIndex<reader.nodeProtoCount; cellIndex++) { Cell cell = reader.nodeProtoList[cellIndex]; if (cell == null) continue; if (cell.getLibrary() != reader.lib) continue; reader.computeTech(cell, uncomputedCells); } } // clear flag bits for scanning the library hierarchically totalCells = 0; HashSet<Cell> markCellForNodes = new HashSet<Cell>(); for(LibraryFiles reader : libsBeingRead) { totalCells += reader.nodeProtoCount; for(int cellIndex=0; cellIndex<reader.nodeProtoCount; cellIndex++) { Cell cell = reader.nodeProtoList[cellIndex]; if (cell == null) continue; if (cell.getLibrary() != reader.lib) continue; reader.cellLambda[cellIndex] = reader.computeLambda(cell, cellIndex); cell.setTempInt(cellIndex); } } cellsConstructed = 0; // now recursively adjust lambda sizes if (LibraryFiles.VERBOSE) System.out.println("Preparing to compute scale factors"); for(int i=0; i<20; i++) { boolean unchanged = true; for(LibraryFiles reader : libsBeingRead) { for(int cellIndex=0; cellIndex<reader.nodeProtoCount; cellIndex++) { Cell cell = reader.nodeProtoList[cellIndex]; if (cell == null) continue; if (cell.getLibrary() != reader.lib) continue; if (reader.spreadLambda(cell, cellIndex)) { unchanged = false; } } } if (unchanged) break; } if (LibraryFiles.VERBOSE) System.out.println("Finished computing scale factors"); // recursively create the cell contents for(LibraryFiles reader : libsBeingRead) { for(int cellIndex=0; cellIndex<reader.nodeProtoCount; cellIndex++) { Cell cell = reader.nodeProtoList[cellIndex]; if (cell == null) continue; if (markCellForNodes.contains(cell)) continue; reader.realizeCellsRecursively(cell, markCellForNodes, null, 0); } } for (LibraryFiles reader: libsBeingRead) reader.lib.clearChanged(); // tell which libraries had extra "scaled" cells added boolean first = true; for(LibraryFiles reader : libsBeingRead) { if (reader.scaledCells != null && reader.scaledCells.size() != 0) { if (first) { System.out.println("WARNING: to accommodate scaling inconsistencies, these cells were created:"); first = false; } StringBuffer sb = new StringBuffer(); sb.append(" Library " + reader.lib.getName() + ":"); for(Cell cell : reader.scaledCells) { sb.append(" " + cell.noLibDescribe()); } System.out.println(sb.toString()); } } // convert Spice model file data (was on cells, now in preferences) Variable.Key SPICE_MODEL_FILE_KEY = Variable.newKey("SIM_spice_behave_file"); for(LibraryFiles reader : libsBeingRead) { for(int cellIndex=0; cellIndex<reader.nodeProtoCount; cellIndex++) { Cell cell = reader.nodeProtoList[cellIndex]; if (cell == null) continue; String spiceModelFile = cell.getVarValue(SPICE_MODEL_FILE_KEY, String.class); if (spiceModelFile != null) { CellModelPrefs.spiceModelPrefs.setModelFile(cell, spiceModelFile, false, false); } String verilogModelFile = cell.getVarValue(Verilog.VERILOG_BEHAVE_FILE_KEY, String.class); if (verilogModelFile != null) { CellModelPrefs.verilogModelPrefs.setModelFile(cell, verilogModelFile, false, false); } } } // adjust for old library conversion// convertOldLibraries(); // broadcast the library-read to all listeners for(Iterator<Listener> it = Tool.getListeners(); it.hasNext(); ) { Listener listener = it.next(); for(LibraryFiles reader : libsBeingRead) { listener.readLibrary(reader.lib); } } if (!undefinedTechsAndPrimitives.isEmpty()) { String prims = ""; for (TechId techId: undefinedTechsAndPrimitives.keySet()) { int count = 0; for (PrimitiveNodeId primId : undefinedTechsAndPrimitives.get(techId)) { prims += " " + primId + ", "; count += primId.name.length(); if (count > 50) // 50 is an arbritary number { count = 0; prims += "\n"; } } Job.getUserInterface().showErrorMessage("Library contains unknown nodes from the technology '" + techId + "':\n" + prims, "Unknown nodes/technologies"); } } // clean up init (free LibraryFiles for garbage collection) libsBeingRead.clear(); undefinedTechsAndPrimitives.clear(); }// private static void convertOldLibraries()// {// // see if the MOSIS CMOS technology now has old-style state information// MoCMOS.tech.convertOldState();// } protected LibraryFiles getReaderForLib(Library lib) { for (LibraryFiles reader : libsBeingRead) { if (reader.lib == lib) return reader; } return null; } Technology.SizeCorrector getSizeCorrector(Technology tech) { Technology.SizeCorrector corrector = sizeCorrectors.get(tech); if (corrector == null) { corrector = tech.getSizeCorrector(version, projectSettings, false, false); sizeCorrectors.put(tech, corrector); } return corrector; } String convertCellName(String s) { StringBuffer buf = null; for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (ch == '\n' || ch == '|' || ch == ':') { if (buf == null) { buf = new StringBuffer(); buf.append(s.substring(0, i)); } buf.append('-'); continue; } else if (buf != null) { buf.append(ch); } } if (buf != null) { String newS = buf.toString(); System.out.println("Cell name " + s + " was converted to " + newS); return newS; } return s; } /** * Method to conver name of Geometric object. * @param value name of object * @param isDisplay true if this is displayable variable. */ protected static String convertGeomName(Object value, boolean isDisplay) { if (value == null || !(value instanceof String)) return null; String str = (String)value; int indexOfAt = str.indexOf('@'); if (isDisplay) { if (indexOfAt >= 0) { String newS = ""; for (int i = 0; i < str.length(); i++) { char c = str.charAt(i); if (c == '@') c = '_'; newS += c; } str = newS; } } else if (indexOfAt < 0) return null; return str; } /** * Method to build a NodeInst. * @param nil arrays with data of new NodeInst * @param nodeIndex index in nik array * @param xoff x-offset of NodeInst in integer coordinates * @param yoff y-offset of NodeInst in integer coordinates * @param lambda scale factor * @param parent parent Cell * @param proto actual node proto (may be different for instance of scaled Cells) */ void realizeNode(NodeInstList nil, int nodeIndex, int xoff, int yoff, double lambda, Cell parent, NodeProto proto) { double lowX = nil.lowX[nodeIndex]-xoff; double lowY = nil.lowY[nodeIndex]-yoff; double highX = nil.highX[nodeIndex]-xoff; double highY = nil.highY[nodeIndex]-yoff; Point2D center = new Point2D.Double(((lowX + highX) / 2) / lambda, ((lowY + highY) / 2) / lambda); EPoint size = EPoint.ORIGIN; if (proto instanceof PrimitiveNode) { PrimitiveNode pn = (PrimitiveNode)proto; size = getSizeCorrector(pn.getTechnology()).getSizeFromDisk(pn, (highX - lowX) / lambda, (highY - lowY) / lambda); } int rotation = nil.rotation[nodeIndex]; boolean flipX = false; boolean flipY = false; if (rotationMirrorBits) { // new version: allow mirror bits if ((nil.transpose[nodeIndex]&1) != 0) { flipY = true; rotation = (rotation + 900) % 3600; } if ((nil.transpose[nodeIndex]&2) != 0) { // mirror in X flipX = true; } if ((nil.transpose[nodeIndex]&4) != 0) { // mirror in Y flipY = !flipY; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -