📄 arcproto.java
字号:
// /**// * Method to return the array of layers that comprise this ArcProto.// * @return the array of layers that comprise this ArcProto.// */// public Iterator<Technology.ArcLayer> getArcLayers() { return ArrayIterator.iterator(layers); } /** * Method to return an iterator over the layers in this ArcProto. * @return an iterator over the layers in this ArcProto. */ public Iterator<Layer> getLayerIterator() { return new LayerIterator(layers); } /** * Iterator for Layers on this ArcProto */ private static class LayerIterator implements Iterator<Layer> { Technology.ArcLayer [] array; int pos; public LayerIterator(Technology.ArcLayer [] a) { array = a; pos = 0; } public boolean hasNext() { return pos < array.length; } public Layer next() throws NoSuchElementException { if (pos >= array.length) throw new NoSuchElementException(); return array[pos++].getLayer(); } public void remove() throws UnsupportedOperationException, IllegalStateException { throw new UnsupportedOperationException(); } }// /**// * Method to find the ArcLayer on this ArcProto with a given Layer.// * If there are more than 1 with the given Layer, the first is returned.// * @param layer the Layer to find.// * @return the ArcLayer that has this Layer.// */// public Technology.ArcLayer findArcLayer(Layer layer)// {// for(int j=0; j<layers.length; j++)// {// Technology.ArcLayer oneLayer = layers[j];// if (oneLayer.getLayer() == layer) return oneLayer;// }// return null;// } /** * Method to find an index of Layer in a list of Layers that comprise this ArcProto. * If this layer is not in the list, return -1 * @param layer the Layer to find. * @return an index of Layer in a list of Layers that comprise this ArcProto, or -1. */ public int indexOf(Layer layer) { for (int arcLayerIndex = 0; arcLayerIndex < layers.length; arcLayerIndex++) { if (layers[arcLayerIndex].getLayer() == layer) return arcLayerIndex; } return -1; } /** * Resizes this ArcProto according to rules from the DistanceContext * @param context context to find rules by name */ void resize(Technology.DistanceContext context) { for (Technology.ArcLayer al: layers) al.resize(context, this); gridBaseExtend = layers[0].getGridExtend(); lambdaBaseExtend = DBMath.gridToLambda(gridBaseExtend); computeLayerGridExtendRange(); if (arcPin != null) arcPin.resizeArcPin(); }// /**// * Method to set the surround distance of layer "outerlayer" from layer "innerlayer"// * in arc "aty" to "surround".// */// protected void setArcLayerSurroundLayer(Layer outerLayer, Layer innerLayer,// double surround)// {// // find the inner layer// int inLayerIndex = indexOf(innerLayer);// if (inLayerIndex < 0)// {// System.out.println("Internal error in " + tech.getTechDesc() + " surround computation. Arc layer '" +// innerLayer.getName() + "' is not valid in '" + getName() + "'");// return;// }//// // find the outer layer// int i = indexOf(outerLayer);//// if (i < 0)// {// System.out.println("Internal error in " + tech.getTechDesc() + " surround computation. Arc layer '" +// outerLayer.getName() + "' is not valid in '" + getName() + "'");// return;// }//// // compute the indentation of the outer layer// long extent = layers[inLayerIndex].getGridExtend() + DBMath.lambdaToGrid(surround);// layers[i] = layers[i].withGridExtend(extent);//// long indent = layers[inLayerIndex].getGridOffset() - DBMath.lambdaToGrid(surround)*2;//// layers[i] = layers[i].withGridOffset(indent);// computeLayerGridExtendRange();// } void computeLayerGridExtendRange() { long min = Long.MAX_VALUE, max = Long.MIN_VALUE; for (int i = 0; i < layers.length; i++) { Technology.ArcLayer primLayer = layers[i]; assert indexOf(primLayer.getLayer()) == i; // layers are unique min = Math.min(min, getLayerGridExtend(i)); max = Math.max(max, getLayerGridExtend(i)); } assert -Integer.MAX_VALUE/8 < min;// assert 0 <= min; assert max < Integer.MAX_VALUE/8 && min <= max; minLayerGridExtend = (int)min; maxLayerGridExtend = (int)max; if (arcPin != null) arcPin.resizeArcPin(); } /** * Method to get MinZ and MaxZ of this ArcProto * @param array array[0] is minZ and array[1] is max */ public void getZValues(double [] array) { for(int j=0; j<layers.length; j++) { Layer layer = layers[j].getLayer(); double distance = layer.getDistance(); double thickness = layer.getThickness(); double z = distance + thickness; array[0] = (array[0] > distance) ? distance : array[0]; array[1] = (array[1] < z) ? z : array[1]; } } /** * Returns the polygons that describe dummy arc of this ArcProto * with default width and specified length. * @param lambdaLength length of dummy arc in lambda units. * @return an array of Poly objects that describes dummy arc graphically. */ public Poly[] getShapeOfDummyArc(double lambdaLength) { long l2 = DBMath.lambdaToGrid(lambdaLength/2); // see how many polygons describe this arc Poly [] polys = new Poly[layers.length];// Point2D.Double headLocation = new Point2D.Double(lambdaLength/2, 0);// Point2D.Double tailLocation = new Point2D.Double(-lambdaLength/2, 0); for (int i = 0; i < layers.length; i++) { long gridWidth = 2*(getDefaultGridExtendOverMin() + getLayerGridExtend(i));// long gridWidth = getDefaultGridFullWidth() - primLayer.getGridOffset(); Poly.Type style = getLayerStyle(i); Point2D.Double[] points; if (gridWidth == 0) { points = new Point2D.Double[]{ new Point2D.Double(-l2, 0), new Point2D.Double(l2, 0)}; if (style == Poly.Type.FILLED) style = Poly.Type.OPENED; } else { long w2 = gridWidth/2; assert w2 > 0; points = new Point2D.Double[] { new Point2D.Double(-l2-w2, w2), new Point2D.Double(-l2-w2, -w2), new Point2D.Double(l2+w2, -w2), new Point2D.Double(l2+w2, w2) }; if (style.isOpened()) points = new Point2D.Double[] { points[0], points[1], points[2], points[3], (Point2D.Double)points[0].clone() }; } Poly poly = new Poly(points); poly.gridToLambda(); poly.setStyle(style); poly.setLayer(getLayer(i)); polys[i] = poly; } return polys; } /** * Method to describe this ArcProto as a string. * Prepends the Technology name if it is * not from the current technology (for example, "mocmos:Polysilicon-1"). * @return a String describing this ArcProto. */ public String describe() { String description = ""; Technology tech = getTechnology(); if (Technology.getCurrent() != tech) description += tech.getTechName() + ":"; description += getName(); return description; } /** * Compares ArcProtos by their Technologies and definition order. * @param that the other ArcProto. * @return a comparison between the ArcProto. */ public int compareTo(ArcProto that) { if (this.tech != that.tech) { int cmp = this.tech.compareTo(that.tech); if (cmp != 0) return cmp; } return this.primArcIndex - that.primArcIndex; } /** * Returns a printable version of this ArcProto. * @return a printable version of this ArcProto. */ @Override public String toString() { return "arc " + describe(); } void dump(PrintWriter out) { out.println("ArcProto " + getName() + " " + getFunction()); out.println("\tisWipable=" + isWipable()); out.println("\tisCurvable=" + isCurvable()); out.println("\tisSpecialArc=" + isSpecialArc()); out.println("\tisEdgeSelect=" + isEdgeSelect()); out.println("\tisNotUsed=" + isNotUsed()); out.println("\tisSkipSizeInPalette=" + isSkipSizeInPalette()); Technology.printlnPref(out, 1, defaultExtendPrefs.get(this)); out.println("\tbaseExtend=" + getLambdaBaseExtend()); out.println("\tdefaultLambdaBaseWidth=" + getDefaultLambdaBaseWidth()); out.println("\tdiskOffset1=" + DBMath.round(getLambdaBaseExtend() + 0.5*getLambdaElibWidthOffset())); out.println("\tdiskOffset2=" + getLambdaBaseExtend()); Technology.printlnPref(out, 1, defaultAnglePrefs.get(this)); Technology.printlnPref(out, 1, defaultRigidPrefs.get(this)); Technology.printlnPref(out, 1, defaultFixedAnglePrefs.get(this)); Technology.printlnPref(out, 1, defaultExtendedPrefs.get(this)); Technology.printlnPref(out, 1, defaultDirectionalPrefs.get(this)); for (Technology.ArcLayer arcLayer: layers) arcLayer.dump(out); } Xml.ArcProto makeXml() { Xml.ArcProto a = new Xml.ArcProto(); a.name = getName(); for (Map.Entry<String,ArcProto> e: tech.getOldArcNames().entrySet()) { if (e.getValue() != this) continue; assert a.oldName == null; a.oldName = e.getKey(); } a.function = getFunction(); a.wipable = isWipable(); a.curvable = isCurvable(); a.special = isSpecialArc(); a.notUsed = isNotUsed(); a.skipSizeInPalette = isSkipSizeInPalette(); double correction2 = DBMath.round(getLambdaBaseExtend()); double correction1 = DBMath.round(correction2 + 0.5*getLambdaElibWidthOffset()); if (correction1 != correction2) a.diskOffset.put(Integer.valueOf(1), correction1); if (correction2 != 0) a.diskOffset.put(Integer.valueOf(2), correction2); a.extended = isExtended(); a.fixedAngle = isFixedAngle(); a.angleIncrement = getAngleIncrement(); a.antennaRatio = ERC.getERCTool().getAntennaRatio(this); for (Technology.ArcLayer arcLayer: layers) a.arcLayers.add(arcLayer.makeXml());// if (arcPin != null) {// a.arcPin = new Xml.ArcPin();// a.arcPin.name = arcPin.getName();// PrimitivePort port = arcPin.getPort(0);// a.arcPin.portName = port.getName();// a.arcPin.elibSize = 2*arcPin.getSizeCorrector(0).getX();// for (ArcProto cap: port.getConnections()) {// if (cap.getTechnology() == tech && cap != this)// a.arcPin.portArcs.add(cap.getName());// }//// } return a; } XmlParam.ArcProto makeXmlParam() { XmlParam.ArcProto a = new XmlParam.ArcProto(); a.name = getName(); for (Map.Entry<String,ArcProto> e: tech.getOldArcNames().entrySet()) { if (e.getValue() != this) continue; assert a.oldName == null; a.oldName = e.getKey(); } a.function = getFunction(); a.wipable = isWipable(); a.curvable = isCurvable(); a.special = isSpecialArc(); a.notUsed = isNotUsed(); a.skipSizeInPalette = isSkipSizeInPalette(); a.elibWidthOffset = getLambdaElibWidthOffset(); a.extended = isExtended(); a.fixedAngle = isFixedAngle(); a.angleIncrement = getAngleIncrement(); a.antennaRatio = ERC.getERCTool().getAntennaRatio(this); for (Technology.ArcLayer arcLayer: layers) a.arcLayers.add(arcLayer.makeXmlParam()); if (arcPin != null) { a.arcPin = new XmlParam.ArcPin(); a.arcPin.name = arcPin.getName(); PrimitivePort port = arcPin.getPort(0); a.arcPin.portName = port.getName(); a.arcPin.elibSize = 2*arcPin.getSizeCorrector(0).getX(); for (ArcProto cap: port.getConnections()) { if (cap.getTechnology() == tech && cap != this) a.arcPin.portArcs.add(cap.getName()); } } return a; } /** * Method to check invariants in this ArcProto. * @exception AssertionError if invariants are not valid */ void check() { assert protoId.techId == tech.getId(); for (Technology.ArcLayer primLayer: layers) { long gridExtend = getLayerGridExtend(primLayer.getLayer()); assert minLayerGridExtend <= gridExtend && gridExtend <= maxLayerGridExtend; } assert lambdaElibWidthOffset >= 0; assert 0 <= gridBaseExtend && gridBaseExtend <= maxLayerGridExtend; assert gridBaseExtend == getLayerGridExtend(0); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -