📄 libraryfiles.java
字号:
var = var.withUnit(groupParam.getUnit()); } foundParams++; cell.setTextDescriptor(var.getKey(), var.getTextDescriptor()); continue; } if (var.getTextDescriptor().isParam()) { String msg = cell + " has extra parameter \"" + var.getTrueName() + "\" compared to " + cell.getCellGroup().getParameterOwner(); errorLogger.logError(msg, EPoint.fromLambda(var.getXOff(), var.getYOff()), cell, 2); var = var.withParam(false); if (var.getKey() == NccCellAnnotations.NCC_ANNOTATION_KEY) var = var.withInherit(false).withInterior(false); } } realizeVariable(cell, var); } if (foundParams == groupParams.size()) return; // Create parameters which were omitted in the disk library HashSet<Variable.AttrKey> omittedParams = new HashSet<Variable.AttrKey>(groupParams.keySet()); for (Variable var: origVars) omittedParams.remove(var.getKey()); assert omittedParams.size() + foundParams == groupParams.size(); // For icon cell try to find variables on an example icon in schematic cell Variable[] exampleVars = null; if (cell.isIcon()) { for (Iterator<Cell> cit = cell.getCellGroup().getCells(); cit.hasNext();) { Cell schCell = cit.next(); if (!schCell.isSchematic()) continue; exampleVars = findVarsOnExampleIcon(schCell, cell); if (exampleVars == null) continue; break; } } for (Variable.AttrKey omittedParam: omittedParams) { Variable param = groupParams.get(omittedParam); String msg = cell + " must have parameter \"" + param.getTrueName() + "\" as on " + cell.getCellGroup().getParameterOwner(); Variable exampleParam = null; if (exampleVars != null) { for (Variable var: exampleVars) { if (var == null || var.getKey() != omittedParam) continue; exampleParam = var; break; } } if (exampleParam != null) { TextDescriptor td = exampleParam.getTextDescriptor(); td = td.withInherit(true).withParam(true).withUnit(param.getUnit()); boolean interior = !exampleParam.isDisplay(); td = td.withInterior(interior).withDisplay(true); param = param.withTextDescriptor(td); } assert param.getTextDescriptor().isParam() && param.isInherit(); errorLogger.logError(msg, EPoint.fromLambda(param.getXOff(), param.getYOff()), cell, 2); cell.setTextDescriptor(param.getKey(), param.getTextDescriptor()); } } abstract Variable[] findVarsOnExampleIcon(Cell parentCell, Cell iconCell); protected void scanNodesForRecursion(Cell cell, HashSet<Cell> markCellForNodes, NodeProto [] nil, int start, int end) { // scan the nodes in this cell and recurse for(int j=start; j<end; j++) { NodeProto np = nil[j]; if (np instanceof PrimitiveNode) continue; Cell otherCell = (Cell)np; if (otherCell == null) continue; // subcell: make sure that cell is setup if (markCellForNodes.contains(otherCell)) continue; LibraryFiles reader = this; if (otherCell.getLibrary() != cell.getLibrary()) reader = getReaderForLib(otherCell.getLibrary()); // subcell: make sure that cell is setup if (reader != null) reader.realizeCellsRecursively(otherCell, markCellForNodes, null, 0); } markCellForNodes.add(cell); } /** * Method to read project settings from a Library. * This method is never called. * Instead, it is always overridden by the appropriate read subclass. * @return true on error. */ protected boolean readProjectSettings() { return true; } /** * Method to find the View to use for an old View name. * @param viewName the old View name. * @return the View to use (null if not found). */ protected View findOldViewName(String viewName) { if (version.getMajor() < 8) { if (viewName.equals("compensated")) return View.LAYOUTCOMP; if (viewName.equals("skeleton")) return View.LAYOUTSKEL; if (viewName.equals("simulation-snapshot")) return View.DOCWAVE; if (viewName.equals("netlist-netlisp-format")) return View.NETLISTNETLISP; if (viewName.equals("netlist-rsim-format")) return View.NETLISTRSIM; if (viewName.equals("netlist-silos-format")) return View.NETLISTSILOS; if (viewName.equals("netlist-quisc-format")) return View.NETLISTQUISC; if (viewName.equals("netlist-als-format")) return View.NETLISTALS; } return null; } protected Technology findTechnologyName(String name) { Technology tech = null; if (convertMosisCmosTechnologies) { if (name.equals("mocmossub")) tech = Technology.getMocmosTechnology(); else if (name.equals("mocmos")) tech = Technology.findTechnology("mocmosold"); } if (tech == null) tech = Technology.findTechnology(name); if (tech == null && name.equals("logic")) tech = Schematics.tech(); if (tech == null && (name.equals("epic8c") || name.equals("epic7c"))) tech = Technology.findTechnology("epic7s"); return tech; } /** * Method to read an external library file, given its name as stored on disk. * Attempts to find the file in many different ways, including asking the user. * @param theFileName the full path to the file, as written to disk. * @return a Library that was read. If library cannot be read or found, creates * a Library called DUMMYname, and returns that. */ protected Library readExternalLibraryFromFilename(String theFileName, FileType defaultType) { // get the path to the library file String legalLibName = TextUtils.getFileNameWithoutExtension(theFileName); // Checking if the library is already open Library elib = Library.findLibrary(legalLibName); if (elib != null) return elib;// URL url = TextUtils.makeURLToFile(theFileName);// String fileName = url.getFile();// File libFile = new File(fileName); // see if this library is already read in String libFileName = theFileName;// String libFileName = libFile.getName(); // special case if the library path came from a different computer system and still has separators while (libFileName.endsWith("\\") || libFileName.endsWith(":") || libFileName.endsWith("/")) libFileName = libFileName.substring(0, libFileName.length()-1); int backSlashPos = libFileName.lastIndexOf('\\'); int colonPos = libFileName.lastIndexOf(':'); int slashPos = libFileName.lastIndexOf('/'); int charPos = Math.max(backSlashPos, Math.max(colonPos, slashPos)); if (charPos >= 0) { libFileName = libFileName.substring(charPos+1); } String libName = libFileName; FileType importType = OpenFile.getOpenFileType(libName, defaultType); FileType preferredType = importType; // this is just to remove the extension from the lib name string if (libName.endsWith(".elib")) { libName = libName.substring(0, libName.length()-5); } else if (libName.endsWith(".jelib")) { libName = libName.substring(0, libName.length()-6); } else if (libName.endsWith(".delib")) { libName = libName.substring(0, libName.length()-6); } else if (libName.endsWith(".txt")) { libName = libName.substring(0, libName.length()-4); } else { // no recognizable extension, add one to the file name libFileName += "." + defaultType.getExtensions()[0]; } StringBuffer errmsg = new StringBuffer(); // first try the library name with the extension it came with // However, do not look in electric library area to avoid problems with spice configurations for old chips URL externalURL = getLibrary(libName + "." + preferredType.getExtensions()[0], theFileName, errmsg, true); // Now try all file types, starting with jelib // try JELIB if (externalURL == null && preferredType != FileType.JELIB) { externalURL = getLibrary(libName + "." + FileType.JELIB.getExtensions()[0], theFileName, errmsg, true); } // try ELIB if (externalURL == null && preferredType != FileType.ELIB) { externalURL = getLibrary(libName + "." + FileType.ELIB.getExtensions()[0], theFileName, errmsg, true); } // try DELIB if (externalURL == null && preferredType != FileType.DELIB) { externalURL = getLibrary(libName + "." + FileType.DELIB.getExtensions()[0], theFileName, errmsg, true); } // try txt if (externalURL == null && preferredType != FileType.READABLEDUMP) { externalURL = getLibrary(libName + "." + FileType.READABLEDUMP.getExtensions()[0], theFileName, errmsg, true); } boolean exists = (externalURL == null) ? false : true; // last option: let user pick library location if (!exists) { System.out.println("Error: cannot find referenced library " + libName+":"); System.out.print(errmsg.toString()); String pt = null; while (true) { // continue to ask the user where the library is until they hit "cancel" String description = "Reference library '" + libFileName + "'"; pt = OpenFile.chooseInputFile(FileType.LIBFILE, description); if (pt == null) { // user cancelled, break break; } // see if user chose a file we can read externalURL = TextUtils.makeURLToFile(pt); if (externalURL != null) { exists = TextUtils.URLExists(externalURL, null); if (exists) { // good pt, opened it, get out of here break; } } } } if (exists) { System.out.println("Reading referenced library " + externalURL.getFile()); importType = OpenFile.getOpenFileType(externalURL.getFile(), defaultType); elib = Library.newInstance(legalLibName, externalURL); } if (elib != null) { // read the external library String oldNote = getProgressNote(); setProgressValue(0); setProgressNote("Reading referenced library " + legalLibName + "..."); // get the library name String eLibName = TextUtils.getFileNameWithoutExtension(externalURL); elib = readALibrary(externalURL, elib, eLibName, importType); setProgressValue(100); setProgressNote(oldNote); } if (elib == null) { System.out.println("Error: cannot find referenced library " + theFileName); System.out.println("...Creating new "+legalLibName+" Library instead"); elib = Library.newInstance(legalLibName, null); elib.setLibFile(TextUtils.makeURLToFile(theFileName)); elib.clearFromDisk(); }// if (failed) elib->userbits |= UNWANTEDLIB; else// {// // queue this library for announcement through change control// io_queuereadlibraryannouncement(elib);// } return elib; } /** Get the URL to the library named libFileName * @param libFileName the library file name (with extension) * @param originalPath the original, exact path of the reference if any * @param errmsg a StringBuffer into which errors may be placed. * @param checkElectricLib to force search in Electric library area * @return null if not found, or valid URL if file found */ private URL getLibrary(String libFileName, String originalPath, StringBuffer errmsg, boolean checkElectricLib) { // library does not exist: see if file is in the same directory as the main file URL firstURL = TextUtils.makeURLToFile(mainLibDirectory + libFileName); boolean exists = TextUtils.URLExists(firstURL, errmsg); if (exists) return firstURL; HashMap<String,String> searchedURLs = new HashMap<String,String>(); // try secondary library file locations for (Iterator<String> libIt = LibDirs.getLibDirs(); libIt.hasNext(); ) { URL url = TextUtils.makeURLToFile(libIt.next() + File.separator + libFileName); exists = TextUtils.URLExists(url, errmsg); if (exists) return url; if (url != null) searchedURLs.put(url.getFile(), url.getFile()); } // check the current working dir // (Note that this is not necessarily the same as the mainLibDirectory above) // Do NOT search User.getCurrentWorkingDir, as another Electric process can // modify that during library read instead, search System.getProperty("user.dir"); URL thirdURL = TextUtils.makeURLToFile(System.getProperty("user.dir") + File.separator + libFileName); if (thirdURL != null && !searchedURLs.containsKey(thirdURL.getFile())) { exists = TextUtils.URLExists(thirdURL, errmsg); if (exists) return thirdURL; if (thirdURL != null) searchedURLs.put(thirdURL.getFile(), thirdURL.getFile()); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -