📄 calibredrcerrors.java
字号:
} else { System.out.println("Error, expected Edge or Poly definition on line number "+lineno+": "+nextLine); } return null; } // parse a line specifying an edge, and add it to a list of shapes // lambdaScale: divide microns by this number to get lambda private Shape parseErrorEdge(String line, double lambdaScale) { String [] vals = line.trim().split(spaces); if (vals.length != 4) { System.out.println("Error, bad format for edge on line number "+lineno+": "+line); return null; } try { double x1 = (double)Integer.parseInt(vals[0])/(double)scale/lambdaScale; double y1 = (double)Integer.parseInt(vals[1])/(double)scale/lambdaScale; double x2 = (double)Integer.parseInt(vals[2])/(double)scale/lambdaScale; double y2 = (double)Integer.parseInt(vals[3])/(double)scale/lambdaScale; Shape line2d = new Line2D.Double(x1, y1, x2, y2); return line2d; } catch (NumberFormatException e) { System.out.println("Error, bad format for edge on line number "+lineno+": "+line); return null; } } // parse a line specifying a polygon vertex, and add it to a list of points private boolean parseErrorPoint(String line, Point2D [] points, int point, double lambdaScale) { String [] vals = line.trim().split(spaces); if (vals.length != 2) { System.out.println("Error, bad format for poly vertex on line number "+lineno+": "+line); return false; } try { double x1 = (double)Integer.parseInt(vals[0])/(double)scale/lambdaScale; double y1 = (double)Integer.parseInt(vals[1])/(double)scale/lambdaScale; Point2D p = new Point2D.Double(x1, y1); points[point] = p; return true; } catch (NumberFormatException e) { System.out.println("Error, bad format for poly vertex on line number "+lineno+": "+line); return false; } } /** * Method to create Logger * @return number of errors if found */ private int done() { try { in.close(); } catch (IOException e) {} // populate error logger logger = ErrorLogger.newInstance("Calibre "+type+" Errors"); int sortKey = 0; int count = 0; for (Iterator<DrcRuleViolation> it = ruleViolations.iterator(); it.hasNext(); ) { DrcRuleViolation v = it.next(); String ruleDesc = v.header.comment.toString().replaceAll("\\n", ";"); int y = 1; for (Iterator<DrcError> it2 = v.errors.iterator(); it2.hasNext(); ) { DrcError drcError = it2.next(); Cell cell = drcError.cell; List<EPoint> lineList = new ArrayList<EPoint>(); List<PolyBase> polyList = new ArrayList<PolyBase>(); for (Iterator<Shape> it3 = drcError.shapes.iterator(); it3.hasNext(); ) { Shape shape = it3.next(); if (shape instanceof Line2D) { Line2D line = (Line2D)shape; lineList.add(new EPoint(line.getX1(), line.getY1())); lineList.add(new EPoint(line.getX2(), line.getY2())); } else if (shape instanceof PolyBase) { PolyBase poly = (PolyBase)shape; polyList.add(poly); } else { System.out.println("Unsupported drc error shape "+shape); } } logger.logError(y+". "+cell.getName()+": "+ruleDesc, null, null, lineList, null, polyList, cell, sortKey); y++; count++; } logger.setGroupName(sortKey, "(" + (y-1) + ") " + ruleDesc); sortKey++; } System.out.println(type+" Imported "+count+" errors from "+filename); if (count == 0 && !noPopupMessages) { Job.getUserInterface().showInformationMessage(type+" Imported Zero Errors", type+" Import Complete"); } logger.termLogging(!noPopupMessages); return logger.getNumErrors(); } // ----------------------------------------------------------------------------- private static class DrcRuleViolation {// private final String ruleNumber; private final Header header; private final List<DrcError> errors; // list of DrcErrors private DrcRuleViolation(String ruleNumber, Header header) {// this.ruleNumber = ruleNumber; this.header = header; this.errors = new ArrayList<DrcError>(); } private void addError(DrcError error) { errors.add(error); } } private static class DrcError { private final Cell cell; private final List<Shape> shapes; // list of shapes private DrcError(Cell cell) { this.cell = cell; this.shapes = new ArrayList<Shape>(); } private void addShape(Shape shape) { shapes.add(shape); } } private static class Header { private final int currentDrcResultsCount;// private final int originalDrcResultsCount; private final int headerLength; // does not include headerStart line// private String ruleFilePath;// private String ruleFileTitle; private StringBuffer comment; private Header(int currentDrcResultsCount, int originalDrcResultsCount, int headerLength) { this.currentDrcResultsCount = currentDrcResultsCount;// this.originalDrcResultsCount = originalDrcResultsCount; this.headerLength = headerLength; comment = new StringBuffer(); } public void addHeaderLine(String line) { if (line.startsWith("Rule File Pathname")) {// ruleFilePath = line; } else if (line.startsWith("Rule File Title")) {// ruleFileTitle = line; } else { if (comment.length() != 0) { // already a line added comment.append("\n"); } comment.append(line); } } } // --------------------------------------------------------- private String readLine() throws IOException { return readLine(true); } private String readLine(boolean errorOnEOF) throws IOException { // if in is null we ignore if (in == null) return null; String line = in.readLine(); if (line == null && errorOnEOF) { System.out.println("Unexpected End of File!"); in = null; // ignore rest of readLine requests return null; } lineno++; return line; } public static Cell getCell(String cellName, Map<Cell,String> mangledNames) { List<Cell> matchedNames = new ArrayList<Cell>(); for (Map.Entry<Cell,String> entry : mangledNames.entrySet()) { String name = entry.getValue(); if (name.equals(cellName)) matchedNames.add(entry.getKey()); } if (matchedNames.size() == 0) return null; if (matchedNames.size() == 1) return matchedNames.get(0); // more than one match, ask user to choose, or just return the first one in non-interactive mode UserInterface ui = Job.getUserInterface(); String choices[] = new String[matchedNames.size()]; for (int i=0; i<choices.length; i++) { choices[i] = matchedNames.get(i).describe(false); } int c = ui.askForChoice("Multiple cells matches, please choose one for \""+cellName+"\":", "Ambiguity Found", choices, choices[0]); return matchedNames.get(c); }/* public static Cell getCell(String cellName) { // try blind search for (Iterator<Library> it = Library.getLibraries(); it.hasNext(); ) { Library lib = (Library)it.next(); Cell c = lib.findNodeProto(cellName+"{lay}"); if (c != null && (c instanceof Cell)) return c; } // assume libname.cellname format if (cellName.indexOf(GDS.concatStr) != -1) { String libname = cellName.substring(0, cellName.indexOf(GDS.concatStr)); String name = cellName.substring(cellName.indexOf(GDS.concatStr)+1, cellName.length()); Library lib = Library.findLibrary(libname); if (lib == null) { // lib name may have been truncated for (Iterator<Library> it = Library.getLibraries(); it.hasNext(); ) { Library l = (Library)it.next(); if (l.getName().startsWith(libname)) { lib = l; break; } } } if (lib != null) { Cell c = lib.findNodeProto(name+"{lay}"); if (c != null && (c instanceof Cell)) return c; // try taking off any ending _### if (name.matches("(.+?)_\\d+")) { int underscore = name.lastIndexOf('_'); c = lib.findNodeProto(name.substring(0, underscore)+"{lay}"); if (c != null && (c instanceof Cell)) return c; } } } return null; }*/ // ====================================================================================== // DRC Density results public static void readDensityErrors(Cell cell, File drcDirectory) { if (drcDirectory == null || !drcDirectory.exists() || !drcDirectory.isDirectory()) { System.out.println("DRC density errors: no such directory: "+drcDirectory.getAbsolutePath()); return; } ErrorLogger logger = ErrorLogger.newInstance("Calibre DRC Density Values"); int sortKey = 0; double scale = cell.getTechnology().getScale(); for (File file : drcDirectory.listFiles()) { if (file.getName().endsWith(".density")) { try { FileReader reader = new FileReader(file); BufferedReader in = new BufferedReader(reader); String line = null; boolean first = true; while ( (line = in.readLine()) != null) { if (line.equals("")) continue; if (first) { logger.setGroupName(sortKey, file.getName()); first = false; } String [] parts = line.split("[ ]+"); double x1, y1, x2, y2; x1 = Double.valueOf(parts[0]) / scale * 1000; y1 = Double.valueOf(parts[1]) / scale * 1000; x2 = Double.valueOf(parts[2]) / scale * 1000; y2 = Double.valueOf(parts[3]) / scale * 1000; Point2D [] points = new Point2D[4]; points[0] = new Point2D.Double(x1, y1); points[1] = new Point2D.Double(x1, y2); points[2] = new Point2D.Double(x2, y2); points[3] = new Point2D.Double(x2, y1); PolyBase poly = new PolyBase(points); logger.logError(file.getName()+": "+parts[4], poly, cell, sortKey); } if (!first) sortKey++; } catch (IOException e) { System.out.println("Error read file "+file.getName()+": "+e.getMessage()); } } } logger.termLogging(false); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -