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

📄 epicanalysis.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                l = 4;            }            while (l > 0) {                b = (b << 8) | packedWaveform[i++] & 0xff;                l--;            }            v = v + b;            value[count] = v * valueResolution;        }        assert count == time.length;        return new Waveform[] { new WaveformImpl(time, value) };    }        /************************* EpicRootTreeNode *********************************************     * This class is for root node of EpicTreeNode tree.     * It contains children from rootContext of specified EpicAnalysis.     */    private static class EpicRootTreeNode extends DefaultMutableTreeNode {        /** EpicAnalysis which owns the tree. */    private EpicAnalysis an;                /**         * Private constructor.         * @param an specified EpicAnalysy.         * @paran name name of bwq EpicRootTreeNode         */        private EpicRootTreeNode(EpicAnalysis an, String name) {            super(name);            this.an = an;            Vector<EpicTreeNode> children = new Vector<EpicTreeNode>();//    		// make a list of signal names with "#" in them//    		Map<String,DefaultMutableTreeNode> sharpMap = new HashMap<String,DefaultMutableTreeNode>();//            for (EpicTreeNode tn: an.rootContext.sortedNodes)//    		{//    			String sigName = tn.name;//    			int hashPos = sigName.indexOf('#');//    			if (hashPos <= 0) continue;//    			String sharpName = sigName.substring(0, hashPos);//    			DefaultMutableTreeNode parent = sharpMap.get(sharpName);//    			if (parent == null)//    			{//    				parent = new DefaultMutableTreeNode(sharpName + "#");//    				sharpMap.put(sharpName, parent);//    				this.add(parent);//    			}//    		}////    		// add all signals to the tree//            for (EpicTreeNode tn: an.rootContext.sortedNodes)//    		{//    			String nodeName = null;//    			String sigName = tn.name;//    			int hashPos = sigName.indexOf('#');//    			if (hashPos > 0)//    			{//    				// force a branch with the proper name//    				nodeName = sigName.substring(0, hashPos);//    			} else//    			{//    				// if this is the pure name of a hash set, force a branch//    				String pureSharpName = sigName;//    				if (sharpMap.get(pureSharpName) != null)//    					nodeName = pureSharpName;//    			}//    			if (nodeName != null)//    			{//    				DefaultMutableTreeNode parent = sharpMap.get(nodeName);//    				parent.add(new DefaultMutableTreeNode(tn));//    			} else//    			{//                    children.add(tn);//    			}//    		}            for (EpicTreeNode tn: an.rootContext.sortedNodes)                children.add(tn);            this.children = children;        }        /**         * Returns the index of the specified child in this node's child array.         * If the specified node is not a child of this node, returns         * <code>-1</code>.  This method performs a linear search and is O(n)         * where n is the number of children.         *         * @param	aChild	the TreeNode to search for among this node's children         * @exception	IllegalArgumentException	if <code>aChild</code>         *							is null         * @return	an int giving the index of the node in this node's child         *          array, or <code>-1</code> if the specified node is a not         *          a child of this node         */        public int getIndex(TreeNode aChild) {            try {                EpicTreeNode tn = (EpicTreeNode)aChild;                if (getChildAt(tn.sortedIndex) == tn)                    return tn.sortedIndex;            } catch (Exception e) {                if (aChild == null)                    throw new IllegalArgumentException("argument is null");            }            return -1;        }    }        /************************* Context *********************************************     * This class denotes a group of siignals. It may have a few instance in signal tree.     */    static class Context {        /**         * Type of context.         * it is nonzero for leaf context and it is zero for non-leaf contexts.         */        private final byte type;        /**         * Hash code of this Context         */        private final int hashCode;        /**         * Nodes of this Context in chronological order.         */        private final EpicTreeNode[] nodes;        /**         * Nodes of this Context sorted by type and name.         */        private final EpicTreeNode[] sortedNodes;        /**         * Flat number of signals in tree whose root is this context.         */        private final int treeSize;                /**         * Map from name of subcontext to EpicTreeNode.         */        private final HashMap<String,EpicTreeNode> subs = new HashMap<String,EpicTreeNode>();        /**         * Map from name of leaf npde to EpicTreeNode.         */        private final HashMap<String,EpicTreeNode> sigs = new HashMap<String,EpicTreeNode>();         /**         * Constructor of leaf fake context.         */        private Context(byte type) {            assert type != 0;            this.type = type;            assert isLeaf();            hashCode = type;            nodes = null;            sortedNodes = null;            treeSize = 1;        }                /**         * Constructor of real context.         * @param names list of names.         * @param contexts list of contexts.         * @param hashCode precalculated hash code of new Context.         */        private Context(ArrayList<String> names, ArrayList<Context> contexts, int hashCode) {            assert names.size() == contexts.size();            type = 0;            this.hashCode = hashCode;            nodes = new EpicTreeNode[names.size()];            int treeSize = 0;            for (int i = 0; i < nodes.length; i++) {                String name = names.get(i);                Context subContext = contexts.get(i);                EpicTreeNode tn = new EpicTreeNode(i, name, subContext,treeSize);                nodes[i] = tn;                String canonicName = TextUtils.canonicString(name);                if (subContext.isLeaf())                    sigs.put(canonicName, tn);                else                    subs.put(canonicName, tn);                treeSize += subContext.treeSize;            }            sortedNodes = nodes.clone();            Arrays.sort(sortedNodes, TREE_NODE_ORDER);            for (int i = 0; i < sortedNodes.length; i++)                sortedNodes[i].sortedIndex = i;            this.treeSize = treeSize;        }                /**         * Returns true if this context is fake leaf context.         * @return true if this context is fake leaf context.         */        boolean isLeaf() { return type != 0; }                /**         * Returns true if contenst of this Context is equal to specified lists.         * @returns true if contenst of this Context is equal to specified lists.         */        private boolean equals(ArrayList<String> names, ArrayList<Context> contexts) {            int len = nodes.length;            if (names.size() != len || contexts.size() != len) return false;            for (int i = 0; i < len; i++) {                EpicTreeNode tn = nodes[i];                if (names.get(i) != tn.name || contexts.get(i) != tn.context) return false;            }            return true;        }                /**         * Returns hash code of this Context.         * @return hash code of this Context.         */        public int hashCode() { return hashCode; }                /**         * Private method to calculate hash code.         * @param names list of names.         * @param contexts list of contexts.         * @return hash code         */        private static int hashValue(ArrayList<String> names, ArrayList<Context> contexts) {            assert names.size() == contexts.size();            int hash = 0;            for (int i = 0; i < names.size(); i++)                hash = hash * 19 + names.get(i).hashCode()^contexts.get(i).hashCode();            return hash;        }                /**         * Searches an EpicTreeNode in this context where signal with specified flat offset lives.         * @param offset flat offset of EpicSignal.         * @return index of EpicTreeNode in this Context or -1.         */        private int localSearch(int offset) {            assert offset >= 0 && offset < treeSize;            assert nodes.length > 0;            int l = 1;            int h = nodes.length - 1;            while (l <= h) {                int m = (l + h) >> 1;                if (nodes[m].nodeOffset <= offset)                    l = m + 1;                else                    h = m - 1;            }            return h;        }    }        /************************* EpicTreeNode *********************************************     * This class denotes an element of a Context.     * It partially implements TreeNode (without getParent).     */    public static class EpicTreeNode implements TreeNode {//        private final int chronIndex;        private final String name;        private final Context context;        private final int nodeOffset;        private int sortedIndex;        /**         * Private constructor.         */        private EpicTreeNode(int chronIndex, String name, Context context, int nodeOffset) {//            this.chronIndex = chronIndex;            this.name = name;            this.context = context;            this.nodeOffset = nodeOffset;        }                /**         * Returns the child <code>TreeNode</code> at index         * <code>childIndex</code>.         */        public TreeNode getChildAt(int childIndex) {            try {                return context.sortedNodes[childIndex];            } catch (NullPointerException e) {                throw new ArrayIndexOutOfBoundsException("node has no children");            }        }                /**         * Returns the number of children <code>TreeNode</code>s the receiver         * contains.         */        public int getChildCount() {            return isLeaf() ? 0 : context.sortedNodes.length;        }                /**         * Returns the parent <code>TreeNode</code> of the receiver.         */        public TreeNode getParent() {            throw new UnsupportedOperationException();        }                /**         * Returns the index of <code>node</code> in the receivers children.         * If the receiver does not contain <code>node</code>, -1 will be         * returned.         */        public int getIndex(TreeNode node) {            try {                EpicTreeNode tn = (EpicTreeNode)node;                if (context.nodes[tn.sortedIndex] == tn)                    return tn.sortedIndex;            } catch (Exception e) {                if (node == null)                    throw new IllegalArgumentException("argument is null");            }            return -1;        }                /**         * Returns true if the receiver allows children.         */        public boolean getAllowsChildren() { return !isLeaf(); }                /**         * Returns true if the receiver is a leaf.         */        public boolean isLeaf() { return context.type != 0; }                /**         * Returns the children of the receiver as an <code>Enumeration</code>.         */        public Enumeration children() {            if (isLeaf())                return DefaultMutableTreeNode.EMPTY_ENUMERATION;            return new Enumeration<EpicTreeNode>() {                int count = 0;                                public boolean hasMoreElements() {                    return count < context.nodes.length;                }                                public EpicTreeNode nextElement() {                    if (count < context.nodes.length)                        return context.nodes[count++];                    throw new NoSuchElementException("Vector Enumeration");                }            };        }                public String toString() { return name; }    }        /**     * Comparator which compares EpicTreeNodes by type and by name.     */    private static Comparator<EpicTreeNode> TREE_NODE_ORDER = new Comparator<EpicTreeNode>() {              public int compare(EpicTreeNode tn1, EpicTreeNode tn2) {            int cmp = tn1.context.type - tn2.context.type;            if (cmp != 0) return cmp;            return TextUtils.STRING_NUMBER_ORDER.compare(tn1.name, tn2.name);        }    };        /************************* EpicSignal *********************************************     * Class which represents Epic AnalogSignal.     */    static class EpicSignal extends AnalogSignal {                EpicSignal(EpicAnalysis an, byte type, int index) {            super(an);            assert getIndexInAnalysis() == index;            if (type == VOLTAGE_TYPE)                an.voltageSignals.set(index);            else                assert type == CURRENT_TYPE;        }                /**         * Method to return the context of this simulation signal.         * The context is the hierarchical path to the signal, and it usually contains         * instance names of cells farther up the hierarchy, all separated by dots.         * @param signalContext the context of this simulation signal.         */        @Override        public void setSignalContext(String signalContext) { throw new UnsupportedOperationException(); }                /**         * Method to return the context of this simulation signal.         * The context is the hierarchical path to the signal, and it usually contains         * instance names of cells farther up the hierarchy, all separated by dots.         * @return the context of this simulation signal.         * If there is no context, this returns null.         */        @Override        public String getSignalContext() {            return ((EpicAnalysis)getAnalysis()).makeName(getIndexInAnalysis(), false);        }                /**         * Method to return the full name of this simulation signal.         * The full name includes the context, if any.         * @return the full name of this simulation signal.         */        @Override        public String getFullName() {            return ((EpicAnalysis)getAnalysis()).makeName(getIndexInAnalysis(), true);        }                void setBounds(int minV, int maxV) {            EpicAnalysis an = (EpicAnalysis)getAnalysis();            double resolution = an.getValueResolution(getIndexInAnalysis());            bounds = new Rectangle2D.Double(0, minV*resolution, an.maxTime, (maxV - minV)*resolution);            leftEdge = 0;            rightEdge = minV*resolution;        }    }}

⌨️ 快捷键说明

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