📄 primitivenode.java
字号:
/** * Method to tell whether this function describes a transistor. * @return true if this function describes a transistor. */ public boolean isTransistor() { return isTransistor; } /** * Method to tell whether this function describes a field-effect transtor. * This includes the nMOS, PMOS, and DMOS transistors, as well as the DMES and EMES transistors. * @return true if this function describes a field-effect transtor. */ public boolean isFET() { if (this == TRANMOS || this == TRA4NMOS || this == TRAPMOS || this == TRA4PMOS || this == TRADMOS || this == TRA4DMOS || this == TRAPMOSD || this == TRA4PMOSD || this == TRANMOSNT || this == TRA4NMOSNT || this == TRAPMOSNT || this == TRA4PMOSNT || this == TRANMOSFG || this == TRA4NMOSFG || this == TRAPMOSFG || this == TRA4PMOSFG || this == TRANMOSVTL || this == TRA4NMOSVTL || this == TRAPMOSVTL || this == TRA4PMOSVTL || this == TRANMOSVTH || this == TRA4NMOSVTH || this == TRAPMOSVTH || this == TRA4PMOSVTH || this == TRANMOSHV1 || this == TRA4NMOSHV1 || this == TRAPMOSHV1 || this == TRA4PMOSHV1 || this == TRANMOSHV2 || this == TRA4NMOSHV2 || this == TRAPMOSHV2 || this == TRA4PMOSHV2 || this == TRANMOSHV3 || this == TRA4NMOSHV3 || this == TRAPMOSHV3 || this == TRA4PMOSHV3 || this == TRANMOSNTHV1 || this == TRA4NMOSNTHV1 || this == TRAPMOSNTHV1 || this == TRA4PMOSNTHV1 || this == TRANMOSNTHV2 || this == TRA4NMOSNTHV2 || this == TRAPMOSNTHV2 || this == TRA4PMOSNTHV2 || this == TRANMOSNTHV3 || this == TRA4NMOSNTHV3 || this == TRAPMOSNTHV3 || this == TRA4PMOSNTHV3 || this == TRANJFET || this == TRA4NJFET || this == TRAPJFET || this == TRA4PJFET || this == TRADMES || this == TRA4DMES || this == TRAEMES || this == TRA4EMES) return true; return false; } /** * Method to tell whether this function describes a 4-port transtor and to return the equivalent 3-port function. * @return the equivalent 3-port transistor function for this 4-port function. * Returns null if this is not a 4-port transistor function. */ public Function make3PortTransistor() { if (!isTransistor) return null; if (this == TRA4NMOS) return TRANMOS; if (this == TRA4PMOS) return TRAPMOS; if (this == TRA4DMOS) return TRADMOS; if (this == TRA4PMOSD) return TRAPMOSD; if (this == TRA4NMOSNT) return TRANMOSNT; if (this == TRA4PMOSNT) return TRAPMOSNT; if (this == TRA4NMOSFG) return TRANMOSFG; if (this == TRA4PMOSFG) return TRAPMOSFG; if (this == TRA4NMOSVTL) return TRANMOSVTL; if (this == TRA4PMOSVTL) return TRAPMOSVTL; if (this == TRA4NMOSVTH) return TRANMOSVTH; if (this == TRA4PMOSVTH) return TRAPMOSVTH; if (this == TRA4NMOSHV1) return TRANMOSHV1; if (this == TRA4PMOSHV1) return TRAPMOSHV1; if (this == TRA4NMOSHV2) return TRANMOSHV2; if (this == TRA4PMOSHV2) return TRAPMOSHV2; if (this == TRA4NMOSHV3) return TRANMOSHV3; if (this == TRA4PMOSHV3) return TRAPMOSHV3; if (this == TRA4NMOSNTHV1) return TRANMOSNTHV1; if (this == TRA4PMOSNTHV1) return TRAPMOSNTHV1; if (this == TRA4NMOSNTHV2) return TRANMOSNTHV2; if (this == TRA4PMOSNTHV2) return TRAPMOSNTHV2; if (this == TRA4NMOSNTHV3) return TRANMOSNTHV3; if (this == TRA4PMOSNTHV3) return TRAPMOSNTHV3; if (this == TRA4NPN) return TRANPN; if (this == TRA4PNP) return TRAPNP; if (this == TRA4NJFET) return TRANJFET; if (this == TRA4PJFET) return TRAPJFET; if (this == TRA4DMES) return TRADMES; if (this == TRA4EMES) return TRAEMES; if (this == TRANS4) return TRANS; return null; } /** * Method to tell whether this function describes an n-Type transtor. * This includes the MOS transistors, as well as the DMES and EMES transistors. * @return true if this function describes an n-Type transtor. */ public boolean isNTypeTransistor() { if (this == TRANMOS || this == TRA4NMOS || this == TRADMOS || this == TRA4DMOS || this == TRANMOSNT || this == TRA4NMOSNT || this == TRANMOSFG || this == TRA4NMOSFG || this == TRANMOSVTL || this == TRA4NMOSVTL || this == TRANMOSVTH || this == TRA4NMOSVTH || this == TRANMOSHV1 || this == TRA4NMOSHV1 || this == TRANMOSHV2 || this == TRA4NMOSHV2 || this == TRANMOSHV3 || this == TRA4NMOSHV3 || this == TRANMOSNTHV1 || this == TRA4NMOSNTHV1 || this == TRANMOSNTHV2 || this == TRA4NMOSNTHV2 || this == TRANMOSNTHV3 || this == TRA4NMOSNTHV3 || this == TRADMES || this == TRA4DMES || this == TRAEMES || this == TRA4EMES) return true; return false; } /** * Method to tell whether this function describes a p-Type transtor. * @return true if this function describes a p-Type transtor. */ public boolean isPTypeTransistor() { if (this == TRAPMOS || this == TRA4PMOS || this == TRAPMOSD || this == TRA4PMOSD || this == TRAPMOSNT || this == TRA4PMOSNT || this == TRAPMOSFG || this == TRA4PMOSFG || this == TRAPMOSVTL || this == TRA4PMOSVTL || this == TRAPMOSVTH || this == TRA4PMOSVTH || this == TRAPMOSHV1 || this == TRA4PMOSHV1 || this == TRAPMOSHV2 || this == TRA4PMOSHV2 || this == TRAPMOSHV3 || this == TRA4PMOSHV3 || this == TRAPMOSNTHV1 || this == TRA4PMOSNTHV1 || this == TRAPMOSNTHV2 || this == TRA4PMOSNTHV2 || this == TRAPMOSNTHV3 || this == TRA4PMOSNTHV3) return true; return false; } /** * Method to tell whether this function describes a bipolar transistor. * This includes NPN and PNP transistors. * @return true if this function describes a bipolar transtor. */ public boolean isBipolar() { return this == TRANPN || this == TRA4NPN || this == TRAPNP || this == TRA4PNP; } /** * Method to tell whether this function describes a flip-flop. * @return true if this function describes a flip-flop. */ public boolean isFlipFlop() { return isFlipFlop; } /** * Returns a printable version of this Function. * @return a printable version of this Function. */ public String toString() { return name; } /** Returns name of the enumeration constant. For example "TRANMOS". * By convention, the enumeration names encode information that isn't * otherwise available. The transistor "TRANMOS" is the same as "TRA4NMOS" * except that the latter has a substrate connection. RKao * @return name of the enumeration constant */ public String enumName() {return super.toString();} } // constants used in the "specialType" field /** Defines a normal node. */ public static final int NORMAL = 0; /** Defines a serpentine transistor. */ public static final int SERPTRANS = 1; /** Defines a polygonal transistor. */ public static final int POLYGONAL = 2; /** set if node is a low vt transistor */ public static final int LOWVTBIT = 010; /** set if node is a high vt transistor */ public static final int HIGHVTBIT = 020; /** set if node is a native transistor */ public static final int NATIVEBIT = 040; /** set if node is a od18 transistor */ public static final int OD18BIT = 0100; /** set if node is a od25 transistor */ public static final int OD25BIT = 0200; /** set if node is a od33 transistor */ public static final int OD33BIT = 0400; /** set if node is a cross contact */ public static final int CROSSCONTACT = 010000000; /** set if node is an aligned contact */ public static final int ALIGNCONTACT = 020000000; /** set if nonmanhattan instances shrink */ private static final int NODESHRINK = 01; /** set if instances can be wiped */ private static final int ARCSWIPE = 01000; /** set if node is to be kept square in size */ private static final int NSQUARE = 02000; /** primitive can hold trace information */ private static final int HOLDSTRACE = 04000; /** set if this primitive can be zero-sized */ private static final int CANBEZEROSIZE = 010000; /** set to erase if connected to 1 or 2 arcs */ private static final int WIPEON1OR2 = 020000; /** set if primitive is lockable (cannot move) */ private static final int LOCKEDPRIM = 040000; /** set if primitive is selectable by edge, not area */ private static final int NEDGESELECT = 0100000; /** set if nonmanhattan arcs on this shrink */ private static final int ARCSHRINK = 0200000; /** set if nonmanhattan arcs on this shrink */ private static final int NINVISIBLE = 0400000; /** set if node will be considered in palette */ private static final int SKIPSIZEINPALETTE = 01000000; /** set if not used (don't put in menu) */ private static final int NNOTUSED = 02000000; // --------------------- private data ----------------------------------- /** The Id of this PrimitiveNode. */ private final PrimitiveNodeId protoId; /** This PrimitiveNode's Technology. */ private final Technology tech; /** The function of this PrimitiveNode. */ private Function function; /** layers describing this primitive */ private Technology.NodeLayer [] layers; /** electrical layers describing this */ private Technology.NodeLayer [] electricalLayers; /** PrimitivePorts on the PrimitiveNode. */ private PrimitivePort[] primPorts = {}; /** array of ports by portId.chronIndex */ private PrimitivePort[] portsByChronIndex = {}; /** flag bits */ private int userBits; /** Global index of this PrimitiveNode. */ private int globalPrimNodeIndex; /** Index of this PrimitiveNode per tech */ private int techPrimNodeIndex = -1; /** special type of unusual primitives */ private int specialType; /** special factors for unusual primitives */ private double[] specialValues; /** true if contains MULTICUTBOX layers */ private int numMultiCuts; /** minimum width and height rule */ private NodeSizeRule minNodeSize; /** size corrector */ private final EPoint[] sizeCorrectors = { EPoint.ORIGIN, EPoint.ORIGIN }; /** offset from database to user */ private SizeOffset offset; /** base (highlight) rectangle of standard node */private ERectangle baseRectangle; /** full (true) rectangle of standard node */ private ERectangle fullRectangle; /** amount to automatically grow to fit arcs */ private Dimension2D autoGrowth; /** template for Spice decks (null if none) */ private String spiceTemplate; /** counter for enumerating primitive nodes */ private static int primNodeNumber = 0; /** Pref map for node width. */ private static Map<PrimitiveNode,Pref> defaultExtendXPrefs = new HashMap<PrimitiveNode,Pref>(); /** Pref map for node height. */ private static Map<PrimitiveNode,Pref> defaultExtendYPrefs = new HashMap<PrimitiveNode,Pref>(); /** cached state of node visibility */ private static Map<PrimitiveNode,Boolean> cacheVisibilityNodes = new HashMap<PrimitiveNode,Boolean>(); // ------------------ private and protected methods ---------------------- /** * The constructor is never called externally. Use the factory "newInstance" instead. */ protected PrimitiveNode(String protoName, Technology tech, EPoint sizeCorrector1, EPoint sizeCorrector2, String minSizeRule, double defWidth, double defHeight, ERectangle fullRectangle, ERectangle baseRectangle, Technology.NodeLayer [] layers) { // things in the base class if (!Technology.jelibSafeName(protoName)) System.out.println("PrimitiveNode name " + protoName + " is not safe to write in the JELIB"); this.protoId = tech.getId().newPrimitiveNodeId(protoName); this.function = Function.UNKNOWN; // things in this class this.tech = tech; this.layers = layers; this.electricalLayers = null; this.userBits = 0; specialType = NORMAL; sizeCorrectors[0] = sizeCorrector1; sizeCorrectors[1] = sizeCorrector2; this.fullRectangle = fullRectangle; this.baseRectangle = baseRectangle; if (minSizeRule != null) { minNodeSize = new NodeSizeRule(minSizeRule); } setFactoryDefSize(defWidth, defHeight); double lx = baseRectangle.getLambdaMinX() - fullRectangle.getLambdaMinX(); double hx = fullRectangle.getLambdaMaxX() - baseRectangle.getLambdaMaxX(); double ly = baseRectangle.getLambdaMinY() - fullRectangle.getLambdaMinY(); double hy = fullRectangle.getLambdaMaxY() - baseRectangle.getLambdaMaxY(); offset = new SizeOffset(lx, hx, ly, hy); this.autoGrowth = null; globalPrimNodeIndex = primNodeNumber++; int numMultiCuts = 0; for (Technology.NodeLayer nodeLayer: layers) { if (nodeLayer.getRepresentation() == Technology.NodeLayer.MULTICUTBOX) numMultiCuts++; } this.numMultiCuts = numMultiCuts; // add to the nodes in this technology tech.addNodeProto(this); check(); } protected Object writeReplace() { return new PrimitiveNodeKey(this); } private static class PrimitiveNodeKey extends EObjectInputStream.Key<PrimitiveNode> { public PrimitiveNodeKey() {} private PrimitiveNodeKey(PrimitiveNode pn) { super(pn); } @Override public void writeExternal(EObjectOutputStream out, PrimitiveNode pn) throws IOException { out.writeObject(pn.getTechnology()); out.writeInt(pn.getId().chronIndex); } @Override public PrimitiveNode readExternal(EObjectInputStream in) throws IOException, ClassNotFoundException { Technology tech = (Technology)in.readObject(); int chronIndex = in.readInt(); PrimitiveNode pn = tech.getPrimitiveNodeByChronIndex(chronIndex); if (pn == null) throw new InvalidObjectException("primitive node not found"); return pn; } } // ------------------------- public methods ------------------------------- /** * Method to create a new PrimitiveNode from the parameters. * Size corrector of PrimitiveNode is determined from width and height. * @param protoName the name of the PrimitiveNode. * Primitive names may not contain unprintable characters, spaces, tabs, a colon (:), semicolon (;) or curly braces ({}). * @param tech the Technology of the PrimitiveNode. * @param width the width of the PrimitiveNode. * @param height the height of the PrimitiveNode.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -