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

📄 arcproto.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: ArcProto.java * * Copyright (c) 2003 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.technology;import com.sun.electric.database.EObjectInputStream;import com.sun.electric.database.EObjectOutputStream;import com.sun.electric.database.ImmutableArcInst;import com.sun.electric.database.geometry.DBMath;import com.sun.electric.database.geometry.Poly;import com.sun.electric.database.id.ArcProtoId;import com.sun.electric.database.text.Pref;import com.sun.electric.technology.xml.XmlParam;import com.sun.electric.tool.erc.ERC;import com.sun.electric.tool.user.User;import java.awt.geom.Point2D;import java.io.IOException;import java.io.InvalidObjectException;import java.io.PrintWriter;import java.io.Serializable;import java.util.Arrays;import java.util.HashMap;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.NoSuchElementException;/** * The ArcProto class defines a type of ArcInst. * <P> * Every arc in the database appears as one <I>prototypical</I> object and many <I>instantiative</I> objects. * Thus, for a ArcProto such as the CMOS Metal-1 there is one object (called a ArcProto) * that describes the wire prototype and there are many objects (called ArcInsts), * one for every instance of a Metal-1 wire that appears in a circuit. * ArcProtos are statically created and placed in the Technology objects. * <P> * The basic ArcProto has a name, default width, function, Layers that describes it graphically and more. */public class ArcProto implements Comparable<ArcProto>, Serializable{	/**	 * Function is a typesafe enum class that describes the function of an ArcProto.	 * Functions are technology-independent and include different types of metal,	 * polysilicon, and other basic wire types.	 */	public static enum Function	{		/** Describes an arc with unknown type. */		UNKNOWN("unknown", 0, 0),		/** Describes an arc on Metal layer 1. */		METAL1("metal-1", 1, 0),		/** Describes an arc on Metal layer 2. */		METAL2("metal-2", 2, 0),		/** Describes an arc on Metal layer 3. */		METAL3("metal-3", 3, 0),		/** Describes an arc on Metal layer 4. */		METAL4("metal-4", 4, 0),		/** Describes an arc on Metal layer 5. */		METAL5("metal-5", 5, 0),		/** Describes an arc on Metal layer 6. */		METAL6("metal-6", 6, 0),		/** Describes an arc on Metal layer 7. */		METAL7("metal-7", 7, 0),		/** Describes an arc on Metal layer 8. */		METAL8("metal-8", 8, 0),		/** Describes an arc on Metal layer 9. */		METAL9("metal-9", 9, 0),		/** Describes an arc on Metal layer 10. */		METAL10("metal-10", 10, 0),		/** Describes an arc on Metal layer 11. */		METAL11("metal-11", 11, 0),		/** Describes an arc on Metal layer 12. */		METAL12("metal-12", 12, 0),		/** Describes an arc on Polysilicon layer 1. */		POLY1("polysilicon-1", 0, 1),		/** Describes an arc on Polysilicon layer 2. */		POLY2("polysilicon-2", 0, 2),		/** Describes an arc on Polysilicon layer 3. */		POLY3("polysilicon-3", 0, 3),		/** Describes an arc on the Diffusion layer. */		DIFF("diffusion", 0, 0),		/** Describes an arc on the P-Diffusion layer. */		DIFFP("p-diffusion", 0, 0),		/** Describes an arc on the N-Diffusion layer. */		DIFFN("n-diffusion", 0, 0),		/** Describes an arc on the Substrate-Diffusion layer. */		DIFFS("substrate-diffusion", 0, 0),		/** Describes an arc on the Well-Diffusion layer. */		DIFFW("well-diffusion", 0, 0),		/** Describes an arc on the Well layer (bias connections). */		WELL("well", 0, 0),		/** Describes a bus arc. */		BUS("bus", 0, 0),		/** Describes an arc that is unrouted (to be replaced by routers). */		UNROUTED("unrouted", 0, 0),		/** Describes an arc that is non-electrical (does not make a circuit connection). */		NONELEC("nonelectrical", 0, 0);		private final String printName;		private final int level;        private final boolean isMetal;        private final boolean isPoly;        private final boolean isDiffusion;        private static final Function[] metalLayers = initMetalLayers(Function.class.getEnumConstants());        private static final Function[] polyLayers = initPolyLayers(Function.class.getEnumConstants());        private Function(String printName, int metalLevel, int polyLevel) {            this.printName = printName;            isMetal = metalLevel != 0;            isPoly = polyLevel != 0;            isDiffusion = name().startsWith("DIFF");            level = isMetal ? metalLevel : isPoly ? polyLevel : 0;        }		/**		 * Returns a printable version of this ArcProto.		 * @return a printable version of this ArcProto.		 */		public String toString() { return printName; }		/**		 * Returns the constant name for this Function.		 * Constant names are used when writing Java code, so they must be the same as the actual symbol name.		 * @return the constant name for this Function.		 */		public String getConstantName() { return name(); }		/**		 * Method to return a List of all ArcProto functions.		 * @return a List of all ArcProto functions.		 */		public static List<Function> getFunctions() { return Arrays.asList(Function.class.getEnumConstants()); }		/**		 * Method to get the level of this ArcProto.Function.		 * The level applies to metal and polysilicon functions, and gives the layer number		 * (i.e. Metal-2 is level 2).		 * @return the level of this ArcProto.Function.		 */		public int getLevel() { return level; }		/**		 * Method to find the Function that corresponds to Metal on a given layer.		 * @param level the layer (starting at 1 for Metal-1).		 * @return the Function that represents that Metal layer.		 */        public static Function getMetal(int level) {            return level < metalLayers.length ? metalLayers[level] : null;        }		/**		 * Method to find the Function that corresponds to Polysilicon on a given layer.		 * @param level the layer (starting at 1 for Polysilicon-1).		 * @return the Function that represents that Polysilicon layer.		 */        public static Function getPoly(int level) {            return level < polyLayers.length ? polyLayers[level] : null;        }        /**         * Method to find the Function that corresponds to a contact on a given arc.         * @param level the arc (starting at 1 for Contact-1).         * @return the Function that represents that Contact arc.         */        public static Function getContact(int level)        {            return metalLayers[level];        }        /**		 * Method to tell whether this ArcProto.Function is metal.		 * @return true if this ArcProto.Function is metal.		 */		public boolean isMetal() { return isMetal; }		/**		 * Method to tell whether this ArcProto.Function is polysilicon.		 * @return true if this ArcProto.Function is polysilicon.		 */		public boolean isPoly() { return isPoly; }		/**		 * Method to tell whether this ArcProto.Function is diffusion.		 * @return true if this ArcProto.Function is diffusion.		 */		public boolean isDiffusion() { return isDiffusion; }        private static Function[] initMetalLayers(Function[] allFunctions) {            int maxLevel = -1;            for (Function fun: getFunctions()) {                if (!fun.isMetal()) continue;                maxLevel = Math.max(maxLevel, fun.level);            }            Function[] layers = new Function[maxLevel + 1];            for (Function fun: getFunctions()) {                if (!fun.isMetal()) continue;                assert layers[fun.level] == null;                layers[fun.level] = fun;            }            return layers;        }        private static Function[] initPolyLayers(Function[] allFunctions) {            int maxLevel = -1;            for (Function fun: getFunctions()) {                if (!fun.isPoly()) continue;                maxLevel = Math.max(maxLevel, fun.level);            }            Function[] layers = new Function[maxLevel + 1];            for (Function fun: getFunctions()) {                if (!fun.isPoly()) continue;                assert layers[fun.level] == null;                layers[fun.level] = fun;            }            return layers;        }	}	// ----------------------- private data -------------------------------	/** Pref map for arc extend over min. */					private static HashMap<ArcProto,Pref> defaultExtendPrefs = new HashMap<ArcProto,Pref>();	/** Pref map for arc angle increment. */					private static HashMap<ArcProto,Pref> defaultAnglePrefs = new HashMap<ArcProto,Pref>();	/** Pref map for arc rigidity. */							private static HashMap<ArcProto,Pref> defaultRigidPrefs = new HashMap<ArcProto,Pref>();	/** Pref map for arc fixed angle. */						private static HashMap<ArcProto,Pref> defaultFixedAnglePrefs = new HashMap<ArcProto,Pref>();	/** Pref map for arc slidable. */							private static HashMap<ArcProto,Pref> defaultSlidablePrefs = new HashMap<ArcProto,Pref>();	/** Pref map for arc end extension. */						private static HashMap<ArcProto,Pref> defaultExtendedPrefs = new HashMap<ArcProto,Pref>();//	/** Pref map for arc negation. */							private static HashMap<ArcProto,Pref> defaultNegatedPrefs = new HashMap<ArcProto,Pref>();	/** Pref map for arc directionality. */						private static HashMap<ArcProto,Pref> defaultDirectionalPrefs = new HashMap<ArcProto,Pref>();	/** The name of this ArcProto. */							private final ArcProtoId protoId;	/** The technology in which this ArcProto resides. */		private final Technology tech;    /** The ELIB width offset */                                private final double lambdaElibWidthOffset;	/** The base extend of this ArcProto in lambda units. */    private double lambdaBaseExtend;	/** The base extend of this ArcProto in grid units. */      private int gridBaseExtend;    /** The minimum extend among ArcLayers. */                  private int minLayerGridExtend;    /** The minimum extend among ArcLayers. */                  private int maxLayerGridExtend;	/** Flags bits for this ArcProto. */						private int userBits;	/** The function of this ArcProto. */						final Function function;	/** Layers in this arc */                                   final Technology.ArcLayer [] layers;    /** Pin for this arc */                                     PrimitiveNode arcPin;	/** Index of this ArcProto. */                              final int primArcIndex;//	/** A temporary integer for this ArcProto. */				private int tempInt;	// the meaning of the "userBits" field://	/** these arcs are fixed-length */							private static final int WANTFIX  =            01;//	/** these arcs are fixed-angle */							private static final int WANTFIXANG  =         02;//	/** set if arcs should not slide in ports */				private static final int WANTCANTSLIDE  =      04;//	/** set if ends do not extend by half width */				private static final int WANTNOEXTEND  =      010;//	/** set if arcs should be negated */						private static final int WANTNEGATED  =       020;//	/** set if arcs should be directional */					private static final int WANTDIRECTIONAL  =   040;	/** set if arcs can wipe wipable nodes */					private static final int CANWIPE  =          0100;	/** set if arcs can curve */								private static final int CANCURVE  =         0200;//	/** arc function (from efunction.h) */						private static final int AFUNCTION  =      017400;//	/** right shift for AFUNCTION */							private static final int AFUNCTIONSH  =         8;//	/** angle increment for this type of arc */					private static final int AANGLEINC  =   017760000;//	/** right shift for AANGLEINC */							private static final int AANGLEINCSH  =        13;    /** set if arc is not selectable in palette */			    private static final int ARCSPECIAL  = 010000000;	/** set if arc is selectable by edge, not area */			private static final int AEDGESELECT  = 020000000;	/** set if arc is invisible and unselectable */				private static final int AINVISIBLE   = 040000000;	/** set if arc is not used */								private static final int ANOTUSED  = 020000000000;	/** set if node will be considered in palette */            private static final int SKIPSIZEINPALETTE =    0400;	// ----------------- protected and private methods -------------------------	/**	 * The constructor is never called.  Use "Technology.newArcProto" instead.	 */	ArcProto(Technology tech, String protoName, long gridFullExtend, long gridBaseExtend, Function function, Technology.ArcLayer [] layers, int primArcIndex)	{        assert -Integer.MAX_VALUE/8 < gridFullExtend && gridFullExtend < Integer.MAX_VALUE/8;        assert -Integer.MAX_VALUE/8 < gridBaseExtend && gridBaseExtend < Integer.MAX_VALUE/8;		if (!Technology.jelibSafeName(protoName))			System.out.println("ArcProto name " + protoName + " is not safe to write into JELIB");        protoId = tech.getId().newArcProtoId(protoName);		this.tech = tech;		this.userBits = 0;		this.function = function;		this.layers = layers.clone();        this.primArcIndex = primArcIndex;        lambdaElibWidthOffset = DBMath.gridToLambda(2*(gridFullExtend - gridBaseExtend));        this.gridBaseExtend = (int)gridBaseExtend;        lambdaBaseExtend = DBMath.gridToLambda(gridBaseExtend);        computeLayerGridExtendRange();        getArcProtoExtendPref();	}    protected Object writeReplace() { return new ArcProtoKey(this); }    private static class ArcProtoKey extends EObjectInputStream.Key<ArcProto> {        public ArcProtoKey() {}        private ArcProtoKey(ArcProto ap) { super(ap); }        @Override        public void writeExternal(EObjectOutputStream out, ArcProto ap) throws IOException {            out.writeObject(ap.getTechnology());            out.writeInt(ap.getId().chronIndex);        }        @Override        public ArcProto readExternal(EObjectInputStream in) throws IOException, ClassNotFoundException {            Technology tech = (Technology)in.readObject();            int chronIndex = in.readInt();            ArcProto ap = tech.getArcProtoByChronIndex(chronIndex);            if (ap == null)                throw new InvalidObjectException("arc proto not found");            return ap;        }    }	// ------------------------ public methods -------------------------------	/**	 * Method to return the Id of this ArcProto.	 * @return the Id of this ArcProto.	 */	public ArcProtoId getId() { return protoId; }	/**	 * Method to return the name of this ArcProto.	 * @return the name of this ArcProto.	 */	public String getName() { return protoId.name; }	/**	 * Method to return the full name of this ArcProto.	 * Full name has format "techName:primName"	 * @return the full name of this ArcProto.	 */	public String getFullName() { return protoId.fullName; }	/**	 * Method to return the Technology of this ArcProto.	 * @return the Technology of this ArcProto.	 */	public Technology getTechnology() { return tech; }	private Pref getArcProtoExtendPref()	{        double factory = 0;

⌨️ 快捷键说明

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