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

📄 sue.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
				{					NodeProto proto = Schematics.tech().wirePinNode;					if (sw.proto == Schematics.tech().bus_arc) proto = Schematics.tech().busPinNode;					NodeInst ni = NodeInst.makeInstance(proto, sw.pt[i], proto.getDefWidth(), proto.getDefHeight(), cell);					sw.pi[i] = ni.getOnlyPortInst();				}			}		}		// now make the connections		for(SueWire sw : sueWires)		{			if (sw.proto == null) sw.proto = Schematics.tech().wire_arc;//			double wid = sw.proto.getDefaultLambdaFullWidth();			// if this is a bus, make sure it can connect */			if (sw.proto == Schematics.tech().bus_arc)			{				for(int i=0; i<2; i++)				{					if (!sw.pi[i].getPortProto().getBasePort().connectsTo(Schematics.tech().bus_arc))					{						// this end cannot connect: fake the connection						double px = (sw.pt[0].getX() + sw.pt[1].getX()) / 2;						double py = (sw.pt[0].getY() + sw.pt[1].getY()) / 2;						Point2D pt = new Point2D.Double(px, py);						double xsize = Schematics.tech().busPinNode.getDefWidth();						double ysize = Schematics.tech().busPinNode.getDefHeight();						NodeInst ni = NodeInst.makeInstance(Schematics.tech().busPinNode, pt, xsize, ysize, cell);						if (ni == null) break;						PortInst pi = ni.getOnlyPortInst();						ArcInst ai = ArcInst.makeInstanceBase(Generic.tech().unrouted_arc, 0, pi, sw.pi[i]);//						ArcInst ai = ArcInst.makeInstanceFull(Generic.tech.unrouted_arc, Generic.tech.unrouted_arc.getDefaultLambdaFullWidth(), pi, sw.pi[i]);						if (ai == null)						{							System.out.println("Error making fake connection");							break;						}						sw.pi[i] = pi;						sw.pt[i] = pt;					}				}			}			ArcInst ai = ArcInst.makeInstance(sw.proto, sw.pi[0], sw.pi[1], sw.pt[0], sw.pt[1], null);//			ArcInst ai = ArcInst.makeInstanceFull(sw.proto, wid, sw.pi[0], sw.pi[1], sw.pt[0], sw.pt[1], null);			if (ai == null)			{				System.out.println(cell + ": Could not run a wire from " + sw.pi[0].getNodeInst().describe(true) + " to " +					sw.pi[1].getNodeInst().describe(true));				continue;			}			// negate the wire if requested			if (invertNodeOutput.contains(sw.pi[0].getNodeInst()) && sw.pi[0].getPortProto().getName().equals("y"))				ai.setHeadNegated(true);			if (invertNodeOutput.contains(sw.pi[1].getNodeInst()) && sw.pi[1].getPortProto().getName().equals("y"))				ai.setTailNegated(true);		}		// now look for implicit connections where "offpage" connectors touch		for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )		{			NodeInst ni = it.next();			if (ni.getProto() != Schematics.tech().offpageNode) continue;			if (ni.hasConnections()) continue;			PortInst pi = ni.getPortInst(1);			Poly piPoly = pi.getPoly();			double x = piPoly.getCenterX();			double y = piPoly.getCenterY();			Rectangle2D searchBounds = new Rectangle2D.Double(x, y, 0, 0);			for(Iterator<RTBounds> sea = cell.searchIterator(searchBounds); sea.hasNext(); )			{				RTBounds geom = sea.next();				if (!(geom instanceof NodeInst)) continue;				NodeInst oNi = (NodeInst)geom;				if (oNi == ni) continue;				boolean wired = false;				for(Iterator<PortInst> oIt = oNi.getPortInsts(); oIt.hasNext(); )				{					PortInst oPi = oIt.next();					Poly oPiPoly = oPi.getPoly();					double oX = oPiPoly.getCenterX();					double oY = oPiPoly.getCenterY();					if (oX != x || oY != y) continue;					ArcProto ap = null;					for(int i=0; i<3; i++)					{						switch (i)						{							case 0: ap = Schematics.tech().bus_arc;     break;							case 1: ap = Schematics.tech().wire_arc;    break;							case 2: ap = Generic.tech().unrouted_arc;   break;						}						if (!pi.getPortProto().getBasePort().connectsTo(ap)) continue;						if (!oPi.getPortProto().getBasePort().connectsTo(ap)) continue;						break;					}					ArcInst.makeInstance(ap, pi, oPi);//					double wid = ap.getDefaultLambdaFullWidth();//					ArcInst.makeInstanceFull(ap, wid, pi, oPi);					wired = true;					break;				}				if (wired) break;			}		}	}	/**	 * Method to find the node at (x, y) and return it.	 */	private PortInst findNode(Point2D pt, Point2D oPt, Cell cell, PortInst notThisPort)	{		double slop = 10;		PortInst bestPi = null;		double bestDist = Double.MAX_VALUE;		Rectangle2D searchBounds = new Rectangle2D.Double(pt.getX()-slop, pt.getY()-slop, slop*2, slop*2);		for(Iterator<RTBounds> sea = cell.searchIterator(searchBounds); sea.hasNext(); )		{			RTBounds geom = sea.next();			if (!(geom instanceof NodeInst)) continue;			NodeInst ni = (NodeInst)geom;			if (notThisPort != null && ni == notThisPort.getNodeInst()) continue;			// ignore pins			if (ni.getProto() == Schematics.tech().wirePinNode) continue;			// find closest port			for(Iterator<PortInst> it = ni.getPortInsts(); it.hasNext(); )			{				PortInst pi = it.next();				Poly poly = pi.getPoly();				Rectangle2D bounds = poly.getBounds2D();				// find out if the line crosses the polygon				double thisX = oPt.getX();				double thisY = oPt.getY();				if (pt.getX() == oPt.getX())				{					// line is vertical: look for intersection with polygon					if (oPt.getX() < bounds.getMinX() || oPt.getX() > bounds.getMaxX()) continue;					thisX = oPt.getX();					thisY = bounds.getCenterY();				} else if (pt.getY() == oPt.getY())				{					// line is horizontal: look for intersection with polygon					if (oPt.getY() < bounds.getMinY() || oPt.getY() > bounds.getMaxY()) continue;					thisX = bounds.getCenterX();					thisY = oPt.getY();				} else				{					if (!poly.isInside(oPt)) continue;				}				double dist = oPt.distance(new Point2D.Double(thisX, thisY));				if (bestPi == null || dist < bestDist)				{					bestPi = pi;					bestDist = dist;				}			}		}		// report the hit		return bestPi;	}	/**	 * Method to find the port on node "ni" that attaches to the wire from (x,y) to (ox,oy).	 * Returns NOPORTPROTO if not found.	 */	private PortInst wiredPort(NodeInst ni, Point2D pt, Point2D oPt)	{		for(Iterator<PortInst> it = ni.getPortInsts(); it.hasNext(); )		{			PortInst pi = it.next();			Poly poly = pi.getPoly();			if (poly.isInside(pt)) return pi;		}		if (ni.getTrueCenterX() != pt.getX() ||			ni.getTrueCenterY() != pt.getY()) return null;		// find port that is closest to OTHER end		double bestDist = Double.MAX_VALUE;		PortInst bestPi = null;		for(Iterator<PortInst> it = ni.getPortInsts(); it.hasNext(); )		{			PortInst pi = it.next();			Poly poly = pi.getPoly();			Point2D ctr = new Point2D.Double(poly.getCenterX(), poly.getCenterY());			double dist = ctr.distance(oPt);			if (dist > bestDist) continue;			bestDist = dist;			bestPi = pi;		}		Poly poly = bestPi.getPoly();		pt.setLocation(poly.getCenterX(), poly.getCenterY());		return bestPi;	}	/**	 * Method to place all SUE nets into the cell (they are in a linked	 * list headed by "sueNets").	 */	private void placeNets(List<SueNet> sueNets, Cell cell)	{		// 3 passes: qualified labels, unqualified busses, unqualified wires		for(int pass=0; pass<3; pass++)		{			for(SueNet sn : sueNets)			{				// unqualified labels (starting with "[") happen second				if (sn.label.startsWith("["))				{					// unqualified label: pass 2 or 3 only					if (pass == 0) continue;				} else				{					// qualified label: pass 1 only					if (pass != 0) continue;				}				// see if this is a bus				Name lableName = Name.findName(sn.label);				boolean isBus = false;				if (lableName.busWidth() > 1) isBus = true;				ArcInst bestAi = null;				double bestDist = Double.MAX_VALUE;				Rectangle2D searchBounds = new Rectangle2D.Double(sn.pt.getX(), sn.pt.getY(), 0, 0);				for(Iterator<RTBounds> sea = cell.searchIterator(searchBounds); sea.hasNext(); )				{					RTBounds geom = sea.next();					if (geom instanceof NodeInst) continue;					ArcInst ai = (ArcInst)geom;					if (isBus)					{						if (ai.getProto() != Schematics.tech().bus_arc) continue;					} else					{						if (ai.getProto() == Schematics.tech().bus_arc) continue;					}					double cx = (ai.getHeadLocation().getX() + ai.getTailLocation().getX()) / 2;					double cy = (ai.getHeadLocation().getY() + ai.getTailLocation().getY()) / 2;					Point2D ctr = new Point2D.Double(cx, cy);					double dist = ctr.distance(sn.pt);					// LINTED "bestdist" used in proper order					if (bestAi == null || dist < bestDist)					{						bestAi = ai;						bestDist = dist;					}				}				if (bestAi != null)				{					if (pass == 1)					{						// only allow busses						if (bestAi.getProto() != Schematics.tech().bus_arc) continue;					} else if (pass == 2)					{						// disallow busses						if (bestAi.getProto() == Schematics.tech().bus_arc) continue;					}					String netName = sn.label;					if (netName.startsWith("["))					{						// find the proper name of the network						String busName = findBusName(bestAi);						if (busName != null)						{							netName = busName + netName;						}					}					bestAi.setName(netName);				}			}		}	}	/**	 * Method to start at "ai" and search all wires until it finds a named bus.	 * Returns zero if no bus name is found.	 */	private String findBusName(ArcInst ai)	{		Set<ArcInst> arcsSeen = new HashSet<ArcInst>();		String busName = searchBusName(ai, arcsSeen);		if (busName == null)		{			for(int index=1; ; index++)			{				String pseudoBusName = "NET" + index;				int len = pseudoBusName.length();				boolean found = false;				for(Iterator<ArcInst> it = ai.getParent().getArcs(); it.hasNext(); )				{					ArcInst oAi = it.next();					String arcName = oAi.getName();					if (arcName.equalsIgnoreCase(pseudoBusName)) { found = true;   break; }					if (arcName.startsWith(pseudoBusName) && arcName.charAt(len) == '[') { found = true;   break; }				}				if (!found) return pseudoBusName;			}		}		return busName;	}	private String searchBusName(ArcInst ai, Set<ArcInst> arcsSeen)	{		arcsSeen.add(ai);		if (ai.getProto() == Schematics.tech().bus_arc)		{			String arcName = ai.getName();			int openPos = arcName.indexOf('[');			if (openPos >= 0) arcName = arcName.substring(0, openPos);			return arcName;		}		for(int i=0; i<2; i++)		{			NodeInst ni = ai.getPortInst(i).getNodeInst();			if (ni.getProto() != Schematics.tech().wirePinNode && ni.getProto() != Schematics.tech().busPinNode &&				ni.getProto() != Schematics.tech().offpageNode) continue;			if (ni.getProto() == Schematics.tech().busPinNode || ni.getProto() == Schematics.tech().offpageNode)			{				// see if there is an arrayed port here				for(Iterator<Export> it = ni.getExports(); it.hasNext(); )				{					Export pp = it.next();					String busName = pp.getName();					int openPos = busName.indexOf('[');					if (openPos >= 0) return busName.substring(0, openPos);				}			}			for(Iterator<Connection> it = ni.getConnections(); it.hasNext(); )			{				Connection con = it.next();				ArcInst oAi = con.getArc();				if (arcsSeen.contains(oAi)) continue;				String busName = searchBusName(oAi, arcsSeen);				if (busName != null) return busName;			}		}		return null;	}	/**	 * Method to read the next line from file and break	 * it up into space-separated keywords.  Returns the number	 * of keywords (-1 on EOF)	 */	private List<String> getNextLine(LineNumberReader lr)		throws IOException	{		lastLineRead = null;		for(int lineNo=0; ; lineNo++)		{			if (sueLastLine == null)			{				sueLastLine = lr.readLine();				if (sueLastLine == null) return null;			}			if (lineNo == 0)			{				// first line: use it				lastLineRead = sueLastLine;			} else			{				// subsequent line: use it only if a continuation				if (sueLastLine.length() == 0 || sueLastLine.charAt(0) != '+') break;				lastLineRead += sueLastLine.substring(1);			}			sueLastLine = null;		}		// parse the line		boolean inBlank = true;		List<String> keywords = new ArrayList<String>();		int startIndex = 0;		int len = lastLineRead.length();		int curlyDepth = 0;		for(int i=0; i<len; i++)		{			char pt = lastLineRead.charAt(i);			if (pt == '{') curlyDepth++;			if (pt == '}') curlyDepth--;			if ((pt == ' ' || pt == '\t') && curlyDepth == 0)			{				if (!inBlank)				{					String keyword = lastLineRead.substring(startIndex, i).trim();					keywords.add(keyword);					startIndex = i;				}				inBlank = true;			} else			{				if (inBlank)				{					startIndex = i;				}				inBlank = false;			}		}		String keyword = lastLineRead.substring(startIndex, len).trim();		if (keyword.length() > 0)			keywords.add(keyword);		return keywords;	}	/**	 * Method to examine a SUE expression and add "@" in front of variable names.	 * Only does this if requested.	 */	private String parseExpression(String expression)	{		if (!IOTool.isSueConvertsExpressions()) return expression;		StringBuffer infstr = new StringBuffer();		for(int i=0; i<expression.length(); i++)		{			int startKey = i;			while (i < expression.length())			{				char chr = expression.charAt(i);				if (chr == ' ' || chr == '\t' || chr == ',' || chr == '+' ||					chr == '-' || chr == '*' || chr == '/' || chr == '(' || chr == ')')						break;				i++;			}			if (i > startKey)			{				String keyword = expression.substring(startKey, i);				if (!TextUtils.isANumber(keyword))				{					if (i >= expression.length() || expression.charAt(i) != '(')						infstr.append('@');				}				infstr.append(keyword);			}			if (i < expression.length())			{				infstr.append(expression.charAt(i));				i++;			}		}		return infstr.toString();	}	/**	 * Method to convert SUE X coordinate "x" to Electric coordinates	 */	private static double convertXCoord(double x)	{		return x / 8;	}	/**	 * Method to convert SUE Y coordinate "y" to Electric coordinates	 */	private static double convertYCoord(double y)	{		return -y / 8;	}}

⌨️ 快捷键说明

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