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

📄 edifequiv.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                String portDef = portsList.substring(last, i);                last = i+1;                Port port = parsePort(portDef, lineno);                if (port != null) ports.add(port);            }        }        // last one does not have trailing comma        if (last < i) {            String portDef = portsList.substring(last, i);            Port port = parsePort(portDef, lineno);            if (port != null) ports.add(port);        }        return ports;    }    /**     * String should be of the format (ignore spaces):     * a(x,y)     * @param port     * @return a Port object     */    private Port parsePort(String port, int lineno) {        boolean ignorePort = false;        if (port.trim().equals("NA")) return new Port("NA", new Point2D.Double(0,0), true);        String [] fields = port.split("[(),]");        if (fields.length != 3) {            System.out.println("Expected port format portname(x,y), but got "+port+" on line "+lineno);            return null;        }        double x = 0, y = 0;        try {            x = Double.parseDouble(fields[1]);            y = Double.parseDouble(fields[2]);        } catch (NumberFormatException e) {            System.out.println("Could not convert port coordinate to number: "+port+", on line "+lineno);            return null;        }        String name = fields[0].trim();        if (name.equals("NA")) ignorePort = true;        if (name.equals("\\NA")) name = "NA";        return new Port(fields[0].trim(), new Point2D.Double(x, y), ignorePort);    }    public void print() {        for (NodeEquivalence ne : equivsByNodeProto.values()) {            System.out.println(ne.toString());        }    }    // ==================================================================================    //                            Equivalence Classes    public static class NodeEquivalence {        public final NodeProto np;        public final PrimitiveNode.Function function;        public final PortCharacteristic exortedType;        public final String externalLib;        public final String externalCell;        public final String externalView;        public final List<PortEquivalence> portEquivs;        public final int rotation;         // in degrees, rotate the electric prim by this value to match the cadence prim        public final double xOffset, yOffset;        private NodeEquivalence(NodeProto np, PrimitiveNode.Function func, PortCharacteristic exportedType,                String externalLib, String externalCell, String externalView, int rotation, List<PortEquivalence> portEquivs) {            this.np = np;            this.function = func;            this.exortedType = exportedType;            this.externalLib = externalLib;            this.externalCell = externalCell;            this.externalView = externalView;            this.rotation = rotation;            this.portEquivs = portEquivs;            // figure out offset			double bestXOff = 0, bestYOff = 0;			if (rotation == 0)			{				Map<Double,MutableInteger> xMap = new HashMap<Double,MutableInteger>();				Map<Double,MutableInteger> yMap = new HashMap<Double,MutableInteger>();				for(EDIFEquiv.PortEquivalence pe : portEquivs)				{					Double diffX = new Double(pe.getElecPort().loc.getX() - pe.getExtPort().loc.getX());					MutableInteger xCount = xMap.get(diffX);					if (xCount == null) xMap.put(diffX, xCount = new MutableInteger(0));					xCount.increment();					Double diffY = new Double(pe.getElecPort().loc.getY() - pe.getExtPort().loc.getY());					MutableInteger yCount = yMap.get(diffY);					if (yCount == null) yMap.put(diffY, yCount = new MutableInteger(0));					yCount.increment();				}				int bestXInc = 0;				for(Double diffX : xMap.keySet())				{					MutableInteger xCount = xMap.get(diffX);					if (xCount.intValue() > bestXInc)					{						bestXInc = xCount.intValue();						bestXOff = diffX.doubleValue();					}				}				int bestYInc = 0;				for(Double diffY : yMap.keySet())				{					MutableInteger yCount = yMap.get(diffY);					if (yCount.intValue() > bestYInc)					{						bestYInc = yCount.intValue();						bestYOff = diffY.doubleValue();					}				}			}			xOffset = bestXOff;			yOffset = bestYOff;        }        /**         * Get the PortEquivalence object for the Electric port name.         * @param elecPortName         * @return null if no such port         */        public PortEquivalence getPortEquivElec(String elecPortName) {            for (PortEquivalence pe : portEquivs) {                if (pe.getElecPort().name.equals(elecPortName))                    return pe;            }            return null;        }        /**         * Get the PortEquivalence object for the external node's port name.         * @param extPortName         * @return null if no such port         */        public PortEquivalence getPortEquivExt(String extPortName) {            for (PortEquivalence pe : portEquivs) {                if (pe.getExtPort().name.equals(extPortName))                    return pe;            }            return null;        }        /**         * Get a list of the external ports of this equivalence class         * @return a list of EDIFEquiv.Port objects         */        public List<Port> getExtPorts() {            List<Port> extPorts = new ArrayList<Port>();            for (PortEquivalence pe : portEquivs) {                extPorts.add(pe.getExtPort());            }            return extPorts;        }        public String toString() {            StringBuffer buf = new StringBuffer();            buf.append("NodeEquivalence Elec: "+np.describe(false)+", func: "+function+"\n");            buf.append("  Ext: "+externalLib+" "+externalCell+" "+externalView+"\n");            for (PortEquivalence pe : portEquivs) {                buf.append(pe.toString()+"\n");            }            return buf.toString();        }    }    public static class PortEquivalence {        private final Port elecPort;        private final Port extPort;        private PortEquivalence(Port elecPort, Port extPort) {            this.elecPort = elecPort;            this.extPort = extPort;        }        public Port getElecPort() { return elecPort; }        public Port getExtPort() { return extPort; }        /**         * Translate the location of the electric port to the external port         * @param point the location of the port in Electric.         * @return the location of the port in EDIF.         */        public Point2D translateElecToExt(Point2D point, AffineTransform niPureRotation) {            Point2D elecPoint = new Point2D.Double(elecPort.loc.getX(), elecPort.loc.getY());            Point2D extPoint = new Point2D.Double(extPort.loc.getX(), extPort.loc.getY());            if (niPureRotation != null) {                elecPoint = niPureRotation.transform(elecPort.loc, elecPoint);                extPoint = niPureRotation.transform(extPort.loc, extPoint);            }            return new Point2D.Double(point.getX()-(elecPoint.getX()-extPoint.getX()),                                      point.getY()-(elecPoint.getY()-extPoint.getY()));        }        /**         * Translate the location of the external port to the electric port         * @param point the location of the port in EDIF.         * @return the location of the port in Electric.         */        public Point2D translateExtToElec(Point2D point, AffineTransform niPureRotation) {            Point2D elecPoint = new Point2D.Double(elecPort.loc.getX(), elecPort.loc.getY());            Point2D extPoint = new Point2D.Double(extPort.loc.getX(), extPort.loc.getY());            if (niPureRotation != null) {                elecPoint = niPureRotation.transform(elecPort.loc, elecPoint);                extPoint = niPureRotation.transform(extPort.loc, extPoint);            }            return new Point2D.Double(point.getX()-(elecPoint.getX()-extPoint.getX()),                                      point.getY()-(elecPoint.getY()-extPoint.getY()));        }        public String toString() {            return "PortEquiv Elec{ "+elecPort+" } - Ext{ "+extPort+" }";        }    }    public static class VariableEquivalence {        public final String elecVarName;        public final String externVarName;        public final double scale;        public final String appendElecOutput;        private VariableEquivalence(String elecVarName, String externVarName, double scale, String appendElecOutput) {            this.elecVarName = elecVarName;            this.externVarName = externVarName;            this.scale = scale;            this.appendElecOutput = appendElecOutput;        }    }    public static class FigureGroupEquivalence {        public final String elecFGName;        public final String externFGName;        private FigureGroupEquivalence(String elecFGName, String externFGName) {            this.elecFGName = elecFGName;            this.externFGName = externFGName;        }    }    public static class GlobalEquivalence {        public final String elecGName;        public final String externGName;        private GlobalEquivalence(String elecGName, String externGName) {            this.elecGName = elecGName;            this.externGName = externGName;        }    }    public static class Port {        public final String name;        public final Point2D loc;        public final boolean ignorePort;        private Port(String name, Point2D loc, boolean ignorePort) {            this.name = name;            this.loc = loc;            this.ignorePort = ignorePort;        }        public String toString() {            return name+"("+loc.getX()+","+loc.getY()+")"+(ignorePort?"[ignored]":"");        }    }    /** Unit Test */    public static void mainTest() {        EDIFEquiv eq = new EDIFEquiv();        eq.print();    }}

⌨️ 快捷键说明

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