📄 lenetlister2.java
字号:
protected Iterator<LENodable> getSizeableNodables() { return sizableLENodables.iterator(); } protected float getGlobalSU() { return constants.su; } protected LESizer2 getSizer() { return sizer; } protected float getKeeperRatio() { return constants.keeperRatio; } private LENetwork getNetwork(int globalID, HierarchyEnumerator.CellInfo info) { LENetwork net = globalNetworks.get(new Integer(globalID)); if (net == null) { String name = (info == null) ? null : info.getUniqueNetName(globalID, "."); net = new LENetwork(name); globalNetworks.put(new Integer(globalID), net); } return net; } // ======================= Hierarchy Enumerator ============================== /** * Class to implement the first pass of definitions for all LENodables. * The first pass creates the definitions for all LENodables, and sees which * Cells can be cached (i.e. do not have parameters that need parent context * to evaluate, and do not have sizeable gates in them) */ private static class FirstPassEnum extends HierarchyEnumerator.Visitor { /** LENetlister2 */ private LENetlister2 netlister; private FirstPassEnum(LENetlister2 netlister) { this.netlister = netlister; } /** * Override the default Cell info to pass along logical effort specific information * @return a LECellInfo */ public HierarchyEnumerator.CellInfo newCellInfo() { return new LECellInfo(); } public boolean enterCell(HierarchyEnumerator.CellInfo info) { if (netlister.aborted) return false; if (((LETool.AnalyzeCell)netlister.job).checkAbort(null)) { netlister.aborted = true; return false; } CachedCell cachedCell = netlister.cellMap.get(info.getCell()); if (cachedCell == null) { cachedCell = new CachedCell(info.getCell(), info.getNetlist()); if (netlister.cellMap.containsKey(info.getCell())) System.out.println("Possible hash map conflict in netlister.cellMap!"); netlister.cellMap.put(info.getCell(), cachedCell); if (DEBUG_FIRSTPASS) System.out.println(" === entering "+info.getCell()); return true; } else { // because this cell is already cached, we will not be visiting nodeinsts, // and we will not be calling exit cell. So link into parent here, because // we won't be linking into parent from exit cell. // add this to parent cached cell if any if (DEBUG_FIRSTPASS) System.out.println(" === not entering, using cached version for "+info.getCell()); HierarchyEnumerator.CellInfo parentInfo = info.getParentInfo(); if (parentInfo != null) { Cell parent = info.getParentInfo().getCell(); CachedCell parentCached = netlister.cellMap.get(parent); Nodable no = info.getParentInst(); parentCached.add(no, (LECellInfo)info.getParentInfo(), cachedCell, (LECellInfo)info, netlister.constants); } } return false; } public boolean visitNodeInst(Nodable ni, HierarchyEnumerator.CellInfo info) { CachedCell cachedCell = netlister.cellMap.get(info.getCell()); if (ni.getNodeInst().isCellInstance()) if (DEBUG_FIRSTPASS) System.out.println(" === visiting "+ni.getName()); // see if we can make an LENodable from the nodable LENodable.Type type = netlister.getType(ni, info); if (type == null) return true; // recurse if (type == LENodable.Type.IGNORE) return false; // ignore LENodable leno = netlister.createLENodable(type, ni, info); // if no lenodable, recurse if (leno == null) return true; cachedCell.add(ni, leno); if (netlister.nodablesDefinitions.containsKey(ni)) System.out.println("Possible hash map conflict in netlister.nodablesDefinitions!"); netlister.nodablesDefinitions.put(ni, leno); return false; } public void exitCell(HierarchyEnumerator.CellInfo info) { CachedCell cachedCell = netlister.cellMap.get(info.getCell()); if (DEBUG_FIRSTPASS) System.out.println(" === exiting "+info.getCell()); // add this to parent cached cell if any HierarchyEnumerator.CellInfo parentInfo = info.getParentInfo(); if (parentInfo != null) { Cell parent = info.getParentInfo().getCell(); CachedCell parentCached = netlister.cellMap.get(parent); Nodable no = info.getParentInst(); parentCached.add(no, (LECellInfo)info.getParentInfo(), cachedCell, (LECellInfo)info, netlister.constants); } } protected void cleanup(boolean disableCaching) { // remove all cachedCells that contain sizeable gates or are not context free HashMap<Cell,CachedCell> cachedMap = new HashMap<Cell,CachedCell>(); for (Map.Entry<Cell,CachedCell> entry : netlister.cellMap.entrySet()) { Cell cell = (Cell)entry.getKey(); CachedCell cachedCell = (CachedCell)entry.getValue(); if (cachedCell.isContextFree(netlister.constants)) { cachedMap.put(cell, cachedCell); } } netlister.cellMap = cachedMap; if (disableCaching) netlister.cellMap = new HashMap<Cell,CachedCell>(); } } /** * Override the default Cell info to pass along logical effort specific information * @return a LECellInfo */ public HierarchyEnumerator.CellInfo newCellInfo() { return new LECellInfo(); } /** * Enter cell initializes the LECellInfo. * @param info the LECellInfo * @return true to process the cell, false to ignore. */ public boolean enterCell(HierarchyEnumerator.CellInfo info) { if (aborted) return false; if (((LETool.AnalyzeCell)job).checkAbort(null)) { aborted = true; return false; } LECellInfo leinfo = (LECellInfo)info; leinfo.leInit(constants); // check if conflicting settings if (topLevelCell != info.getCell()) { if (isSettingsConflict(leinfo.getSettings(), topLevelCell, info.getContext(), info.getCell())) { aborted = true; return false; } } boolean enter = true; // if there is a cachedCell, do not enter CachedCell cachedCell = cellMap.get(info.getCell()); // if this was a cached cell, link cached networks into global network // note that a cached cell cannot by definition contain sizeable LE gates if ((cachedCell != null) && (leinfo.getMFactor() == 1f)) { for (Map.Entry<Network,LENetwork> entry : cachedCell.getLocalNetworks().entrySet()) { Network jnet = (Network)entry.getKey(); LENetwork subnet = (LENetwork)entry.getValue(); int globalID = info.getNetID(jnet); LENetwork net = (LENetwork)getNetwork(globalID, info); if (net == null) continue; net.add(subnet); if (DEBUG) { if (net.getName().equals("vdd")) continue; if (net.getName().equals("gnd")) continue; System.out.println(" Added to global net "+net.getName() +" "+subnet.getName()+" from "+info.getCell().describe(false)); System.out.println(" subcell="+info.getCell().describe(false)+" subnet="+subnet.getName()+": "); subnet.print(); System.out.println(" result: global net="+net.getName()+": "); net.print(); } } //for (Iterator it = cachedCell.getAllCachedNodables().iterator(); it.hasNext(); ) { // allLENodables.add(it.next()); //} enter = false; } return enter; } /** * Visit NodeInst creates a new Logical Effort instance from the * parameters found on the Nodable, if that Nodable is an LEGATE. * It also creates instances for wire models (LEWIREs). * @param ni the Nodable being visited * @param info the cell info * @return true to push down into the Nodable, false to continue. */ public boolean visitNodeInst(Nodable ni, HierarchyEnumerator.CellInfo info) { LECellInfo leinfo = (LECellInfo)info; LENodable def = nodablesDefinitions.get(ni); if (def == null) return true; else { // create hierarchical unique instance from definition LENetwork outputNet = null; if (def.isLeGate()) { // get global output network Network outNet = def.getOutputNet(); int globalID = info.getNetID(outNet); outputNet = getNetwork(globalID, info); } float localsu = constants.su; if (leinfo.getSU() != -1f) localsu = leinfo.getSU(); LENodable uniqueLeno = def.createUniqueInstance(info.getContext(), outputNet, leinfo.getMFactor(), localsu, constants); if (uniqueLeno.isLeGate()) sizableLENodables.add(uniqueLeno); allLENodables.add(uniqueLeno); // add pins to global networks for (LEPin pin : uniqueLeno.getPins()) { int globalID = info.getNetID(pin.getNetwork()); LENetwork net = getNetwork(globalID, info); net.add(pin); } //uniqueLeno.print(); //uniqueLeno.printPins(); } return false; } public void doneVisitNodeInst(Nodable ni, HierarchyEnumerator.CellInfo info) {} /** * Nothing to do for exitCell */ public void exitCell(HierarchyEnumerator.CellInfo info) { } /** * Logical Effort Cell Info class. Keeps track of: * <p>- M factors */ public static class LECellInfo extends LENetlister.LECellInfo { /** the cached cell */ private CachedCell cachedCell; protected void setCachedCell(CachedCell c) { cachedCell = c; } protected CachedCell getCachedCell() { return cachedCell; } } /** * Get the LENodable type of this Nodable. If it is not a valid type, return null. * @param ni the Nodable to examine * @param info the current info * @return the LENodable type, or null if not an LENodable */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -