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

📄 celllists.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: CellLists.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.user.dialogs;import com.sun.electric.database.geometry.ERectangle;import com.sun.electric.database.geometry.GenMath;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.hierarchy.View;import com.sun.electric.database.prototype.NodeProto;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.variable.Variable;import com.sun.electric.technology.ArcProto;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.Technology;import com.sun.electric.tool.Job;import com.sun.electric.tool.drc.DRC;import com.sun.electric.tool.extract.TransistorSearch;import com.sun.electric.tool.generator.sclibrary.SCLibraryGen;import com.sun.electric.tool.io.FileType;import com.sun.electric.tool.user.ui.TopLevel;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.geom.Rectangle2D;import java.io.BufferedOutputStream;import java.io.DataOutputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.text.DateFormat;import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.Date;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.List;import java.util.Map;import java.util.Set;import javax.swing.JFrame;/** * Class to handle the "Cell Lists" dialog. */public class CellLists extends EDialog{	Cell curCell;	private static int whichSwitch = 0;	private static boolean onlyViewSwitch = false;	private static View viewSwitch = View.SCHEMATIC;	private static boolean alsoIconSwitch = false;	private static boolean excOldVersSwitch = false;	private static boolean excNewVersSwitch = false;	private static boolean evaluateNumbers = true;	private static int orderingSwitch = 0;	private static int destinationSwitch = 0;	/**	 * This method implements the command to create general Cell lists.	 */	public static void generalCellListsCommand()	{		JFrame jf = TopLevel.getCurrentJFrame(); 		CellLists dialog = new CellLists(jf, true);		dialog.setVisible(true);		dialog.toFront();	}	/** Creates new form Cell Lists */	private CellLists(JFrame parent, boolean modal)	{		super(parent, modal);		initComponents();		getRootPane().setDefaultButton(ok);		// make a popup of views		for (View v : View.getOrderedViews())		{			views.addItem(v.getFullName());		}		curCell = WindowFrame.getCurrentCell();		onlyCellsUnderCurrent.setEnabled(curCell != null);		switch (whichSwitch)		{			case 0: allCells.setSelected(true);                   break;			case 1: onlyCellsUsedElsewhere.setSelected(true);     break;			case 2: onlyCellsNotUsedElsewhere.setSelected(true);  break;			case 3: onlyCellsUnderCurrent.setSelected(true);      break;			case 4: onlyPlaceholderCells.setSelected(true);       break;		}		onlyThisView.setSelected(onlyViewSwitch);		views.setSelectedItem(viewSwitch.getFullName());		views.setEnabled(onlyViewSwitch);		alsoIconViews.setSelected(alsoIconSwitch);		excludeOlderVersions.setSelected(excOldVersSwitch);		excludeNewestVersions.setSelected(excNewVersSwitch);		evaluateNumerically.setSelected(evaluateNumbers);		switch (orderingSwitch)		{			case 0: orderByName.setSelected(true);                break;			case 1: orderByDate.setSelected(true);                break;			case 2: orderByStructure.setSelected(true);           break;		}		switch (destinationSwitch)		{			case 0: displayInMessages.setSelected(true);          break;			case 1: saveToDisk.setSelected(true);                 break;		}		finishInitialization();	}	protected void escapePressed() { cancel(null); }	private static String makeCellLine(Cell cell, int maxlen)	{		String line = cell.noLibDescribe();		if (maxlen < 0) line += "\t"; else		{			for(int i=line.length(); i<maxlen; i++) line += " ";		}		// add the version number		String versionString = TextUtils.toBlankPaddedString(cell.getVersion(), 5);		line += versionString;		if (maxlen < 0) line += "\t"; else line += "   ";		// add the creation date		Date creationDate = cell.getCreationDate();		if (creationDate == null)		{			if (maxlen < 0) line += "UNRECORDED"; else				line += "     UNRECORDED     ";		} else		{			line += TextUtils.formatDate(creationDate);		}		if (maxlen < 0) line += "\t"; else line += "   ";		// add the revision date		Date revisionDate = cell.getRevisionDate();		if (revisionDate == null)		{			if (maxlen < 0) line += "UNRECORDED"; else				line += "     UNRECORDED     ";		} else		{			line += TextUtils.formatDate(revisionDate);		}		if (maxlen < 0) line += "\t"; else line += "   ";		// add the size		if (cell.getView().isTextView())		{			int len = 0;			String [] textLines = cell.getTextViewContents();			if (textLines != null) len = textLines.length;			if (maxlen < 0) line += len + " lines"; else			{				line += TextUtils.toBlankPaddedString(len, 8) + " lines   ";			}		} else		{			String width = Double.toString(cell.getBounds().getWidth());			if (maxlen >= 0)			{				while (width.length() < 8) width = " " + width;			}			String height = Double.toString(cell.getBounds().getHeight());			if (maxlen >= 0)			{				while (height.length() < 8) height += " ";			}			line += width + "x" + height;		}		if (maxlen < 0) line += "\t";		// count the number of instances		int total = 0;		for(Iterator<NodeInst> it = cell.getInstancesOf(); it.hasNext(); )		{			total++;			it.next();		}		if (maxlen < 0) line += total; else		{			line += TextUtils.toBlankPaddedString(total, 4);		}		if (maxlen < 0) line += "\t"; else line += "   ";		// show other factors about the cell		if (cell.isAllLocked()) line += "L"; else line += " ";		if (maxlen < 0) line += "\t"; else line += " ";		if (cell.isInstancesLocked()) line += "I"; else line += " ";		if (maxlen < 0) line += "\t"; else line += " ";		if (SCLibraryGen.isStandardCell(cell)) line += "S"; else line += " ";		if (maxlen < 0) line += "\t"; else line += " ";		boolean goodDRC = false;		int activeBits = DRC.getActiveBits(cell.getTechnology());		Date lastGoodDate = DRC.getLastDRCDateBasedOnBits(cell, true, activeBits, true);		// checking spacing drc		if (!Job.getDebug() && lastGoodDate != null && cell.getRevisionDate().before(lastGoodDate)) goodDRC = true;		if (goodDRC) line += "D"; else line += " ";		// now check min area		goodDRC = false;		lastGoodDate = DRC.getLastDRCDateBasedOnBits(cell, false, activeBits, true);		if (!Job.getDebug() && lastGoodDate != null && cell.getRevisionDate().before(lastGoodDate)) goodDRC = true;		if (goodDRC) line += "A"; else line += " ";		if (maxlen < 0) line += "\t"; else line += " ";//		if (net_ncchasmatch(cell) != 0) addstringtoinfstr(infstr, x_("N")); else//			addstringtoinfstr(infstr, x_(" "));		return line;	}	/**	 * Method to recursively walk the hierarchy from "np", marking all cells below it.	 */	private void recursiveMark(Cell cell, Set<Cell> cellsSeen)	{		if (cellsSeen.contains(cell)) return;		cellsSeen.add(cell);		for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )		{			NodeInst ni = it.next();			if (!ni.isCellInstance()) continue;			Cell subCell = (Cell)ni.getProto();			recursiveMark(subCell, cellsSeen);			Cell contentsCell = subCell.contentsView();			if (contentsCell != null) recursiveMark(contentsCell, cellsSeen);		}	}	private static class SortByCellStructure implements Comparator<Cell>	{		public int compare(Cell c1, Cell c2)		{			// first sort by cell size			Rectangle2D b1 = c1.getBounds();			Rectangle2D b2 = c2.getBounds();			int xs1 = (int)b1.getWidth();			int xs2 = (int)b2.getWidth();			if (xs1 != xs2) return(xs1-xs2);			int ys1 = (int)b1.getHeight();			int ys2 = (int)b2.getHeight();			if (ys1 != ys2) return(ys1-ys2);			// now sort by number of exports			int pc1 = c1.getNumPorts();			int pc2 = c2.getNumPorts();			pc1 = 0;			if (pc1 != pc2) return(pc1-pc2);			// now match the exports//			for(Iterator it = c1.getPorts(); it.hasNext(); )//			{//				PortProto pp1 = it.next();//				pp1.clearBit(portFlagBit);//			}//			for(Iterator it = c2.getPorts(); it.hasNext(); )//			{//				PortProto pp2 = it.next();////				// locate center of this export//				ni = &dummyni;//				initdummynode(ni);//				ni->proto = f2;//				ni->lowx = -xs1/2;   ni->highx = ni->lowx + xs1;//				ni->lowy = -ys1/2;   ni->highy = ni->lowy + ys1;//				portposition(ni, pp2, &x2, &y2);////				ni->proto = f1;//				for(pp1 = f1->firstportproto; pp1 != NOPORTPROTO; pp1 = pp1->nextportproto)//				{//					portposition(ni, pp1, &x1, &y1);//					if (x1 == x2 && y1 == y2) break;//				}//				if (pp1 == NOPORTPROTO) return(f1-f2);//				pp1->temp1 = 1;//			}//			for(pp1 = f1->firstportproto; pp1 != NOPORTPROTO; pp1 = pp1->nextportproto)//				if (pp1->temp1 == 0) return(f1-f2);			return(0);		}	}	/**	 * This method implements the command to list (recursively) the nodes and arcs in this Cell.	 */	public static void listNodesAndArcsInCellCommand()	{		Cell curCell = WindowFrame.needCurCell();		if (curCell == null) return;		// now look at every object recursively in this cell		Map<NodeProto,GenMath.MutableInteger> nodeCount = new HashMap<NodeProto,GenMath.MutableInteger>();        Map<ArcProto,GenMath.MutableInteger> arcCount = new HashMap<ArcProto,GenMath.MutableInteger>();        addObjects(curCell, nodeCount, arcCount);		// print the totals		System.out.println("Contents of " + curCell + ":");		Technology printtech = null;		for(Iterator<Technology> it = Technology.getTechnologies(); it.hasNext(); )		{			Technology curtech = it.next();			int totalVal = 0;            // nodes            for(Iterator<PrimitiveNode> nIt = curtech.getNodes(); nIt.hasNext(); )			{				PrimitiveNode np = nIt.next();				GenMath.MutableInteger count = nodeCount.get(np);				if (count == null) continue;				if (curtech != printtech)				{					System.out.println(curtech.getTechName() + " technology:");					printtech = curtech;				}				System.out.println("\t" + TextUtils.toBlankPaddedString(count.intValue(), 6) + " " + np.describe(true) + " nodes");				totalVal += count.intValue();			}            if (totalVal > 0)            	System.out.println(TextUtils.toBlankPaddedString(totalVal, 6) + " Total nodes for " + curtech.getTechName() + " technology");            // arcs            totalVal = 0;            for(Iterator<ArcProto> nIt = curtech.getArcs(); nIt.hasNext(); )			{                ArcProto ap = nIt.next();				GenMath.MutableInteger count = arcCount.get(ap);				if (count == null) continue;				if (curtech != printtech)				{					System.out.println(curtech.getTechName() + " technology:");					printtech = curtech;				}				System.out.println("\t" + TextUtils.toBlankPaddedString(count.intValue(), 6) + " " + ap.describe() + " arcs");				totalVal += count.intValue();			}            if (totalVal > 0)            	System.out.println(TextUtils.toBlankPaddedString(totalVal, 6) + " Total arcs for " + curtech.getTechName() + " technology");        }		for(Iterator<Library> it = Library.getLibraries(); it.hasNext(); )		{			Library lib = it.next();			Library printlib = null;			for(Iterator<Cell> cIt = lib.getCells(); cIt.hasNext(); )			{				Cell cell = cIt.next();				GenMath.MutableInteger count = nodeCount.get(cell);				if (count == null) continue;				if (lib != printlib)				{					System.out.println(lib + ":");					printlib = lib;				}				System.out.println(TextUtils.toBlankPaddedString(count.intValue(), 6) + " " + cell.describe(true) + " nodes");			}		}	}	/**	 * Method to recursively examine cell "np" and update the number of	 * instantiated primitive nodeprotos in the "temp1" field of the nodeprotos.	 */	private static void addObjects(Cell cell, Map<NodeProto,GenMath.MutableInteger> nodeCount,                                   Map<ArcProto,GenMath.MutableInteger> arcCount)	{		for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )		{			NodeInst ni = it.next();			if (ni.isIconOfParent()) continue;			NodeProto np = ni.getProto();			GenMath.MutableInteger count = nodeCount.get(np);			if (count == null)			{				count = new GenMath.MutableInteger(0);				nodeCount.put(np, count);			}			count.increment();			if (!ni.isCellInstance()) continue;			Cell subCell = (Cell)np;			/* ignore recursive references (showing icon in contents) */			if (ni.isIconOfParent()) continue;			Cell cnp = subCell.contentsView();			if (cnp == null) cnp = subCell;			addObjects(cnp, nodeCount, arcCount);		}

⌨️ 快捷键说明

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