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

📄 edifequiv.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: EDIFEquiv.java * * Copyright (c) 2005 Sun Microsystems and Static Free Software * * Electric(tm) is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Electric(tm) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Electric(tm); see the file COPYING.  If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. */package com.sun.electric.tool.io.output;import com.sun.electric.database.geometry.Orientation;import com.sun.electric.database.geometry.GenMath.MutableInteger;import com.sun.electric.database.hierarchy.Export;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.prototype.NodeProto;import com.sun.electric.database.prototype.PortCharacteristic;import com.sun.electric.database.prototype.PortProto;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.topology.PortInst;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.Technology;import com.sun.electric.technology.technologies.Schematics;import com.sun.electric.tool.io.IOTool;import java.awt.geom.AffineTransform;import java.awt.geom.Point2D;import java.io.BufferedReader;import java.io.File;import java.io.FileReader;import java.io.IOException;import java.util.ArrayList;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.regex.Matcher;import java.util.regex.Pattern;/** * Reads in a configuration file that specifies the equivalent Electric nodes for Nodes * found in (or to be written to) the EDIF file.  This allows mapping of Electric primitives * and Cells to primitives and cells in the target Tool which will read in the EDIF, or vice versa. * Most importantly, it specifies equivalences between ports on the two nodes which may be in * different locations.  Differing sizes of nodes does not matter. * <P> * This is currently only being used with Cadence Virtuoso Composer. */public class EDIFEquiv {    private HashMap<Object,NodeEquivalence> equivsByNodeProto;      // key: Electric hash (getElectricKey()), value: NodeEquivalence    private HashMap<Object,NodeEquivalence> equivsByExternal;       // key: External hash (getExternalKey()), value: NodeEquivalence    private HashMap<String,VariableEquivalence> exportByVariable;       // key: External hash (electric varname), value: VariableEquivalence    private HashMap<String,VariableEquivalence> exportFromVariable;     // key: External hash (external varname), value: VariableEquivalence    private HashMap<String,FigureGroupEquivalence> exportByFigureGroup;    // key: External hash (electric figureGroupName), value: FigureGroupEquivalence    private HashMap<String,FigureGroupEquivalence> exportFromFigureGroup;  // key: External hash (external figureGroupName), value: FigureGroupEquivalence    private HashMap<String,GlobalEquivalence> exportByGlobal;    		// key: External hash (electric figureGroupName), value: GlobalEquivalence    private HashMap<String,GlobalEquivalence> exportFromGlobal;  		// key: External hash (external figureGroupName), value: GlobalEquivalence    /**     * Get the node equivalence for the NodeInst.  This must be a NodeInst, not a     * NodeProto, because different transistor primitives share the same Primitive     * prototype.     * @param ni the NodeInst to look up     * @return null if none found     */    public NodeEquivalence getNodeEquivalence(NodeInst ni) {        NodeProto np = ni.getProto();        PrimitiveNode.Function func = np.getFunction();        PortCharacteristic exportType = null;        if (!ni.isCellInstance()) {            PrimitiveNode pn = (PrimitiveNode)np;            func = pn.getTechnology().getPrimitiveFunction(pn, ni.getTechSpecific());            // if this is an off page node and one of it's ports is exported, find out type            if (np == Schematics.tech().offpageNode) {                for (Iterator<PortProto> it = ni.getParent().getPorts(); it.hasNext(); ) {                    Export e = (Export)it.next();                    if (e.getOriginalPort().getNodeInst() == ni) {                        exportType = e.getCharacteristic();                        break;                    }                }            }        }        return equivsByNodeProto.get(getElectricKey(np, func, exportType));    }	/**	 * Method to get the VariableEquivalence that maps Electric variable names to external names.	 * @param varName the Electric variable name.	 * @return the VariableEquivalence that tells how to do the mapping (null if none).	 */	public VariableEquivalence getElectricVariableEquivalence(String varName)	{		VariableEquivalence ve = exportByVariable.get(varName);		return ve;	}	/**	 * Method to get the VariableEquivalence that maps external variable names to Electric names.	 * @param varName the external variable name.	 * @return the VariableEquivalence that tells how to do the mapping (null if none).	 */	public VariableEquivalence getExternalVariableEquivalence(String varName)	{		VariableEquivalence ve = exportFromVariable.get(varName);		return ve;	}	/**	 * Method to get the FigureGroupEquivalence that maps Electric figuregroup names to external names.	 * @param fgName the Electric figuregroup name.	 * @return the FigureGroupEquivalence that tells how to do the mapping (null if none).	 */	public FigureGroupEquivalence getElectricFigureGroupEquivalence(String fgName)	{		FigureGroupEquivalence fge = exportByFigureGroup.get(fgName);		return fge;	}	/**	 * Method to get the FigureGroupEquivalence that maps external figuregroup names to Electric names.	 * @param fgName the external figuregroup name.	 * @return the FigureGroupEquivalence that tells how to do the mapping (null if none).	 */	public FigureGroupEquivalence getExternalFigureGroupEquivalence(String fgName)	{		FigureGroupEquivalence fge = exportFromFigureGroup.get(fgName);		return fge;	}	/**	 * Method to get the GlobalEquivalence that maps Electric global names to external names.	 * @param gName the Electric global name.	 * @return the GlobalEquivalence that tells how to do the mapping (null if none).	 */	public GlobalEquivalence getElectricGlobalEquivalence(String gName)	{		GlobalEquivalence ge = exportByGlobal.get(gName);		return ge;	}	/**	 * Method to get the GlobalEquivalence that maps external global names to Electric names.	 * @param gName the external global name.	 * @return the GlobalEquivalence that tells how to do the mapping (null if none).	 */	public GlobalEquivalence getExternalGlobalEquivalence(String gName)	{		GlobalEquivalence ge = exportFromGlobal.get(gName);		return ge;	}	/**     * Get the node equivalence for the external reference.     * @param extLib     * @param extCell     * @param extView     * @return  null if none found     */    public NodeEquivalence getNodeEquivalence(String extLib, String extCell, String extView) {        Object key = getExternalKey(extLib, extCell, extView);        return equivsByExternal.get(key);    }    /**     * Get a list of NodeEquivalences     * @return  a list of NodeEquivalence objects     */    public List<NodeEquivalence> getNodeEquivs() {        return new ArrayList<NodeEquivalence>(equivsByExternal.values());    }    /**     * Translate a port location on an Electric node to a the equivalent port     * location on the equivalent external node instance.     * @param connPoint the electric connection point     * @param pi the port inst     * @return the connection point on the equivalent external node instance     */    public Point2D translatePortConnection(Point2D connPoint, PortInst pi) {        NodeInst ni = pi.getNodeInst();        NodeEquivalence equiv = getNodeEquivalence(ni);        if (equiv == null) return connPoint;        PortEquivalence pe = equiv.getPortEquivElec(pi.getPortProto().getName());        if (pe == null) return connPoint;        AffineTransform af2 = ni.getOrient().concatenate(Orientation.fromAngle(-equiv.rotation*10)).pureRotate();        return pe.translateElecToExt(connPoint, af2);    }    /**     * Translate a port location on an external node instance to the equivalent     * port location on the equivalent Electric node instance     * @param connPoint the connection point on the external node instance     * @param externalLib the external node's library     * @param externalCell the external node     * @param externalView the external node's view     * @param externalPort the external node's port in question     * @return the connection point on the equivalent electric node instance     */    public Point2D translatePortConnection(Point2D connPoint, String externalLib, String externalCell,                                           String externalView, String externalPort, String orientation) {        NodeEquivalence equiv = getNodeEquivalence(externalLib, externalCell, externalView);        if (equiv == null) return connPoint;        PortEquivalence pe = equiv.getPortEquivExt(externalPort);        if (pe == null) return connPoint;        int angle = 0;        boolean mirroredAboutXAxis = false;        boolean mirroredAboutYAxis = false;        if (orientation.indexOf("R90") != -1) angle = 900;        if (orientation.indexOf("R180") != -1) angle = 1800;        if (orientation.indexOf("R270") != -1) angle = 2700;        if (orientation.indexOf("MX") != -1) mirroredAboutXAxis = true;        if (orientation.indexOf("MY") != -1) mirroredAboutYAxis = true;        Orientation orient = Orientation.fromJava(angle, mirroredAboutYAxis, mirroredAboutXAxis);        orient = orient.concatenate(Orientation.fromAngle(equiv.rotation*10));        AffineTransform af2 = orient.pureRotate();        Point2D ret = pe.translateExtToElec(connPoint, af2);        if (equiv.xOffset != 0 || equiv.yOffset != 0)        	ret = new Point2D.Double(ret.getX()+equiv.xOffset, ret.getY()+equiv.yOffset);        return ret;    }    // hash map key    private Object getElectricKey(NodeProto np, PrimitiveNode.Function func, PortCharacteristic portType) {        if (func == null) func = PrimitiveNode.Function.UNKNOWN;        if (portType == null) portType = PortCharacteristic.UNKNOWN;        return np.getName() + " " + func.toString() + " " + portType.getName();    }    // hash map key    private Object getExternalKey(String externalLib, String externalCell, String externalView) {        return externalLib + " " + externalCell + " " + externalView;    }    // size of elecPorts and extPorts lists must be equal    private void addNodeEquiv(NodeProto np, PrimitiveNode.Function func, PortCharacteristic exportType, int rot,                         String extLib, String extCell, String extView, List<Port> elecPorts, List<Port> extPorts) {        List<PortEquivalence> portEquivs = new ArrayList<PortEquivalence>();        if (elecPorts.size() != extPorts.size()) {            System.out.println("Error, port lists differ in size!");            return;        }        for (int i=0; i<elecPorts.size(); i++) {            PortEquivalence pe = new PortEquivalence(elecPorts.get(i), extPorts.get(i));            portEquivs.add(pe);        }        NodeEquivalence equiv = new NodeEquivalence(np, func, exportType, extLib, extCell, extView, rot, portEquivs);        equivsByExternal.put(getExternalKey(extLib, extCell, extView), equiv);        equivsByNodeProto.put(getElectricKey(np, func, exportType), equiv);

⌨️ 快捷键说明

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