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

📄 sue.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
						if (keyword1.equalsIgnoreCase(curEquivs[i].sueName)) break;					if (i < curEquivs.length)					{						proto = curEquivs[i].intProto;						invertOutput = curEquivs[i].netateOutput;						rotation = curEquivs[i].rotation;						transpose = curEquivs[i].transpose;                        AffineTransform trans = Orientation.fromC(parP.rot, parP.trn).pureRotate();						Point2D offPt = new Point2D.Double(curEquivs[i].xOffset, curEquivs[i].yOffset);						trans.transform(offPt, offPt);						xOff = offPt.getX();   yOff = offPt.getY();						if (transpose)						{							parP.trn = !parP.trn;							parP.rot = rotation - parP.rot;							if (parP.rot < 0) parP.rot += 3600;						} else						{							parP.rot += rotation;							if (parP.rot >= 3600) parP.rot -= 3600;						}						detailFunct = curEquivs[i].detailFunct;						extraWires = curEquivs[i].extraWires;					}				}				// now check for references to cells				if (proto == null)				{					// find node or read it from disk					proto = getNodeProto(lib, keyword1);					if (proto == null)						proto = readFromDisk(lib, keyword1);					// set proper offsets for the cell					if (proto != null)					{						Cell np = ((Cell)proto).iconView();						if (np != null) proto = np;					}				}				// ignore "title" specifications				if (keyword1.startsWith("title_")) continue;				// stop now if SUE node is unknown				if (proto == null)				{					System.out.println("Cell " + cellName + ", line " + lr.getLineNumber() +						", cannot create instance of " + keyword1 + " (no Sue object with that name)");					continue;				}				// create the instance				double wid = proto.getDefWidth();				double hei = proto.getDefHeight();				if (proto instanceof Cell)				{					Rectangle2D bounds = ((Cell)proto).getBounds();					wid = bounds.getWidth();					hei = bounds.getHeight();				}				wid -= xShrink;				hei -= yShrink;				Orientation or = Orientation.fromC(parP.rot, parP.trn);				parP.rot = or.getAngle();				NodeInst ni = NodeInst.makeInstance(proto, new Point2D.Double(parP.pt.getX() + xOff, parP.pt.getY() + yOff), wid, hei, cell,					or, null, Schematics.getPrimitiveFunctionBits(detailFunct));				if (ni == null) continue;				if (invertOutput) invertNodeOutput.add(ni);				if (proto instanceof Cell && ((Cell)proto).isIcon())					ni.setExpanded();				// add any extra wires to the node				if (extraWires != null)				{					for(int i=0; i<extraWires.length; i++)					{						PortProto pp = proto.findPortProto(extraWires[i].portName);						if (pp == null) continue;						PortInst pi = ni.findPortInstFromProto(pp);						Poly portPoly = pi.getPoly();						double x = portPoly.getCenterX();						double y = portPoly.getCenterY();						AffineTransform trans = ni.getOrient().pureRotate();						Point2D dPt = new Point2D.Double(extraWires[i].xOffset, extraWires[i].yOffset);						trans.transform(dPt, dPt);						PrimitiveNode wirePin = Schematics.tech().wirePinNode;						double pinx = x + dPt.getX();						double piny = y + dPt.getY();						PortInst ppi = findPinNode(pinx, piny, cell);						if (ppi == null)						{							NodeInst nni = NodeInst.makeInstance(Schematics.tech().wirePinNode, new Point2D.Double(pinx, piny),								wirePin.getDefWidth(), wirePin.getDefHeight(), cell);							if (nni == null) continue;							ppi = nni.getOnlyPortInst();						}						ArcInst ai = ArcInst.makeInstanceBase(Schematics.tech().wire_arc, 0, pi, ppi);						if (ai == null)						{							System.out.println("Cell " + cellName + ", line " + lr.getLineNumber() +								", error adding extra wires to node " + keyword1);							break;						}						if (x != pinx && y != piny) ai.setFixedAngle(false);					}				}				// handle names assigned to the node				if (parP.theName != null)				{					// export a port if this is an input, output, inout					if (proto == Schematics.tech().offpageNode && parP.theName != null)					{						Iterator<PortInst> it = ni.getPortInsts();						PortInst pi = it.next();						if (keyword1.equalsIgnoreCase("output")) pi = it.next();						Export ppt = newExport(cell, pi, parP.theName, type);						if (ppt == null)						{							System.out.println("Cell " + cellName + ", line " + lr.getLineNumber() +								", could not create export " + parP.theName);						}					} else					{						// just name the node						NodeInst oNi = cell.findNode(parP.theName);						if (oNi == null) ni.setName(parP.theName); else						{							List<NodeInst> dups = duplicateNames.get(parP.theName);							if (dups == null)							{								dups = new ArrayList<NodeInst>();								dups.add(ni);								duplicateNames.put(parP.theName, dups);							}							dups.add(oNi);						}					}				}				// count the variables				int varCount = 0;				for(int i=2; i<count; i += 2)				{					String keyword = keywords.get(i);					if (!keyword.startsWith("-")) continue;					if (keyword.equalsIgnoreCase("-origin") ||						keyword.equalsIgnoreCase("-orient") ||						keyword.equalsIgnoreCase("-type") ||						keyword.equalsIgnoreCase("-name")) continue;					varCount++;				}				// add variables				int varIndex = 1;				double varOffset = ni.getYSize() / (varCount+1);				for(int i=2; i<count; i += 2)				{					String keyword = keywords.get(i);					if (!keyword.startsWith("-")) continue;					if (keyword.equalsIgnoreCase("-origin") ||						keyword.equalsIgnoreCase("-orient") ||						keyword.equalsIgnoreCase("-type") ||						keyword.equalsIgnoreCase("-name")) continue;					boolean halveSize = false;					boolean isParam = false;					double xpos = 0, ypos = 0;					String sueVarName = null;					if (keyword.charAt(1) == 'w')					{						sueVarName = "ATTR_width";						xpos = 2;						ypos = -4;					} else if (keyword.charAt(1) == 'l')					{						sueVarName = "ATTR_length";						xpos = -2;						ypos = -4;						halveSize = true;					} else if (keyword.substring(1).equals("capacitance") && proto == Schematics.tech().capacitorNode)					{						sueVarName = Schematics.SCHEM_CAPACITANCE.getName();					} else if (keyword.substring(1).equals("resistance") && proto == Schematics.tech().resistorNode)					{						sueVarName = Schematics.SCHEM_RESISTANCE.getName();					} else					{						sueVarName = "ATTR_" + keyword.substring(1);						if (sueVarName.indexOf(' ') >= 0)						{							System.out.println("Cell " + cellName + ", line " + lr.getLineNumber() +								", bad variable name: " + sueVarName);							break;						}						xpos = 0;						ypos = ni.getYSize() / 2 - varIndex * varOffset;						isParam = true;					}					Object newObject = null;					String pt = keywords.get(i+1);					if (keyword.charAt(1) == 'W' && keyword.length() > 2)					{						newObject = keyword.substring(2) + ":" + parseExpression(pt);					} else					{						int len = pt.length() - 1;						if (Character.toLowerCase(pt.charAt(len)) == 'u')						{							pt = pt.substring(0, len-1);							if (TextUtils.isANumber(pt))							{								newObject = new Double(TextUtils.convertFromDistance(TextUtils.atof(pt), Technology.getCurrent(), TextUtils.UnitScale.MICRO));							}							pt += "u";						}						if (newObject == null && TextUtils.isANumber(pt))						{							newObject = new Integer(TextUtils.atoi(pt));							if (pt.indexOf('.') >= 0 || pt.toLowerCase().indexOf('e') >= 0)							{								newObject = new Double(TextUtils.atof(pt));							}						}						if (newObject == null)						{							newObject = parseExpression(pt);						}					}					// see if the string should be Java code					boolean makeJava = false;					if (newObject instanceof String)					{						makeJava = EvalJavaBsh.evalJavaBsh.isValidJava((String)newObject);//						if (((String)newObject).indexOf('@') >= 0 ||//							((String)newObject).indexOf("p(") >= 0) makeJava = true;					}                    Variable.Key varKey = Variable.newKey(sueVarName);                    MutableTextDescriptor mtd = MutableTextDescriptor.getNodeTextDescriptor();                    varIndex++;                    mtd.setOff(xpos, ypos);                    if (halveSize) {                        if (mtd.getSize().isAbsolute())                            mtd.setAbsSize((int)(mtd.getSize().getSize() / 2)); else                                mtd.setRelSize(mtd.getSize().getSize() / 2);                    }                    if (isParam) {                        mtd.setParam(true);                        mtd.setDispPart(TextDescriptor.DispPos.NAMEVALUE);                    }                    Object instObject = newObject;                    if (makeJava) {                        instObject = Variable.withCode(newObject, CodeExpression.Code.JAVA);                    }					ni.newVar(varKey, instObject, TextDescriptor.newTextDescriptor(mtd));                    // make sure the parameter exists in the cell definition                    NodeProto np = ni.getProto();                    if (isParam && ni.isCellInstance()) {                        Cell cnp = ((Cell)np).contentsView();                        if (cnp == null) cnp = (Cell)np;                        Variable contentsVar = cnp.getParameterOrVariable(varKey);                        if (contentsVar == null) {                        	// really wanted: VTDISPLAYNAMEVALINH                            TextDescriptor td = TextDescriptor.getCellTextDescriptor().withParam(true).                            	withDispPart(TextDescriptor.DispPos.NAMEVALUE);                            newObject = Variable.withCode(newObject, CodeExpression.Code.SPICE);                            cnp.getCellGroup().addParam(Variable.newInstance(varKey, newObject, td));                        }                    }//					Variable var = ni.newDisplayVar(Variable.newKey(sueVarName), newObject);//					if (var != null)//					{////						var.setDisplay(true);//						if (makeJava) var.setCode(TextDescriptor.Code.JAVA);//						varIndex++;//						var.setOff(xpos, ypos);//						if (halveSize)//						{//							if (var.getSize().isAbsolute())//								var.setAbsSize((int)(var.getSize().getSize() / 2)); else//									var.setRelSize(var.getSize().getSize() / 2);//						}//						if (isParam)//						{//							var.setParam(true);//							var.setDispPart(TextDescriptor.DispPos.NAMEVALUE);////							// make sure the parameter exists in the cell definition//							NodeProto np = ni.getProto();//							if (ni.isCellInstance())//							{//								Cell cnp = ((Cell)np).contentsView();//								if (cnp == null) cnp = (Cell)np;//								var = cnp.getVar(sueVarName);//								if (var == null)//								{//									var = cnp.newVar(sueVarName, newObject);//									if (var != null)//									{//										var.setParam(true);//										var.setDispPart(TextDescriptor.DispPos.NAMEVALUE);  // really wanted: VTDISPLAYNAMEVALINH//									}//								}//							}//						}//					}				}				continue;			}			// handle "make_wire" for defining arcs			if (keyword0.equalsIgnoreCase("make_wire"))			{				SueWire sw = new SueWire();				double fx = convertXCoord(TextUtils.atof(keywords.get(1)));				double fy = convertYCoord(TextUtils.atof(keywords.get(2)));				sw.pt[0] = new Point2D.Double(fx, fy);				double tx = convertXCoord(TextUtils.atof(keywords.get(3)));				double ty = convertYCoord(TextUtils.atof(keywords.get(4)));				sw.pt[1] = new Point2D.Double(tx, ty);				sueWires.add(sw);				continue;			}			// handle "icon_term" for defining ports in icons			if (keyword0.equalsIgnoreCase("icon_term"))			{				ParseParameters parP = new ParseParameters(keywords, 1);				NodeProto proto = Schematics.tech().busPinNode;				double pX = proto.getDefWidth();				double pY = proto.getDefHeight();				NodeInst ni = NodeInst.makeInstance(proto, parP.pt, pX, pY, cell);				if (ni == null) continue;				PortInst pi = ni.getOnlyPortInst();				Export ppt = Export.newInstance(cell, pi, parP.theName, parP.type);				if (ppt == null)				{					System.out.println("Cell " + cellName + ", line " + lr.getLineNumber() +						", could not create port " + parP.theName);				}				continue;			}			// handle "icon_arc" for defining icon curves			if (keyword0.equalsIgnoreCase("icon_arc"))			{				if (count != 9)				{					System.out.println("Cell " + cellName + ", line " + lr.getLineNumber() +						": needs 9 arguments, has " + count + ": " + lastLineRead);					continue;				}				int start = 0;   int extent = 359;				double p1X = convertXCoord(TextUtils.atof(keywords.get(1)));				double p1Y = convertYCoord(TextUtils.atof(keywords.get(2)));				double p2X = convertXCoord(TextUtils.atof(keywords.get(3)));				double p2Y = convertYCoord(TextUtils.atof(keywords.get(4)));				if (keywords.get(5).equals("-start")) start = TextUtils.atoi(keywords.get(6));				if (keywords.get(7).equals("-extent")) extent = TextUtils.atoi(keywords.get(8));				double sX = Math.abs(p1X - p2X);				double sY = Math.abs(p1Y - p2Y);				Point2D ctr = new Point2D.Double((p1X+p2X)/2, (p1Y+p2Y)/2);				NodeInst ni = NodeInst.makeInstance(Artwork.tech().circleNode, ctr, sX, sY, cell);				if (ni == null) continue;				if (extent != 359)				{					if (extent < 0)					{						start += extent;						extent = -extent;					}					double rExtent = extent+1;					rExtent = rExtent * Math.PI / 180.0;					double rstart = start * Math.PI / 180.0;					ni.setArcDegrees(rstart, rExtent);				}				continue;			}			// handle "icon_line" for defining icon outlines			if (keyword0.equalsIgnoreCase("icon_line"))			{				List<Point2D> pointList = new ArrayList<Point2D>();				double x = 0;				for(int i=1; i<keywords.size(); i++)				{					if (keywords.get(i).equals("-tags")) break;					if ((i%2) != 0)					{						x = convertXCoord(TextUtils.atof(keywords.get(i)));					} else					{						double y = convertYCoord(TextUtils.atof(keywords.get(i)));						pointList.add(new Point2D.Double(x, y));					}				}				int keyCount = pointList.size();				if (keyCount == 0) continue;				// determine bounds of icon				Point2D firstPt = pointList.get(0);				double lX = firstPt.getX();				double hX = lX;				double lY = firstPt.getY();				double hY = lY;				for(int i=1; i<keyCount; i++)				{					Point2D nextPt = pointList.get(i);					if (nextPt.getX() < lX) lX = nextPt.getX();					if (nextPt.getX() > hX) hX = nextPt.getX();					if (nextPt.getY() < lY) lY = nextPt.getY();					if (nextPt.getY() > hY) hY = nextPt.getY();				}				double cX = (lX + hX) / 2;				double cY = (lY + hY) / 2;				Point2D ctr = new Point2D.Double(cX, cY);				NodeInst ni = NodeInst.makeInstance(Artwork.tech().openedPolygonNode, ctr, hX-lX, hY-lY, cell);				if (ni == null) return null;				EPoint [] points = new EPoint[keyCount];				for(int i=0; i<keyCount; i++)				{					Point2D pt = pointList.get(i);					points[i] = new EPoint(pt.getX(), pt.getY());				}				ni.setTrace(points);				continue;			}			// handle "icon_setup" for defining variables			if (keyword0.equalsIgnoreCase("icon_setup"))			{				// extract parameters				String keyword1 = keywords.get(1);				if (!keyword1.equalsIgnoreCase("$args"))				{					System.out.println("Cell " + cellName + ", line " + lr.getLineNumber() +						": has unrecognized 'icon_setup'");					continue;				}				String pt = keywords.get(2);				int ptLen = pt.length();				int ptPos = 0;				if (ptPos < ptLen && pt.charAt(ptPos) == '{') ptPos++;				for(;;)				{					while (ptPos < ptLen && pt.charAt(ptPos) == ' ') ptPos++;					if (ptPos >= ptLen || pt.charAt(ptPos) == '}') break;					// collect up to a space or close curly					int argStart = ptPos;					int curly = 0;					while (ptPos < ptLen)					{						char chr = pt.charAt(ptPos);						if (curly == 0)						{							if (chr == ' ' || chr == '}') break;						}						if (chr == '{') curly++;						if (chr == '}') curly--;						ptPos++;					}

⌨️ 快捷键说明

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