📄 ncccellannotations.java
字号:
private void processResistorType(NamePatternLexer lex) { NamePattern type = lex.nextPattern(); if (type==null) { prErr("Bad resistorType annotation: missing type"); return; } NamePattern type2 = lex.nextPattern(); if (type2!=null) { prErr("Bad resistorType annotation: only one type allowed"); return; } if (resistorType!=null) { prErr("only one resistorType annotation allowed per Cell"); return; } resistorType = type.getName(); if (resistorType==null) { prErr("resistor type may not be a regular expression"); return; } } private void processForceWireMatch(NamePatternLexer lex) { NamePattern wireNamePat = lex.nextPattern(); if (wireNamePat==null) { prErr("Bad forceWireMatch annotation: missing Wire name"); return; } String wireName = wireNamePat.getName(); if (wireName==null) { prErr("Bad forceWireMatch annotation: Wire name may not be a regular expression"); return; } forceWireMatches.add(wireName); NamePattern namePat2 = lex.nextPattern(); if (namePat2!=null) { prErr("Bad forceWireMatch annotation: only one Wire name allowed"); } } private void processForcePartMatch(NamePatternLexer lex) { NamePattern partNamePat = lex.nextPattern(); if (partNamePat==null) { prErr("Bad forcePartMatch annotation: missing Part name"); return; } String partName = partNamePat.getName(); if (partName==null) { prErr("Bad forcePartMatch annotation: Part name may not be a regular expression"); return; } forcePartMatches.add(partName); NamePattern namePat2 = lex.nextPattern(); if (namePat2!=null) { prErr("Bad forcePartMatch annotation: only one Part name allowed"); } } private void doAnnotation(String note) { annotText.add(note); // for prErr() NamePatternLexer lex = new NamePatternLexer(note); NamePattern key = lex.nextPattern(); if (key==null) { // skip blank lines } else if (key.stringEquals("exportsConnectedByParent")) { processExportsConnAnnot(lex); } else if (key.stringEquals("skipNCC")) { processSkipAnnotation(lex); } else if (key.stringEquals("notSubcircuit")) { processNotSubcircuitAnnotation(lex); } else if (key.stringEquals("joinGroup")) { processJoinGroupAnnotation(note); } else if (key.stringEquals("flattenInstances")) { processFlattenInstancesAnnotation(lex); } else if (key.stringEquals("exportsToRename")) { processExportsToRenameAnnotation(lex); } else if (key.stringEquals("blackBox")) { processBlackBox(lex); } else if (key.stringEquals("transistorType")) { processTransistorType(lex); } else if (key.stringEquals("resistorType")) { processResistorType(lex); } else if (key.stringEquals("forceWireMatch")) { processForceWireMatch(lex); } else if (key.stringEquals("forcePartMatch")) { processForcePartMatch(lex); } else { prErr("Unrecognized NCC annotation."); } } private NccCellAnnotations(Cell cell, Object annotation) { cellThatOwnsMe = NccUtils.fullName(cell); // for prErr() if (annotation instanceof String) { doAnnotation((String) annotation); } else if (annotation instanceof String[]) { String[] ss = (String[]) annotation; for (int i=0; i<ss.length; i++) doAnnotation(ss[i]); } else { prErr(" ignoring bad NCC annotation: "); } } /** * Class to create a Cell NCC annotation object in a new Job. */ private static class MakeCellAnnotationJob extends Job { static final long serialVersionUID = 0; private transient EditWindow_ wnd; private Cell cell; private String newAnnotation; private MakeCellAnnotationJob(EditWindow_ wnd, Cell cell, String annotation) { super("Make Cell NCC Annotation", NetworkTool.getNetworkTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.wnd = wnd; this.cell = cell; newAnnotation = annotation; startJob(); } public boolean doIt() throws JobException { addNccAnnotation(cell, newAnnotation); return true; } public void terminateOK() { wnd.clearHighlighting(); wnd.addHighlightText(cell, cell, NCC_ANNOTATION_KEY); wnd.finishedHighlighting(); } } // ---------------------- public methods ----------------------------- /** * Method to create NCC annotations in the current Cell. * Called from the menu commands. */ public static void makeNCCAnnotationMenuCommand(String newAnnotation) { UserInterface ui = Job.getUserInterface(); EditWindow_ wnd = ui.needCurrentEditWindow_(); if (wnd == null) return; Cell cell = ui.needCurrentCell(); if (cell == null) return; new MakeCellAnnotationJob(wnd, cell, newAnnotation); } /** Add an NCC annotation to a Cell. */ public static void addNccAnnotation(Cell c, String newAnnotation) { Variable nccVar = c.getVar(NCC_ANNOTATION_KEY); if (nccVar == null) { String [] initial = new String[1]; initial[0] = newAnnotation; TextDescriptor td = TextDescriptor.getCellTextDescriptor().withInterior(true).withDispPart(TextDescriptor.DispPos.NAMEVALUE); nccVar = c.newVar(NCC_ANNOTATION_KEY, initial, td); LayoutLib.error(nccVar==null, "couldn't create NCC annotation"); } else { Object oldObj = nccVar.getObject(); if (oldObj instanceof String) { /* Groan! Menu command always creates NCC attributes as arrays of strings. * However, if user edits a single line NCC attribute then dialog box * converts it back into a String. Be prepared to convert it back into an array*/ oldObj = new String[] {(String)oldObj}; } LayoutLib.error(!(oldObj instanceof String[]), "NCC annotation not String[]"); String[] oldVal = (String[]) oldObj; TextDescriptor td = nccVar.getTextDescriptor(); int newLen = oldVal.length+1; String[] newVal = new String[newLen]; for (int i=0; i<newLen-1; i++) newVal[i]=oldVal[i]; newVal[newLen-1] = newAnnotation; nccVar = c.newVar(NCC_ANNOTATION_KEY, newVal, td); } } /** * Method to get the NCC annotations on a Cell. * @param cell the Cell to query. * @return the NccCellAnnotations for the Cell. * Returns null if the Cell has no NCC annotations */ public static NccCellAnnotations getAnnotations(Cell cell) { Variable nccVar = cell.getVar(NCC_ANNOTATION_KEY); if (nccVar==null) return null; Object annotation = nccVar.getObject(); return new NccCellAnnotations(cell, annotation); } /** @return a String which is the reason given by the user for not * NCCing the cell or null if there is no skipNCC annotation on * the cell. */ public String getSkipReason() {return skipReason;} /** @return the reason given by the user for not treating this Cell * as a subcircuit during hierarchical NCC. Return null if there is * no notSubcircuitReason annotation on the Cell */ public String getNotSubcircuitReason() {return notSubcircuitReason;} /** @return an Iterator over Lists of NamePatterns. Each List specifies * the names (or regular expressions that match the names) of Exports * that the user expects to be connected by the Cell's parent. */ public Iterator<List<NamePattern>> getExportsConnected() {return exportsConnByParent.iterator();} public Iterator<String> getAnnotationText() {return annotText.iterator();} public Cell.CellGroup getGroupToJoin() {return groupToJoin;} public boolean flattenInstance(String instName) { for (NamePattern pattern : flattenInstances) { if (pattern.matches(instName)) return true; } return false; } public boolean renameExport(String exportName) { for (NamePattern pattern : exportsToRename) { if (pattern.matches(exportName)) return true; } return false; } /** @return the reason given by the user for block boxing this Cell. * return null if there is no blackBox annotation. */ public String getBlackBoxReason() {return blackBoxReason;} /** @return the transistor type if Cell has a transitorType annotation. * Otherwise return null. */ public String getTransistorType() {return transistorType;} /** @return the resistor type if Cell has a resistorType annotation. * Otherwise return null. */ public String getResistorType() {return resistorType;} /** @return the names of Wires for which we should force matches */ public List<String> getForceWireMatches() {return forceWireMatches;} /** @return the names of Wires for which we should force matches */ public List<String> getForcePartMatches() {return forcePartMatches;}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -