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

📄 arcinst.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
     * @param headPt the coordinate of the head end PortInst.     * @param tailPt the coordinate of the tail end PortInst.     * @param gridExtendOverMin the extend of this ArcInst over minimal-width arc of this type in grid units.     * @param angle angle in tenth-degrees.     * @param flags flag bits.     * @return the newly created ArcInst, or null if there is an error.     */	public static ArcInst newInstance(Cell parent, ArcProto protoType, String name, TextDescriptor nameDescriptor,        PortInst headPort, PortInst tailPort, EPoint headPt, EPoint tailPt, long gridExtendOverMin, int angle, int flags)	{        parent.checkChanging();        Topology topology = parent.getTopology();		// make sure fields are valid		if (protoType == null || headPort == null || tailPort == null || !headPort.isLinked() || !tailPort.isLinked()) return null;        if (headPt == null || tailPt == null) return null;        if (parent != headPort.getNodeInst().getParent() || parent != tailPort.getNodeInst().getParent())		{			System.out.println("ArcProto.newInst: the 2 PortInsts are in different Cells!");            System.out.println("Cell " + parent.getName());            System.out.println("Head " + headPort.getNodeInst().getParent().getName());            System.out.println("Tail " + tailPort.getNodeInst().getParent().getName());            return null;		}        // make sure the arc can connect to these ports        PortProto headProto = headPort.getPortProto();		PrimitivePort headPrimPort = headProto.getBasePort();		if (!headPrimPort.connectsTo(protoType))		{			System.out.println("Cannot create " + protoType + " from (" + headPt.getX() + "," + headPt.getY() +				") to (" + tailPt.getX() + "," + tailPt.getY() + ") in " + parent +				" because it cannot connect to port " + headProto.getName() +				" on node " + headPort.getNodeInst().describe(false));			return null;		}		PortProto tailProto = tailPort.getPortProto();		PrimitivePort tailPrimPort = tailProto.getBasePort();		if (!tailPrimPort.connectsTo(protoType))		{			System.out.println("Cannot create " + protoType + " from (" + headPt.getX() + "," + headPt.getY() +				") to (" + tailPt.getX() + "," + tailPt.getY() + ") in " + parent +				" because it cannot connect to port " + tailProto.getName() +				" on node " + tailPort.getNodeInst().describe(false));			return null;		}        if (nameDescriptor == null) nameDescriptor = TextDescriptor.getArcTextDescriptor();        Name nameKey = name != null ? Name.findName(name) : null;		if (nameKey == null || nameKey.isTempname() && (!parent.isUniqueName(nameKey, ArcInst.class, null)) || checkNameKey(nameKey, topology))		{            nameKey = topology.getArcAutoname();		} else		{			// adjust the name descriptor for "smart" text placement            long gridBaseWidth = 2*(gridExtendOverMin + protoType.getGridBaseExtend());			nameDescriptor = getSmartTextDescriptor(angle, DBMath.gridToLambda(gridBaseWidth), nameDescriptor);		}        TechPool techPool = parent.getTechPool();        if (!(tailProto.getId() instanceof PrimitivePortId && techPool.getPrimitivePort((PrimitivePortId)tailProto.getId()).isNegatable()))            flags = ImmutableArcInst.TAIL_NEGATED.set(flags, false);        if (!(headProto.getId() instanceof PrimitivePortId && techPool.getPrimitivePort((PrimitivePortId)headProto.getId()).isNegatable()))            flags = ImmutableArcInst.HEAD_NEGATED.set(flags, false);        if (protoType.getTechnology().isNoNegatedArcs()) {            flags = ImmutableArcInst.TAIL_NEGATED.set(flags, false);            flags = ImmutableArcInst.HEAD_NEGATED.set(flags, false);        }        CellId parentId = parent.getId();        // search for spare arcId        int arcId;        do {            arcId = parentId.newArcId();        } while (parent.getArcById(arcId) != null);        ImmutableArcInst d = ImmutableArcInst.newInstance(arcId, protoType.getId(), nameKey, nameDescriptor,                tailPort.getNodeInst().getD().nodeId, tailProto.getId(), tailPt,                headPort.getNodeInst().getD().nodeId, headProto.getId(), headPt,                gridExtendOverMin, angle, flags);        ArcInst ai = new ArcInst(topology, d, headPort, tailPort);		// attach this arc to the two nodes it connects		headPort.getNodeInst().redoGeometric();		tailPort.getNodeInst().redoGeometric();		// add this arc to the cell		topology.addArc(ai);		// handle change control, constraint, and broadcast		Constraints.getCurrent().newObject(ai);		return ai;	}    /**	 * Method to delete this ArcInst.	 */	public void kill()	{		if (!isLinked())		{			System.out.println("ArcInst already killed");			return;		}        checkChanging();		// remove this arc from the two nodes it connects		headPortInst.getNodeInst().redoGeometric();		tailPortInst.getNodeInst().redoGeometric();		// remove this arc from the cell		topology.removeArc(this);		// handle change control, constraint, and broadcast		Constraints.getCurrent().killObject(this);	}	/**	 * Method to change the width and end locations of this ArcInst.	 * @param dHeadX the change to the X coordinate of the head of this ArcInst.	 * @param dHeadY the change to the Y coordinate of the head of this ArcInst.	 * @param dTailX the change to the X coordinate of the tail of this ArcInst.	 * @param dTailY the change to the Y coordinate of the tail of this ArcInst.	 */	public void modify(double dHeadX, double dHeadY, double dTailX, double dTailY)	{		// save old arc state        ImmutableArcInst oldD = d;		// change the arc        EPoint tail = d.tailLocation;		if (dTailX != 0 || dTailY != 0)			tail = new EPoint(tail.getX() + dTailX, tail.getY() + dTailY);        EPoint head = d.headLocation;        if (dHeadX != 0 || dHeadY != 0)            head = new EPoint(head.getX() + dHeadX, head.getY() + dHeadY);		lowLevelModify(d.withLocations(tail, head));		// track the change        Constraints.getCurrent().modifyArcInst(this, oldD);	}	/**	 * Method to change the width this ArcInst.	 * @param lambdaBaseWidth new base width of the ArcInst in lambda units.	 */    public void setLambdaBaseWidth(double lambdaBaseWidth) {        setGridBaseWidth(DBMath.lambdaToSizeGrid(lambdaBaseWidth));    }	/**	 * Method to change the width this ArcInst.	 * @param gridBaseWidth new base width of the ArcInst in lambda units.	 */    public void setGridBaseWidth(long gridBaseWidth) {        if (gridBaseWidth == getGridBaseWidth()) return;        // save old arc state        ImmutableArcInst oldD = d;        // change the arc        lowLevelModify(d.withGridExtendOverMin(gridBaseWidth/2 - getProto().getGridBaseExtend()));        // track the change        Constraints.getCurrent().modifyArcInst(this, oldD);    }	/**	 * Method to replace this ArcInst with one of another type.	 * @param ap the new type of arc.	 * @return the new ArcInst (null on error).	 */	public ArcInst replace(ArcProto ap)	{		// check for connection allowance		if (!headPortInst.getPortProto().connectsTo(ap) || !tailPortInst.getPortProto().connectsTo(ap))		{			System.out.println("Cannot replace " + this + " with one of type " + ap.getName() +				" because the nodes cannot connect to it");			return null;		}		// first create the new nodeinst in place		ArcInst newar = ArcInst.newInstanceBase(ap, getLambdaBaseWidth(), headPortInst, tailPortInst, d.headLocation, d.tailLocation, null, 0);		if (newar == null)		{			System.out.println("Cannot replace " + this + " with one of type " + ap.getName() +				" because the new arc failed to create");			return null;		}		// copy all variables on the arcinst		newar.copyPropertiesFrom(this);		// now delete the original nodeinst		kill();		newar.setName(getName());		return newar;	}	/****************************** LOW-LEVEL IMPLEMENTATION ******************************/    /**     * Returns persistent data of this ArcInst.     * @return persistent data of this ArcInst.     */    @Override    public ImmutableArcInst getD() { return d; }    /**     * Modifies persistend data of this ArcInst.     * @param newD new persistent data.     * @param notify true to notify Undo system.     * @return true if persistent data was modified.     */    public boolean setD(ImmutableArcInst newD, boolean notify) {        checkChanging();        ImmutableArcInst oldD = d;        if (newD == oldD) return false;        parent.setTopologyModified();        d = newD;        if (notify)            Constraints.getCurrent().modifyArcInst(this, oldD);        return true;    }    public void setDInUndo(ImmutableArcInst newD) {        checkUndoing();        d = newD;    }    /**     * Method to add a Variable on this ArcInst.     * It may add repaired copy of this Variable in some cases.     * @param var Variable to add.     */    public void addVar(Variable var) {        if (setD(d.withVariable(var), true))        {            // check for side-effects of the change            checkPossibleVariableEffects(var.getKey());        }    }	/**	 * Method to handle special case side-effects of setting variables on this NodeInst.	 * Overrides the general method on ElectricObject.	 * Currently it handles changes to the number-of-degrees on a circle node.	 * @param key the Variable key that has changed on this NodeInst.	 */	public void checkPossibleVariableEffects(Variable.Key key)	{        if (key == ImmutableArcInst.ARC_RADIUS) {			lowLevelModify(d);        }	}	/**	 * Method to delete a Variable from this ArcInst.	 * @param key the key of the Variable to delete.	 */	public void delVar(Variable.Key key)	{        setD(d.withoutVariable(key), true);	}	/**	 * Low-level method to change the width and end locations of this ArcInst.     * New persistent data may differ from old one only by width and end locations	 * @param d the new persistent data of this ArcInst.	 */	public void lowLevelModify(ImmutableArcInst d)	{		// first remove from the R-Tree structure        boolean renamed = this.d.name != d.name;        if (renamed)            topology.removeArc(this);		// now make the change        setD(d, false);        if (renamed)            topology.addArc(this);        redoGeometric();		// update end shrinkage information ?????????????????????//		headPortInst.getNodeInst().updateShrinkage();//		tailPortInst.getNodeInst().updateShrinkage();	}	/****************************** GRAPHICS ******************************/	/**	 * Method to return the full width of this ArcInst in grid units.	 * @return the full width of this ArcInst in grid units.	 */	public long getGridFullWidth() { return 2*(d.getGridExtendOverMin() + getProto().getMaxLayerGridExtend()); }	/**	 * Method to return the base width of this ArcInst in lambda units.	 * @return the base width of this ArcInst in lambda units.	 */	public double getLambdaBaseWidth() { return DBMath.gridToLambda(getGridBaseWidth()); }	/**	 * Method to return the base width of this ArcInst in grid units.	 * @return the base width of this ArcInst in grid units.	 */	public long getGridBaseWidth() { return 2*(d.getGridExtendOverMin() + getProto().getGridBaseExtend()); }	/**	 * Method to return the length of this ArcInst in lambda units.	 * @return the length of this ArcInst in lambda units.	 */	public double getLambdaLength() { return d.getLambdaLength(); }	/**	 * Method to return the length of this ArcInst in grid units.	 * @return the length of this ArcInst in grid units.	 */	public double getGridLength() { return d.getGridLength(); }    /**     * Returns true if length of this ArcInst is zero.     * @return true if length of this ArcInst is zero.     */    public boolean isZeroLength() { return d.isZeroLength(); }	/**	 * Method to return the rotation angle of this ArcInst.     * This is an angle of direction from tailLocation to headLocation.	 * @return the rotation angle of this ArcInst (in tenth-degrees).	 */	public int getAngle() { return d.getAngle(); }

⌨️ 快捷键说明

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