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

📄 routing.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: Routing.java * * Copyright (c) 2003 Sun Microsystems and Static Free Software * * Electric(tm) is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * Electric(tm) is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Electric(tm); see the file COPYING.  If not, write to * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, Mass 02111-1307, USA. */package com.sun.electric.tool.routing;import com.sun.electric.database.CellBackup;import com.sun.electric.database.CellRevision;import com.sun.electric.database.ImmutableArcInst;import com.sun.electric.database.ImmutableNodeInst;import com.sun.electric.database.Snapshot;import com.sun.electric.database.geometry.Poly;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.Export;import com.sun.electric.database.hierarchy.Nodable;import com.sun.electric.database.id.CellId;import com.sun.electric.database.id.PortProtoId;import com.sun.electric.database.network.Netlist;import com.sun.electric.database.network.Network;import com.sun.electric.database.prototype.NodeProto;import com.sun.electric.database.prototype.PortProto;import com.sun.electric.database.text.Name;import com.sun.electric.database.text.Pref;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.Connection;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.topology.PortInst;import com.sun.electric.database.variable.EditWindow_;import com.sun.electric.database.variable.UserInterface;import com.sun.electric.technology.ArcProto;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.PrimitivePort;import com.sun.electric.technology.technologies.Generic;import com.sun.electric.tool.Job;import com.sun.electric.tool.JobException;import com.sun.electric.tool.Listener;import com.sun.electric.tool.user.User;import java.awt.geom.Point2D;import java.lang.reflect.Method;import java.util.ArrayList;import java.util.BitSet;import java.util.Collections;import java.util.Comparator;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;/** * This is the Routing tool. */public class Routing extends Listener{	/**	 * Class to describe recent activity that pertains to routing.	 */	public static class Activity	{		int numCreatedArcs, numCreatedNodes;		ImmutableArcInst [] createdArcs = new ImmutableArcInst[3];        CellId createdArcsParents [] = new CellId[3];		ImmutableNodeInst [] createdNodes = new ImmutableNodeInst[3];		int numDeletedArcs, numDeletedNodes;		ImmutableArcInst deletedArc;		CellId deletedArcParent;		PortProtoId [] deletedPorts = new PortProtoId[2];		Activity()		{		}	}	private Activity current, past = null;	private boolean checkAutoStitch = false;	/** the Routing tool. */		private static Routing tool = new Routing();	/****************************** TOOL INTERFACE ******************************/	/**	 * The constructor sets up the Routing tool.	 */	private Routing()	{		super("routing");	}	/**	 * Method to initialize the Routing tool.	 */	public void init()	{		setOn();	}	/**	 * Method to retrieve the singleton associated with the Routing tool.	 * @return the Routing tool.	 */	public static Routing getRoutingTool() { return tool; }   /**	 * Handles database changes of a Job.	 * @param oldSnapshot database snapshot before Job.	 * @param newSnapshot database snapshot after Job and constraint propagation.	 * @param undoRedo true if Job was Undo/Redo job.	 */	public void endBatch(Snapshot oldSnapshot, Snapshot newSnapshot, boolean undoRedo)	{		if (undoRedo) return;		if (newSnapshot.tool == tool) return;		current = new Activity();		checkAutoStitch = false;		for (CellId cellId: newSnapshot.getChangedCells(oldSnapshot)) {			CellBackup oldBackup = oldSnapshot.getCell(cellId);			if (oldBackup == null) continue; // Don't route in new cells            CellBackup newBackup = newSnapshot.getCell(cellId);            if (newBackup == null) continue;			if (oldBackup == newBackup) continue;            CellRevision oldRevision = oldBackup.cellRevision;            CellRevision newRevision = newBackup.cellRevision;			ArrayList<ImmutableNodeInst> oldNodes = new ArrayList<ImmutableNodeInst>();			for (ImmutableNodeInst n: oldRevision.nodes) {				while (n.nodeId >= oldNodes.size()) oldNodes.add(null);				oldNodes.set(n.nodeId, n);			}			ArrayList<ImmutableArcInst> oldArcs = new ArrayList<ImmutableArcInst>();			for (ImmutableArcInst a: oldRevision.arcs) {				while (a.arcId >= oldArcs.size()) oldArcs.add(null);				oldArcs.set(a.arcId, a);			}            BitSet newNodes = new BitSet();			for (ImmutableNodeInst d: newRevision.nodes) {                newNodes.set(d.nodeId);				ImmutableNodeInst oldD = d.nodeId < oldNodes.size() ? oldNodes.get(d.nodeId) : null;				if (oldD == null) {					if (current.numCreatedNodes < 3)						current.createdNodes[current.numCreatedNodes++] = d;				} else if (oldD != d) {					checkAutoStitch = true;				}			}            BitSet newArcs = new BitSet();			for (ImmutableArcInst d: newRevision.arcs) {                newArcs.set(d.arcId);				ImmutableArcInst oldD = d.arcId < oldArcs.size( ) ? oldArcs.get(d.arcId) : null;				if (oldD == null) {					if (current.numCreatedArcs < 3) {                        current.createdArcsParents[current.numCreatedArcs] = cellId;						current.createdArcs[current.numCreatedArcs++] = d;                    }				}			}			for (ImmutableNodeInst nid: oldRevision.nodes) {				if (!newNodes.get(nid.nodeId))					current.numDeletedNodes++;			}			for (ImmutableArcInst aid: oldRevision.arcs) {				if (!newArcs.get(aid.arcId)) {					if (current.numDeletedArcs == 0) {						current.deletedArc = aid;						current.deletedArcParent = cellId;						current.deletedPorts[0] = aid.headPortId;						current.deletedPorts[1] = aid.tailPortId;					}					current.numDeletedArcs++;				}			}		}		if (current.numCreatedArcs > 0 || current.numCreatedNodes > 0 || current.deletedArc != null)		{			past = current;			if (isMimicStitchOn())			{				MimicStitch.mimicStitch(false);				return;			}		}		if (checkAutoStitch && isAutoStitchOn())		{			AutoStitch.autoStitch(false, false);		}		// JFluid results		current = null;	}	/****************************** COMMANDS ******************************/	/**	 * Method to mimic the currently selected ArcInst.	 */	public void mimicSelected()	{		UserInterface ui = Job.getUserInterface();		EditWindow_ wnd = ui.getCurrentEditWindow_();		if (wnd == null) return;		ArcInst ai = (ArcInst)wnd.getOneElectricObject(ArcInst.class);		if (ai == null) return;		past = new Activity();        past.createdArcsParents[past.numCreatedArcs] = ai.getParent().getId();		past.createdArcs[past.numCreatedArcs++] = ai.getD();		MimicStitch.mimicStitch(true);	}	/**	 * Method to convert the current network(s) to an unrouted wire.	 */	public static void unrouteCurrent()	{		// see what is highlighted		UserInterface ui = Job.getUserInterface();		EditWindow_ wnd = ui.getCurrentEditWindow_();		if (wnd == null) return;		Cell cell = wnd.getCell();		Set<Network> nets = wnd.getHighlightedNetworks();		if (nets.size() == 0)		{			System.out.println("Must select networks to unroute");			return;		}		new UnrouteJob(cell, nets);	}	/**	 * Method to determine the preferred ArcProto to use for routing.	 * Examines preferences in the Routing tool and User interface.	 * @return the preferred ArcProto to use for routing.	 */	public static ArcProto getPreferredRoutingArcProto()	{		ArcProto preferredArc = null;		String preferredName = getPreferredRoutingArc();		if (preferredName.length() > 0) preferredArc = ArcProto.findArcProto(preferredName);		if (preferredArc == null)		{			// see if there is a default user arc			ArcProto curAp = User.getUserTool().getCurrentArcProto();			if (curAp != null) preferredArc = curAp;		}		return preferredArc;	}	private static class UnrouteJob extends Job	{		private Cell cell;		private Set<Network> nets;		private List<ArcInst> highlightThese;		private UnrouteJob(Cell cell, Set<Network> nets)		{			super("Unroute", Routing.tool, Job.Type.CHANGE, null, null, Job.Priority.USER);			this.cell = cell;			this.nets = nets;			startJob();		}		public boolean doIt() throws JobException		{			// convert requested nets			Netlist netList = cell.acquireUserNetlist();			if (netList == null)				throw new JobException("Sorry, a deadlock aborted unrouting (network information unavailable).  Please try again");			highlightThese = new ArrayList<ArcInst>();			// make arrays of what to unroute			int total = nets.size();			Network [] netsToUnroute = new Network[total];			ArrayList<List<Connection>> netEnds = new ArrayList<List<Connection>>();			ArrayList<Set<ArcInst>> arcsToDelete = new ArrayList<Set<ArcInst>>();			ArrayList<Set<NodeInst>> nodesToDelete = new ArrayList<Set<NodeInst>>();			int i = 0;			for(Network net : nets)			{				netsToUnroute[i] = net;				Set<ArcInst> arcs = new HashSet<ArcInst>();				Set<NodeInst> nodes = new HashSet<NodeInst>();				arcsToDelete.add(arcs);				nodesToDelete.add(nodes);				netEnds.add(findNetEnds(net, arcs, nodes, netList, false));				i++;

⌨️ 快捷键说明

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