📄 primitiveport.java
字号:
*/ public EdgeV getBottom() { return bottom; } /** * Method to return the PortCharacteristic of this PortProto. * @return the PortCharacteristic of this PortProto. */ public PortCharacteristic getCharacteristic() { return characteristic; } /** * Method to determine whether this PrimitivePort is of type Power. * This is determined by having the proper PortCharacteristic. * @return true if this PrimitivePort is of type Power. */ public boolean isPower() { return characteristic == PortCharacteristic.PWR; } /** * Method to determine whether this PrimitivePort is of type Ground. * This is determined by having the proper PortCharacteristic. * @return true if this PrimitivePort is of type Ground. */ public boolean isGround() { return characteristic == PortCharacteristic.GND; } /** Set of all well ports */ private static Set<PortProto> wellPorts = null; /** * Method to tell whether this portproto is a "well" port on a transistor (for bias connections). * @return true if this is a Well port on a transistor. */ public boolean isWellPort() { if (wellPorts == null) { wellPorts = new HashSet<PortProto>(); for(Iterator<Technology> it = Technology.getTechnologies(); it.hasNext(); ) { Technology tech = it.next(); for(Iterator<PrimitiveNode> nIt = tech.getNodes(); nIt.hasNext(); ) { PrimitiveNode pnp = nIt.next(); if (!pnp.getFunction().isFET()) continue; for(Iterator<PrimitivePort> pIt = pnp.getPrimitivePorts(); pIt.hasNext(); ) { PrimitivePort pp = pIt.next(); // see if the port connects to active or poly ArcProto [] connections = pp.getConnections(); boolean activeOrPoly = false; for(int i=0; i<connections.length; i++) { ArcProto con = connections[i]; if (con.getTechnology() == Generic.tech()) continue; if (con.getFunction().isDiffusion() || con.getFunction().isPoly()) { activeOrPoly = true; break; } } if (!activeOrPoly) wellPorts.add(pp); } } } } return wellPorts.contains(this); } /** * Method to determine whether this PortProto has a name that suggests Ground. * This is determined by either having a name starting with "vss", "gnd", or "ground". * @return true if this PortProto has a name that suggests Ground. */ public boolean isNamedGround() { String name = TextUtils.canonicString(getName()); if (name.indexOf("vss") >= 0) return true; if (name.indexOf("gnd") >= 0) return true; if (name.indexOf("ground") >= 0) return true; return false; } /** * Method to return the angle of this PrimitivePort. * This is the primary angle that the PrimitivePort faces on the PrimitveNode. * @return the angle of this PrimitivePort. */ public int getAngle() { return angle; } /** * Method to set the angle of this PrimitvePort. * This is the primary angle that the PrimitivePort faces on the PrimitiveNode. * @param angle the angle of this PrimitivePort. */ void setAngle(int angle) { this.angle = angle; } /** * Method to return the angle range of this PrimitvePort. * This is the range about the angle of allowable connections. * When this value is 180, then all angles are permissible, since arcs * can connect at up to 180 degrees in either direction from the port angle. * @return the angle range of this PrimitivePort. */ public int getAngleRange() { return angleRange; } /** * Method to set the angle range of this PrimitivePort. * This is the range about the angle of allowable connections. * When this value is 180, then all angles are permissible, since arcs * can connect at up to 180 degrees in either direction from the port angle. * @param angleRange the angle range of this PrimitivePort. */ void setAngleRange(int angleRange) { this.angleRange = angleRange; } /** * Method to get the topology of this PrimitivePort. * This is a small integer that is unique among PrimitivePorts on this PrimitiveNode. * When two PrimitivePorts have the same topology number, it indicates that these * ports are connected. * @return the topology of this PrimitvePort. */ public int getTopology() { return portTopology; } /** * Method to set this PrimitivePort to be isolated. * Isolated ports do not electrically connect their arcs. * This occurs in the multiple inputs to a schematic gate that all connect to the same port but do not themselves connect. */ public void setIsolated() { isolated = true; } /** * Method to tell whether this PrimitivePort is isolated. * Isolated ports do not electrically connect their arcs. * This occurs in the multiple inputs to a schematic gate that all connect to the same port but do not themselves connect. * @return true if this PrimitivePort is isolated. */ public boolean isIsolated() { return isolated; } /** * Method to tell whether this type of port can be negated. * @return true if this type of port can be negated. */ public boolean isNegatable() { return negatable; } /** * Method to tell set this type of port can be negated. * @param negatable true if this type of port can be negated. */ public void setNegatable(boolean negatable) { this.negatable = negatable; } /** * Method to return true if this PrimitivePort can connect to an arc of a given type. * @param arc the ArcProto to test for connectivity. * @return true if this PrimitivePort can connect to the arc, false if it can't */ public boolean connectsTo(ArcProto arc) { for (int i = 0; i < portArcs.length; i++) { if (portArcs[i] == arc) return true; } return parent.getTechnology().isUniversalConnectivityPort(this); } /** * Method to compute the color of this PrimitivePort. * Combines all arcs that can connect. * @return the color to use for this PrimitivePort. */ public Color getPortColor() { Technology tech = getParent().getTechnology(); int numColors = 0; int r=0, g=0, b=0; for (int i = 0; i < portArcs.length; i++) { ArcProto ap = portArcs[i]; // ignore the generic arcs if (ap.getTechnology() != tech) continue; // get the arc's color Layer layer = ap.getLayer(0); EGraphics graphics = layer.getGraphics(); Color layerCol = graphics.getColor(); r += layerCol.getRed(); g += layerCol.getGreen(); b += layerCol.getBlue(); numColors++; } if (numColors == 0) return null; return new Color(r/numColors, g/numColors, b/numColors); } /** * Compares PrimtivePorts by their PrimitiveNodes and definition order. * @param that the other PrimitivePort. * @return a comparison between the PrimitivePorts. */ public int compareTo(PrimitivePort that) { if (this.parent != that.parent) { int cmp = this.parent.compareTo(that.parent); if (cmp != 0) return cmp; } return this.portIndex - that.portIndex; } /** * Returns a printable version of this PrimitivePort. * @return a printable version of this PrimitivePort. */ public String toString() { return "PrimitivePort " + getName(); } void dump(PrintWriter out) { out.println("\tport " + getName() + " angle=" + getAngle() + " range=" + getAngleRange() + " topology=" + getTopology() + " " + getCharacteristic()); out.println("\t\tlm=" + left.getMultiplier() + " la=" + left.getAdder() + " rm=" + right.getMultiplier() + " ra=" + right.getAdder() + " bm=" + bottom.getMultiplier() + " ba=" + bottom.getAdder() + " tm=" + top.getMultiplier() + " ta=" + top.getAdder()); out.println("\t\tisolated=" + isolated + " negatable=" + negatable); for (ArcProto ap: portArcs) out.println("\t\tportArc " + ap.getName()); } Xml.PrimitivePort makeXml(EPoint minFullSize) { Xml.PrimitivePort ppd = new Xml.PrimitivePort(); ppd.name = getName(); ppd.portAngle = getAngle(); ppd.portRange = getAngleRange(); ppd.portTopology = getTopology(); ppd.lx.k = getLeft().getMultiplier()*2; ppd.lx.addLambda(DBMath.round(getLeft().getAdder() + minFullSize.getLambdaX()*getLeft().getMultiplier()*2)); ppd.hx.k = getRight().getMultiplier()*2; ppd.hx.addLambda(DBMath.round(getRight().getAdder() + minFullSize.getLambdaX()*getRight().getMultiplier()*2)); ppd.ly.k = getBottom().getMultiplier()*2; ppd.ly.addLambda(DBMath.round(getBottom().getAdder() + minFullSize.getLambdaY()*getBottom().getMultiplier()*2)); ppd.hy.k = getTop().getMultiplier()*2; ppd.hy.addLambda(DBMath.round(getTop().getAdder() + minFullSize.getLambdaY()*getTop().getMultiplier()*2)); Technology tech = parent.getTechnology(); for (ArcProto ap: getConnections()) { if (ap.getTechnology() != tech) continue; ppd.portArcs.add(ap.getName()); } return ppd; } XmlParam.PrimitivePort makeXmlParam(EPoint minFullSize) { XmlParam.PrimitivePort ppd = new XmlParam.PrimitivePort(); ppd.name = getName(); ppd.portAngle = getAngle(); ppd.portRange = getAngleRange(); ppd.portTopology = getTopology(); ppd.lx.k = getLeft().getMultiplier()*2; ppd.lx.addLambda(DBMath.round(getLeft().getAdder() + minFullSize.getLambdaX()*getLeft().getMultiplier()*2)); ppd.hx.k = getRight().getMultiplier()*2; ppd.hx.addLambda(DBMath.round(getRight().getAdder() + minFullSize.getLambdaX()*getRight().getMultiplier()*2)); ppd.ly.k = getBottom().getMultiplier()*2; ppd.ly.addLambda(DBMath.round(getBottom().getAdder() + minFullSize.getLambdaY()*getBottom().getMultiplier()*2)); ppd.hy.k = getTop().getMultiplier()*2; ppd.hy.addLambda(DBMath.round(getTop().getAdder() + minFullSize.getLambdaY()*getTop().getMultiplier()*2)); Technology tech = parent.getTechnology(); for (ArcProto ap: getConnections()) { if (ap.getTechnology() != tech) continue; ppd.portArcs.add(ap.getName()); } return ppd; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -