📄 primitivenode.java
字号:
* @param minSizeRule name of minimal size rule * @param offset the offset from the edges of the reported/selected part of the PrimitiveNode. * @param layers the Layers that comprise the PrimitiveNode. * @return the newly created PrimitiveNode. */ public static PrimitiveNode newInstance(String protoName, Technology tech, double width, double height, String minSizeRule, SizeOffset offset, Technology.NodeLayer [] layers) { EPoint sizeCorrector = EPoint.fromLambda(0.5*width, 0.5*height); if (offset == null) offset = new SizeOffset(0,0,0,0); long lx = -sizeCorrector.getGridX() + offset.getLowXGridOffset(); long hx = sizeCorrector.getGridX() - offset.getHighXGridOffset(); long ly = -sizeCorrector.getGridY() + offset.getLowYGridOffset(); long hy = sizeCorrector.getGridY() - offset.getHighYGridOffset(); ERectangle fullRectangle = ERectangle.fromGrid(-sizeCorrector.getGridX(), -sizeCorrector.getGridY(), 2*sizeCorrector.getGridX(), 2*sizeCorrector.getGridY()); ERectangle baseRectangle = ERectangle.fromGrid(lx, ly, hx - lx, hy - ly); EPoint sizeCorrector2 = EPoint.fromGrid(baseRectangle.getGridWidth() >> 1, baseRectangle.getGridHeight() >> 1); return newInstance(protoName, tech, sizeCorrector, sizeCorrector2, minSizeRule, width, height, fullRectangle, baseRectangle, layers); } /** * 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. * @param offset the offset from the edges of the reported/selected part of the PrimitiveNode. * @param layers the Layers that comprise the PrimitiveNode. * @return the newly created PrimitiveNode. */ public static PrimitiveNode newInstance(String protoName, Technology tech, double width, double height, SizeOffset offset, Technology.NodeLayer [] layers) { return newInstance(protoName, tech, width, height, null, offset, layers); } /** * Method to create a new PrimitiveNode from the parameters. * PrimitiveNode has zero size corrector. * @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. * @param layers the Layers that comprise the PrimitiveNode. * @return the newly created PrimitiveNode. */ public static PrimitiveNode newInstance0(String protoName, Technology tech, double width, double height, Technology.NodeLayer [] layers) { return newInstance(protoName, tech, EPoint.ORIGIN, EPoint.ORIGIN, null, width, height, ERectangle.ORIGIN, ERectangle.ORIGIN, layers); } /** * Method to create a new PrimitiveNode from the parameters. * @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 sizeCorrector size corrector for the PrimitiveNode, * @param width the width of the PrimitiveNode. * @param height the height of the PrimitiveNode. * @param baseRectangle the reported/selected part of the PrimitiveNode with standard size. * @param layers the Layers that comprise the PrimitiveNode. * @return the newly created PrimitiveNode. */ static PrimitiveNode newInstance(String protoName, Technology tech, EPoint sizeCorrector1, EPoint sizeCorrector2, String minSizeRule, double width, double height, ERectangle fullRectangle, ERectangle baseRectangle, Technology.NodeLayer [] layers) { // check the arguments if (tech.findNodeProto(protoName) != null) { System.out.println("Error: technology " + tech.getTechName() + " has multiple nodes named " + protoName); return null; } if (width < 0.0 || height < 0.0) { System.out.println("Error: technology " + tech.getTechName() + " node " + protoName + " has negative size"); return null; } PrimitiveNode pn = new PrimitiveNode(protoName, tech, sizeCorrector1, sizeCorrector2, minSizeRule, width, height, fullRectangle, baseRectangle, layers); return pn; } static PrimitiveNode makeArcPin(ArcProto ap, String pinName, String portName, double elibSize0, double elibSize1, ArcProto ... extraArcs) { Technology tech = ap.getTechnology(); Technology.NodeLayer[] nodeLayers = new Technology.NodeLayer[ap.getNumArcLayers()]; for (int i = 0; i < ap.getNumArcLayers(); i++) { Layer layer = ap.getLayer(i); if (layer.getPseudoLayer() == null) layer.makePseudo(); layer = layer.getPseudoLayer(); nodeLayers[i] = new Technology.NodeLayer(layer, 0, Poly.Type.CROSSED, Technology.NodeLayer.BOX, null); } EPoint sizeCorrector1 = EPoint.fromLambda(elibSize0, elibSize0); EPoint sizeCorrector2 = EPoint.fromLambda(elibSize1, elibSize1); PrimitiveNode arcPin = newInstance(pinName, tech, sizeCorrector1, sizeCorrector2, null, 0, 0, ERectangle.ORIGIN, ERectangle.ORIGIN, nodeLayers); ArcProto[] connections = new ArcProto[1 + extraArcs.length]; connections[0] = ap; System.arraycopy(extraArcs, 0, connections, 1, extraArcs.length); arcPin.addPrimitivePorts(new PrimitivePort [] { PrimitivePort.newInstance(tech, arcPin, connections, portName, 0,180, 0, PortCharacteristic.UNKNOWN, EdgeH.fromLeft(0), EdgeV.fromBottom(0), EdgeH.fromRight(0), EdgeV.fromTop(0)) }); arcPin.setFunction(PrimitiveNode.Function.PIN); arcPin.setArcsWipe(); arcPin.setArcsShrink(); if (ap.isSkipSizeInPalette() || ap.isSpecialArc()) arcPin.setSkipSizeInPalette(); arcPin.resizeArcPin(); return arcPin; } void resizeArcPin() { assert function == PrimitiveNode.Function.PIN; assert getNumPorts() == 1; PrimitivePort port = getPort(0); ArcProto ap = port.getConnections()[0]; long fullExtend = ap.getMaxLayerGridExtend(); fullRectangle = ERectangle.fromGrid(-fullExtend, -fullExtend, 2*fullExtend, 2*fullExtend); long baseExtend = ap.getGridBaseExtend(); baseRectangle = ERectangle.fromGrid(-baseExtend, -baseExtend, 2*baseExtend, 2*baseExtend); double sizeOffset = DBMath.gridToLambda(fullExtend - baseExtend); offset = new SizeOffset(sizeOffset, sizeOffset, sizeOffset, sizeOffset); assert ap.getNumArcLayers() == layers.length; for (int arcLayerIndex = 0; arcLayerIndex < layers.length; arcLayerIndex++) { Technology.NodeLayer nl = layers[arcLayerIndex]; double indent = DBMath.gridToLambda(fullExtend - ap.getLayerGridExtend(arcLayerIndex)); nl.setPoints(Technology.TechPoint.makeIndented(indent)); } port.getLeft().setAdder(-fullRectangle.getLambdaMinX()); port.getRight().setAdder(-fullRectangle.getLambdaMaxX()); port.getBottom().setAdder(-fullRectangle.getLambdaMinY()); port.getTop().setAdder(-fullRectangle.getLambdaMaxY()); } /** Method to return NodeProtoId of this NodeProto. * NodeProtoId identifies NodeProto independently of threads. * PrimitiveNodes are shared among threads, so this method returns this PrimitiveNode. * @return NodeProtoId of this NodeProto. */ public PrimitiveNodeId getId() { return protoId; } /** * Method to return the name of this PrimitiveNode in the Technology. * @return the name of this PrimitiveNode. */ public String getName() { return protoId.name; } /** * Method to return the full name of this PrimitiveNode. * Full name has format "techName:primName" * @return the full name of this PrimitiveNode. */ public String getFullName() { return protoId.fullName; } /** * Method to set the function of this PrimitiveNode. * The Function is a technology-independent description of the behavior of this PrimitiveNode. * @param function the new function of this PrimitiveNode. */ public void setFunction(Function function) { checkChanging(); this.function = function; } /** * Method to return the function of this PrimitiveNode. * The Function is a technology-independent description of the behavior of this PrimitiveNode. * @return the function of this PrimitiveNode. */ public Function getFunction() { return function; } /** * Method to return the function of this PrimitiveNode, grouped according to its * general function. * For example, all transistors return the same value. * @return the group function of this PrimitiveNode. */ public Function getGroupFunction() { if (function.isTransistor) return Function.TRANS; if (function.isResistor() || function.isCapacitor() || function == Function.DIODE || function == Function.DIODEZ || function == Function.INDUCT) return Function.INDUCT; if (function == Function.CCVS || function == Function.CCCS || function == Function.VCVS || function == Function.VCCS || function == Function.TLINE) return Function.TLINE; if (function == Function.BASE || function == Function.EMIT || function == Function.COLLECT) return Function.COLLECT; if (function == Function.BUFFER || function == Function.GATEAND || function == Function.GATEOR || function == Function.MUX || function == Function.GATEXOR) return Function.GATEXOR; if (function == Function.CONPOWER || function == Function.CONGROUND) return Function.CONGROUND; if (function == Function.METER || function == Function.SOURCE) return Function.SOURCE; if (function == Function.SUBSTRATE || function == Function.WELL) return Function.CONTACT; return function; } /** * Method to tell whether this primitive node prototype has technology-specific information on it. * At the current time, only certain Schematics primitives have this information. * @return true this primitive node prototype has technology-specific information on it. */ public boolean isTechSpecific() { if (this == Schematics.tech().transistorNode || this == Schematics.tech().transistor4Node || this == Schematics.tech().flipflopNode || this == Schematics.tech().diodeNode || this == Schematics.tech().inductorNode || this == Schematics.tech().resistorNode || this == Schematics.tech().capacitorNode) return true; return false; } /** * Method to return the list of Layers that comprise this PrimitiveNode. * @return the list of Layers that comprise this PrimitiveNode. */ public Technology.NodeLayer [] getLayers() { return layers; } /** * Method to reset the list of Layers that comprise this PrimitiveNode. * @param layers */ public void setLayers(Technology.NodeLayer [] layers) { this.layers = layers; resetAllVisibility(); } /** * Method to return an iterator over the layers in this PrimitiveNode. * @return an iterator over the layers in this PrimitiveNode. */ public Iterator<Layer> getLayerIterator() { return new NodeLayerIterator(layers); } /** * Iterator for Layers on this NodeProto */ private static class NodeLayerIterator implements Iterator<Layer> { Technology.NodeLayer [] array; int pos; public NodeLayerIterator(Technology.NodeLayer [] 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 return the list of electrical Layers that comprise this PrimitiveNode. * Like the list returned by "getLayers", the results describe this PrimitiveNode,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -