⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hierarchyenumerator.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		/** Get the CellInfo for the root Cell */		public final CellInfo getRootInfo() {			CellInfo i = this;			while (i.getParentInfo()!=null)  i = i.getParentInfo();			return i;		}		/** Get netIDs for the Export: e.		 * @return an array of net numbers. */		public final int[] getExportNetIDs(Export e) {			if (isRootCell()) {				// exportNdxToNetIDs is invalid for the root Cell because				// no mapping from net index to netID is performed for Exports				// of the root Cell.				int width = netlist.getBusWidth(e);				int[] netIDs = new int[width];				for (int i=0; i<width; i++) {					netIDs[i] = netlist.getNetwork(e, i).getNetIndex();				}				return netIDs;			}			return exportNdxToNetIDs[e.getPortIndex() + 1];		}		/** Map any net inside the current cell to a net		 * number. During the course of the traversal, all nets that		 * map to the same net number are connected. Nets that map to		 * different net numbers are disconnected.		 *		 * <p>If you want to generate a unique name for the net use		 * getUniqueNetName().		 */		public final int getNetID(Network net) {			return getNetID(net.getNetIndex());		}		/** Map a net index from the current cell to a net ID.		 * number. During the course of the traversal, all nets that		 * map to the same net number are connected. Nets that map to		 * different net numbers are disconnected.		 * @param netIndex net index within current cell		 * @return net ID that is unique over entire net list.		 */		private int getNetID(int netIndex) {			return netNdxToNetID[netIndex];		}//		public final boolean isGlobalNet(int netID) {//			error(netID<0, "negative netIDs are illegal");//			return netID <= largestGlobalNetID;//		}		/**		 * Get the set of netIDs that are connected to the specified port of		 * the specified Nodable.		 */		public final int[] getPortNetIDs(Nodable no, PortProto pp) {			return HierarchyEnumerator.getPortNetIDs(no, pp, netlist,													 netNdxToNetID);		}        /** Get a unique, flat net name for the network.  The network         * name will contain the hierarchical context as returned by         * VarContext.getInstPath() if it is not a top-level network.         * @param sep the context separator to use if needed.         * @return a unique String identifier for the network */        public final String getUniqueNetName(Network net, String sep) {        	NameProxy proxy = getUniqueNetNameProxy(net, sep);        	return proxy.toString();        }        /** Same as getUniqueNetName except it returns a NameProxy instead of a         * String name */		public final NetNameProxy getUniqueNetNameProxy(Network net, String sep) {			return getUniqueNetNameProxy(getNetID(net), sep);		}		/** Get a unique, flat net name for the network.  The network		 * name will contain the hierarchical context as returned by		 * VarContext.getInstPath() if it is not a top-level network.		 * @param sep the hierarchy separator to use if needed.		 * @return a unique String identifier for the network */		public final String getUniqueNetName(int netID, String sep) {  			NameProxy proxy = getUniqueNetNameProxy(netID, sep);  			return proxy.toString();        }		/** Same as getUniqueNetName except it returns a NameProxy instead of a		 * String name */		public final NetNameProxy getUniqueNetNameProxy(int netID, String sep) {			NetDescription ns = netIdToNetDesc.get(netID);			VarContext netContext = ns.getCellInfo().getContext();//			String leafName;//			Iterator it = ns.getNet().getNames();//			if (it.hasNext()) {//				leafName = (String) it.next();//			} else {//				leafName = "netID"+netID;//			}			return new NetNameProxy(netContext, sep, ns.getNet());		}        /** Get a unique, flat instance name for the Nodable.         * @param no         * @param sep the hierarchy separator to use if needed         * @return a unique String identifer for the Nodable */        public final String getUniqueNodableName(Nodable no, String sep) {        	return getUniqueNodableNameProxy(no, sep).toString();        }		/** Same as getUniqueNodableName except that it returns a NameProxy		 *  instead of a String name. */		public final NodableNameProxy getUniqueNodableNameProxy(Nodable no, String sep) {			return new NodableNameProxy(getContext(), sep, no);		}		/** Get the Network that is closest to the root in the design		 * hierarchy that corresponds to netID. */		public final NetDescription netIdToNetDescription(int netID) {			return netIdToNetDesc.get(netID);		}        /**         * Get the Network in the parent that connects to the specified         * Network in this cell.  Returns null if no network in parent connects         * to this network (i.e. network is not connected to export), or null         * if no parent.         * @param network the network in this cell         * @return the network in the parent that connects to the         * specified network, or null if no such network.         */        public Network getNetworkInParent(Network network) {            if (parentInfo == null) return null;			if (network == null) return null;			if (network.getNetlist() != netlist) return null;            return parentInfo.getNetlist().getNetwork(context.getNodable(), network);//            // find export on network//            boolean found = false;//            Export export = null;//            int i = 0;//            for (Iterator<Export> it = cell.getExports(); it.hasNext(); ) {//                export = it.next();//                for (i=0; i<export.getNameKey().busWidth(); i++) {//                    Network net = netlist.getNetwork(export, i);//                    if (net == network) { found = true; break; }//                }//                if (found) break;//            }//            if (found) {//                // find corresponding port on icon//                //System.out.println("In "+cell.describe()+" JNet "+network.describe()+" is exported as "+export.getName()+"; index "+i);//                Nodable no = context.getNodable();//                PortProto pp = no.getProto().findPortProto(export.getNameKey());//                //System.out.println("Found corresponding port proto "+pp.getName()+" on cell "+no.getProto().describe());//                // find corresponding network in parent//                Network parentNet = parentInfo.getNetlist().getNetwork(no, pp, i);//                return parentNet;//            }//            // check if global network//            Global.Set globals = netlist.getGlobals();//            for (i=0; i<globals.size(); i++) {//                Global global = globals.get(i);//                if (netlist.getNetwork(global) == network) {//                    // it is a global, return the global network in the parent//                    return parentInfo.getNetlist().getNetwork(global);//                }//            }//            return null;        }        /**         * Method to get the transformation from the current location to the root.         * If this is at the top cell, the transformation is identity.         * @return the transformation from the current location to the root.         */        public AffineTransform getTransformToRoot() { return xformToRoot; }    }	// ----------------------- public methods --------------------------	/** Begin enumeration of the contents of the Cell root.  You MUST	 * call rebuildNetworks() on the root Cell before calling	 * beginEnumeration().	 * @param root the starting point of the enumeration.	 * @param context the VarContext for evaluating parameters in Cell	 * root. If context is null then VarContext.globalContext is used.	 * @param visitor the object responsible for doing something useful	 * during the enumertion of the design hierarchy. *///	public static void enumerateCell(Cell root, VarContext context,//	                                 Netlist netlist, Visitor visitor) {//		if (netlist == null) netlist = NetworkTool.getUserNetlist(root);//		(new HierarchyEnumerator()).doIt(root, context, netlist, visitor, false, false, false, false);//	}	public static void enumerateCell(Cell root, VarContext context, Visitor visitor) {        enumerateCell(root, context, visitor, Netlist.ShortResistors.NO);	}	public static void enumerateCell(Cell root, VarContext context, Visitor visitor, Netlist.ShortResistors shortResistors) {        enumerateCell(NetworkTool.getNetlist(root, shortResistors), context, visitor);	}	public static void enumerateCell(Netlist rootNetlist, VarContext context, Visitor visitor) {        enumerateCell(rootNetlist, context, visitor, false);	}	/** Experimental. Optionally caches results of variable evaluation. */	public static void enumerateCell(Netlist rootNetlist, VarContext context,  Visitor visitor, boolean caching) {        Netlist.ShortResistors shortResistors = rootNetlist.getShortResistors();		(new HierarchyEnumerator()).doIt(rootNetlist.getCell(), context, rootNetlist, visitor, caching);	}    /**     * Method to count number of unique cells in hierarchy.  Useful     * for progress tracking of hierarchical netlisters and writers.     */    public static int getNumUniqueChildCells(Cell cell) {        HashMap<Cell,Cell> uniqueChildCells = new HashMap<Cell,Cell>();        hierCellsRecurse(cell, uniqueChildCells);        return uniqueChildCells.size();    }    /** Recursive method used to traverse down hierarchy */    private static void hierCellsRecurse(Cell cell, HashMap<Cell,Cell> uniqueCells) {        for (Iterator<CellUsage> uit = cell.getUsagesIn(); uit.hasNext();) {            CellUsage u = uit.next();            Cell subCell = u.getProto();            if (subCell.isIcon()) continue;            uniqueCells.put(subCell, subCell);            hierCellsRecurse(subCell, uniqueCells);        }    }    /**     * Get the Network in the childNodable that corresponds to the Network in the childNodable's     * parent cell.     * @param parentNet the network in the parent     * @param childNodable the child nodable.     * @return the network in the child that connects to the network in the parent, or     * null if no such network.     */    public static Network getNetworkInChild(Network parentNet, Nodable childNodable) {        if (childNodable == null || parentNet == null) return null;        if (!childNodable.isCellInstance()) return null;        Cell childCell = (Cell)childNodable.getProto();		Netlist parentNetlist = parentNet.getNetlist();		Netlist childNetlist = parentNetlist.getNetlist(childNodable);        PortProto pp = null;        int i = 0;        boolean found = false;        NodeInst ni = childNodable.getNodeInst();        // find port and index on nodable that is connected to parentNet        for (Iterator<PortInst> it = ni.getPortInsts(); it.hasNext(); ) {            PortInst pi = it.next();            pp = pi.getPortProto();            for (i=0; i<pp.getNameKey().busWidth(); i++) {                Network net = parentNetlist.getNetwork(childNodable, pp, i);//                Network net = childNodable.getParent().getUserNetlist().getNetwork(childNodable, pp, i);                if (net == parentNet) { found = true; break; }            }            if (found) break;        }        if (!found) return null;        // find corresponding export in child        if (childCell.contentsView() != null)            childCell = childCell.contentsView();        Export export = childCell.findExport(pp.getNameKey());        Network childNet = childNetlist.getNetwork(export, i);//        Network childNet = childCell.getUserNetlist().getNetwork(export, i);        return childNet;    }    /**     * Method to search if child network is connected to visitor network (visitorNet).     * Used in Quick.java and Connection.java.     */    public static boolean searchNetworkInParent(Network net, CellInfo info,                                                Network visitorNet)    {        if (visitorNet == net) return true;        CellInfo cinfo = info;        while (net != null && cinfo.getParentInst() != null) {            net = cinfo.getNetworkInParent(net);            if (visitorNet == net) return true;            cinfo = cinfo.getParentInfo();        }        return false;    }    public static boolean searchInExportNetwork(Network net, CellInfo info,                                                Network visitorNet)    {        boolean found = false;        for (Iterator<Export> it = net.getExports(); !found && it.hasNext();)        {            Export exp = it.next();            Network tmpNet = info.getNetlist().getNetwork(exp, 0);            found = searchNetworkInParent(tmpNet, info, visitorNet);        }        return found;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -