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

📄 mimicstitch.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
						continue;					}					allRoutes.add(route);				}			}			if (total == 0) continue;			// make sure this situation is the desired one			if (matchPorts && (situations[j]&LIKELYDIFFPORT) != 0) { ifIgnorePorts += total;   continue; }			if (matchPortWidth && (situations[j]&LIKELYDIFFPORTWIDTH) != 0) { ifIgnorePortWidth += total;   continue; }			if (matchArcCount && (situations[j]&LIKELYDIFFARCCOUNT) != 0) { ifIgnoreArcCount += total;   continue; }			if (matchNodeType && (situations[j]&LIKELYDIFFNODETYPE) != 0) { ifIgnoreNodeType += total;   continue; }			if (matchNodeSize && (situations[j]&LIKELYDIFFNODESIZE) != 0) { ifIgnoreNodeSize += total;   continue; }			if (noOtherArcsThisDir && (situations[j]&LIKELYARCSSAMEDIR) != 0) { ifIgnoreOtherSameDir += total;   continue; }			if (notAlreadyConnected && (situations[j]&LIKELYALREADYCONNECTED) != 0) { ifAlreadyConnected += total;   continue; }			// create the routes			if (method == Job.Type.EXAMINE)			{				// since this is an examine job, queue a change job to make the wires				new MimicWireJob(allRoutes, allKills, false);			} else			{				// since this is a change job, do the wires now				runTheWires(allRoutes);			}			count += total;		}		if (count == 0)		{			if (forced)			{				String activity = deletion ? "deleted" : "added";				String msg = "No wires " + activity;				if (ifIgnorePorts != 0)					msg += ", might have " + activity + " " + ifIgnorePorts + " wires if 'ports must match' were off";				if (ifIgnorePortWidth != 0)					msg += ", might have " + activity + " " + ifIgnorePortWidth + " wires if 'ports must match width' were off";				if (ifIgnoreArcCount != 0)					msg += ", might have " + activity + " " + ifIgnoreArcCount + " wires if 'number of existing arcs must match' were off";				if (ifIgnoreNodeType != 0)					msg += ", might have " + activity + " " + ifIgnoreNodeType + " wires if 'node types must match' were off";				if (ifIgnoreNodeSize != 0)					msg += ", might have " + activity + " " + ifIgnoreNodeSize + " wires if 'nodes sizes must match' were off";				if (ifIgnoreOtherSameDir != 0)					msg += ", might have " + activity + " " + ifIgnoreOtherSameDir + " wires if 'cannot have other arcs in the same direction' were off";				if (ifAlreadyConnected != 0)					msg += ", might have " + activity + " " + ifAlreadyConnected + " wires if 'ignore if already connected elsewhere' were off";				System.out.println(msg);				if (ifIgnorePorts + ifIgnoreArcCount + ifIgnoreNodeType + ifIgnoreNodeSize + ifIgnoreOtherSameDir != 0)					System.out.println(" (settings are in the Tools / Routing tab of the Preferences)");			}		}	}	private static List<PortInst> runTheWires(List<Route> allRoutes)	{		// create the routes		List<PortInst> portsToHighlight = new ArrayList<PortInst>();        Map<ArcProto,Integer> arcsCreatedMap = new HashMap<ArcProto,Integer>();        Map<NodeProto,Integer> nodesCreatedMap = new HashMap<NodeProto,Integer>();		for (Route route : allRoutes)		{			RouteElement re = route.get(0);			Cell c = re.getCell();			PortInst showThis = Router.createRouteNoJob(route, c, false, arcsCreatedMap, nodesCreatedMap);			if (showThis != null) portsToHighlight.add(showThis);		}		Router.reportRoutingResults("MIMIC ROUTING", arcsCreatedMap, nodesCreatedMap);		return portsToHighlight;	}	/**	 * Class to implement actual wire creation/deletion in a new thread.	 */	private static class MimicWireJob extends Job	{		private List<Route> allRoutes;		private List<ArcInst> allKills;		private boolean redisplay;		private List<PortInst> portsToHighlight;		private MimicWireJob(List<Route> allRoutes, List<ArcInst> allKills, boolean redisplay)		{			super("Mimic-Stitch", Routing.getRoutingTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.allRoutes = allRoutes;			this.allKills = allKills;			this.redisplay = redisplay;			startJob();		}		public boolean doIt() throws JobException		{			if (allRoutes.size() > 0)			{				// create the routes				portsToHighlight = runTheWires(allRoutes);				fieldVariableChanged("portsToHighlight");			} else			{                boolean keepPins = Routing.isMimicStitchPinsKept();				// delete the arcs				for (ArcInst ai : allKills)				{					NodeInst h = ai.getHeadPortInst().getNodeInst();					NodeInst t = ai.getTailPortInst().getNodeInst();					ai.kill();					// also delete freed pin nodes					if (h.getProto().getFunction() == PrimitiveNode.Function.PIN &&						!h.hasConnections() && !h.hasExports() && !keepPins)					{						h.kill();					}					if (t.getProto().getFunction() == PrimitiveNode.Function.PIN &&						!t.hasConnections() && !t.hasExports() && !keepPins)					{						t.kill();					}				}			}			return true;		}		public void terminateOK()		{			if (redisplay)			{				UserInterface ui = Job.getUserInterface();				EditWindow_ wnd = ui.getCurrentEditWindow_();				if (wnd != null)				{	                wnd.clearHighlighting();					for(PortInst pi : portsToHighlight)					{		                wnd.addElectricObject(pi, pi.getNodeInst().getParent());					}	                wnd.finishedHighlighting();				}								ui.repaintAllWindows();			}		}	}	/****************************** INTERACTIVE MIMIC SELECTION ******************************/	/**	 * Class to present the next mimic opportunity and let the user choose whether to do it.	 * This class runs in the Swing thread.	 */	private static class MimicInteractive implements Runnable	{		private Cell cell;		private List<PossibleArc> possibleArcs;		private double prefX, prefY;		private MimicInteractive(Cell cell, List<PossibleArc> possibleArcs, double prefX, double prefY)	    {	    	this.cell = cell;	    	this.possibleArcs = possibleArcs;	    	this.prefX = prefX;	    	this.prefY = prefY;	    }	    public void run()	    {			// interactive mode: show paths before creating arcs	    	presentNextSituation(0, 0, possibleArcs, cell, prefX, prefY);	    }	}	/**	 * Method to interactively present a mimicing situation to the user.	 * @param count the number of arcs created so far.	 * @param situationNumber the starting "situation" number (class of mimics that are allowed).	 * @param possibleArcs a list of possible arcs to route	 * @param cell the Cell where routing is going on.	 * @param wnd the highlighter window.	 * @param prefX preferred X coordinate when arcs bend.	 * @param prefY preferred Y coordinate when arcs bend.	 */	private static void presentNextSituation(int count, int situationNumber, List<PossibleArc> possibleArcs,		Cell cell, double prefX, double prefY)	{		// find the next situation 		for(int j=situationNumber; j<situations.length; j++)		{			// make a list of mimics that match the situation			List<Route> allRoutes = new ArrayList<Route>();			List<ArcInst> allKills = new ArrayList<ArcInst>();			int total = 0;			for(PossibleArc pa : possibleArcs)			{				if (pa.situation != situations[j]) continue;				total++;				if (pa.ai != null)				{					// consider a deletion					allKills.add(pa.ai);				} else				{					// consider a creation					Poly portPoly1 = pa.ni1.getShapeOfPort(pa.pp1);					Poly portPoly2 = pa.ni2.getShapeOfPort(pa.pp2);					Point2D bend = new Point2D.Double((portPoly1.getCenterX() + portPoly2.getCenterX()) / 2 + prefX,						(portPoly1.getCenterY() + portPoly2.getCenterY()) / 2 + prefY);					PortInst pi1 = pa.ni1.findPortInstFromProto(pa.pp1);					PortInst pi2 = pa.ni2.findPortInstFromProto(pa.pp2);					Route route = router.planRoute(pa.ni1.getParent(), pi1, pi2, bend, null, true, true);					if (route.size() == 0)					{						System.out.println("Problem creating arc");						continue;					}					allRoutes.add(route);				}			}			if (total == 0) continue;			// save what is highlighted			UserInterface ui = Job.getUserInterface();			EditWindow_ wnd = ui.getCurrentEditWindow_();			List<Highlight2> saveHighlights = wnd.saveHighlightList();			// show the wires to be created/deleted			wnd.clearHighlighting();			for(Route route : allRoutes)			{				// determine the actual endpoints of the route				Poly sPi = route.getStart().getPortInst().getPoly();				Poly ePi = route.getEnd().getPortInst().getPoly();				double fX = sPi.getCenterX();   double fY = sPi.getCenterY();				double tX = ePi.getCenterX();   double tY = ePi.getCenterY();				if (fX == tX && fY == tY)				{					Rectangle2D pointRect = new Rectangle2D.Double(fX-1, fY-1, 2, 2);					wnd.addHighlightArea(pointRect, cell);				} else				{					wnd.addHighlightLine(new Point2D.Double(fX, fY), new Point2D.Double(tX, tY), cell, false);				}			}			for(ArcInst ai : allKills)			{				wnd.addHighlightLine(ai.getHeadLocation().lambdaMutable(), ai.getTailLocation().lambdaMutable(), cell, false);			}			wnd.finishedHighlighting();			// ask if the user wants to do it			new MimicDialog(TopLevel.getCurrentJFrame(), count, allRoutes, allKills, saveHighlights, wnd, j+1, possibleArcs, cell, prefX, prefY);			return;		}  		// done with all situations: report any arcs created		if (count != 0)			System.out.println("MIMIC ROUTING: Created " + count + " arcs");	}	/**	 * Class to handle the "Interactive Mimic" dialog.	 */	private static class MimicDialog extends EDialog	{		private int count;		private List<Route> allRoutes;		private List<ArcInst> allKills;		private List<Highlight2> saveHighlights;		private EditWindow_ wnd;		private int nextSituationNumber;		private List<PossibleArc> possibleArcs;		private Cell cell;		private double prefX, prefY;		private MimicDialog(Frame parent, int count, List<Route> allRoutes, List<ArcInst> allKills, List<Highlight2> saveHighlights,			EditWindow_ wnd, int nextSituationNumber, List<PossibleArc> possibleArcs, Cell cell, double prefX, double prefY)		{			super(parent, false);			this.count = count;			this.allRoutes = allRoutes;			this.allKills = allKills;			this.saveHighlights = saveHighlights;			this.wnd = wnd;			this.nextSituationNumber = nextSituationNumber;			this.possibleArcs = possibleArcs;			this.cell = cell;			this.prefX = prefX;			this.prefY = prefY;			String activity = (allKills.size() > 0 ? "Delete" : "Create");	        getContentPane().setLayout(new GridBagLayout());	        setTitle(activity + " wires?");	        setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);	        JLabel question = new JLabel(activity + " " + (allRoutes.size()+allKills.size()) + " wires shown here?");		    GridBagConstraints gbc = new GridBagConstraints();		    gbc.gridx = 0;   gbc.gridy = 0;		    gbc.gridwidth = 4;		    gbc.fill = GridBagConstraints.HORIZONTAL;		    gbc.insets = new Insets(4, 4, 4, 4);	        getContentPane().add(question, gbc);	        JButton yes = new JButton("Yes");	        yes.addActionListener(new ActionListener()	        {	            public void actionPerformed(ActionEvent evt) { yes(); }	        });	        gbc = new GridBagConstraints();	        gbc.gridx = 0;   gbc.gridy = 1;	        gbc.insets = new Insets(4, 4, 4, 4);	        getContentPane().add(yes, gbc);	        getRootPane().setDefaultButton(yes);	        JButton no = new JButton("No");	        no.addActionListener(new ActionListener()	        {	            public void actionPerformed(ActionEvent evt) { no(); }	        });	        gbc = new GridBagConstraints();	        gbc.gridx = 1;   gbc.gridy = 1;	        gbc.insets = new Insets(4, 4, 4, 4);	        getContentPane().add(no, gbc);	        JButton noAndStop = new JButton("No, and stop");	        noAndStop.addActionListener(new ActionListener()	        {	            public void actionPerformed(ActionEvent evt) { noAndStopActionPerformed(); }	        });	        gbc = new GridBagConstraints();	        gbc.gridx = 2;   gbc.gridy = 1;	        gbc.insets = new Insets(4, 4, 4, 4);	        getContentPane().add(noAndStop, gbc);	        JButton yesAndStop = new JButton("Yes, then stop");	        yesAndStop.addActionListener(new ActionListener()	        {	            public void actionPerformed(ActionEvent evt) { yesAndStopActionPerformed(); }	        });	        gbc = new GridBagConstraints();	        gbc.gridx = 3;   gbc.gridy = 1;	        gbc.insets = new Insets(4, 4, 4, 4);	        getContentPane().add(yesAndStop, gbc);	        pack();	        finishInitialization();	        setVisible(true);		}		protected void escapePressed() { no(); }		private void yesAndStopActionPerformed()		{			wnd.clearHighlighting();			wnd.restoreHighlightList(saveHighlights);			wnd.finishedHighlighting();			new MimicWireJob(allRoutes, allKills, false);			count += allRoutes.size() + allKills.size();			presentNextSituation(count, situations.length, possibleArcs, cell, prefX, prefY);			setVisible(false);			dispose();		}		private void noAndStopActionPerformed()		{			wnd.clearHighlighting();			wnd.restoreHighlightList(saveHighlights);			wnd.finishedHighlighting();			presentNextSituation(count, situations.length, possibleArcs, cell, prefX, prefY);			setVisible(false);			dispose();		}		private void yes()		{			wnd.clearHighlighting();			wnd.restoreHighlightList(saveHighlights);			wnd.finishedHighlighting();			new MimicWireJob(allRoutes, allKills, false);			count += allRoutes.size() + allKills.size();			presentNextSituation(count, nextSituationNumber, possibleArcs, cell, prefX, prefY);			setVisible(false);			dispose();		}		private void no()		{			wnd.clearHighlighting();			wnd.restoreHighlightList(saveHighlights);			wnd.finishedHighlighting();			presentNextSituation(count, nextSituationNumber, possibleArcs, cell, prefX, prefY);			setVisible(false);			dispose();		}	}}

⌨️ 快捷键说明

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