📄 sclibrarygen.java
字号:
* Mark the cell as a standard cell. * This version of the method performs the task in a Job. * @param standardCells a list of Cells to mark with the standard cell attribute marker. * @param notStandardCells a list of Cells to remove the standard cell attribute marker. */ public static void markStandardCellJob(List<Cell> standardCells, List<Cell> notStandardCells) { CreateVar job = new CreateVar(standardCells, notStandardCells); job.startJob(); } /** * Mark the cell as a standard cell * @param standardCells a list of Cells to mark with the standard cell attribute marker. * @param notStandardCells a list of Cells to remove the standard cell attribute marker. */ public static void markStandardCell(List<Cell> standardCells, List<Cell> notStandardCells) { CreateVar job = new CreateVar(standardCells, notStandardCells); job.doIt(); } private static class CreateVar extends Job { private List<Cell> standardCells; private List<Cell> notStandardCells; public CreateVar(List<Cell> standardCells, List<Cell> notStandardCells) { super("Create Var", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER); this.standardCells = standardCells; this.notStandardCells = notStandardCells; } public boolean doIt() { TextDescriptor td = TextDescriptor.getCellTextDescriptor().withInterior(true).withDispPart(TextDescriptor.DispPos.NAMEVALUE); if (standardCells != null) for(Cell cell : standardCells) cell.newVar(STANDARDCELL, new Integer(1), td); if (notStandardCells != null) for(Cell cell : notStandardCells) cell.delVar(STANDARDCELL); return true; } } /** * Return the standard cells in a hierarchy starting from * the specified top cell. * @param topCell the top cell in the hierarchy (sch or lay view) * @return a set of standard cells in the hierarchy */ public static Set<Cell> getStandardCellsInHierarchy(Cell topCell) { StandardCellHierarchy cells = new StandardCellHierarchy(); HierarchyEnumerator.enumerateCell(topCell, VarContext.globalContext, cells); return cells.getStandardCellsInHier(); } /** * Returns true if the cell is marked as a standard cell for Static * Timing Analysis * @param cell the cell to check * @return true if standard cell, false otherwise */ public static boolean isStandardCell(Cell cell) { Cell schcell = cell.getCellGroup().getMainSchematics(); if (schcell != null) cell = schcell; return cell.getVar(STANDARDCELL) != null; } private void prErr(String msg) { System.out.println("Standard Cell Library Generator Error: "+msg); }// private void prWarn(String msg) {// System.out.println("Standard Cell Library Generator Warning: "+msg);// } private void prMsg(String msg) { System.out.println("Standard Cell Library Generator: "+msg); } /****************************** Standard Cell Enumerator *************************/ public static class StandardCellHierarchy extends HierarchyEnumerator.Visitor { private static final Integer standardCell = new Integer(0); private static final Integer containsStandardCell = new Integer(1); private static final Integer doesNotContainStandardCell = new Integer(2); private Map<Cell,Integer> standardCellMap = new HashMap<Cell,Integer>(); private Map<String,Cell> standardCellsByName = new HashMap<String,Cell>(); private List<VarContext> standardCellContexts = new ArrayList<VarContext>(); private Map<VarContext,VarContext> emptyCellContexts = new HashMap<VarContext,VarContext>(); private Map<VarContext,VarContext> containsStandardCellContexts = new HashMap<VarContext,VarContext>(); private boolean nameConflict = false; public boolean enterCell(HierarchyEnumerator.CellInfo info) { Cell cell = info.getCell(); // skip cached and does not contain standard cell // (we want to traverse all hierarchy that contains standard cells // to produce the standard cell contexts list) if (standardCellMap.get(cell) == doesNotContainStandardCell) { emptyCellContexts.put(info.getContext(), info.getContext()); return false; } if (SCLibraryGen.isStandardCell(cell)) { standardCellContexts.add(info.getContext()); if (!standardCellMap.containsKey(cell)) { standardCellMap.put(cell, standardCell); // check for name conflict Cell otherCell = standardCellsByName.get(cell.getName()); if (otherCell != null && otherCell != cell) { System.out.println("Error: multiple standard cells with same name not allowed: "+ cell.libDescribe()+" and "+ otherCell.libDescribe()); nameConflict = true; } else { standardCellsByName.put(cell.getName(), cell); } } return false; } return true; } public void exitCell(HierarchyEnumerator.CellInfo info) { Cell cell = info.getCell(); VarContext context = info.getContext(); for (Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); ) { NodeInst ni = it.next(); if (!ni.isCellInstance()) continue; if (ni.isIconOfParent()) continue; // standard cell tag is on schematic view Cell proto = ni.getProtoEquivalent(); if (proto == null) proto = (Cell)ni.getProto(); if (containsStandardCell(proto) || standardCellMap.get(proto) == standardCell) { standardCellMap.put(cell, containsStandardCell); containsStandardCellContexts.put(context, context); return; } } standardCellMap.put(cell, doesNotContainStandardCell); emptyCellContexts.put(context, context); for (Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); ) { NodeInst ni = it.next(); if (!ni.isCellInstance()) continue; if (ni.isIconOfParent()) continue; Cell proto = ni.getProtoEquivalent(); if (proto == null) proto = (Cell)ni.getProto(); if (standardCellMap.get(proto) == doesNotContainStandardCell) { VarContext nicontext = context.push(ni); emptyCellContexts.remove(nicontext); } } } public boolean visitNodeInst(Nodable ni, HierarchyEnumerator.CellInfo info) { return true; } /** * True if the cell contains standard cells (but false if it does not, * or if it is a standard cell. * @param cell the cell in question * @return true if the clel contains a standard cell, false otherwise. */ public boolean containsStandardCell(Cell cell) { if (standardCellMap.get(cell) == containsStandardCell) return true; return false; } /** * Get the standard cells in the hiearchy after the hierarchy has * been enumerated * @return a set of the standard cells */ public Set<Cell> getStandardCellsInHier() { return getCells(standardCell); } /** * Get the cells that contain standard cells * in the hiearchy after the hierarchy has * been enumerated * @return a set of the cells that contain standard cells */ public Set<Cell> getContainsStandardCellsInHier() { return getCells(containsStandardCell); } /** * Get the cells that do not contain standard cells * in the hiearchy after the hierarchy has * been enumerated * @return a set of the cells that contain standard cells */ public Set<Cell> getDoesNotContainStandardCellsInHier() { return getCells(doesNotContainStandardCell); } /** * Returns true if there was a name conflict, where two standard * cells from different libraries have the same name. * @return true if name conflict exists */ public boolean getNameConflict() { return nameConflict; } public List<VarContext> getStandardCellsContextsInHier() { return standardCellContexts; } public Set<String> getContainsStandardCellContextsInHier() { Set<VarContext> contexts = containsStandardCellContexts.keySet(); Set<String> sorted = new TreeSet<String>(); for (VarContext context : contexts) { String s = context.getInstPath("/"); sorted.add(s); } return sorted; } /** * Get the contexts of cells that do not contain standard cells * in the hierarchy. This set is minimal. * @return a set of var contexts */ public Set<String> getEmptyCellContextsInHier() { Set<VarContext> contexts = emptyCellContexts.keySet(); Set<String> sorted = new TreeSet<String>(); for (VarContext context : contexts) { String s = context.getInstPath("/"); sorted.add(s); } return sorted; } /** * Get cells of the given type. The type is one of * Type.StandardCell * Type.ContainsStandardCell * Type.DoesNotContainStandardCell * @param type the type of cells to get * @return a set of cells */ private Set<Cell> getCells(Integer type) { TreeSet<Cell> set = new TreeSet<Cell>(); for (Map.Entry<Cell,Integer> entry : standardCellMap.entrySet()) { if (entry.getValue() == type) set.add(entry.getKey()); } return set; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -