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

📄 l.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: L.java * Input/output tool: L Netlist output * Written by Steven M. Rubin, Sun Microsystems. * * Copyright (c) 2004 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.io.output;import com.sun.electric.database.geometry.Orientation;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.View;import com.sun.electric.database.prototype.NodeProto;import com.sun.electric.database.prototype.PortCharacteristic;import com.sun.electric.database.prototype.PortProto;import com.sun.electric.database.text.TextUtils;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.technology.ArcProto;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.PrimitivePort;import com.sun.electric.technology.TransistorSize;import java.awt.geom.Rectangle2D;import java.util.HashSet;import java.util.Iterator;import java.util.Set;/** * This is the netlister for L. */public class L extends Output{	// node types returned by "getNodeType"	private static final int TRUEPIN    = 1;	private static final int TRANSISTOR = 2;	private static final int INSTANCE   = 3;	private static final int OTHERNODE  = 4;	private Set<Cell> cellsSeen;	/** the results of calling "transistorPorts". */	private PortInst gateLeft, gateRight, activeTop, activeBottom;	/**	 * The main entry point for L deck writing.     * @param cell the top-level cell to write.	 * @param filePath the disk file to create.	 */	public static void writeLFile(Cell cell, String filePath)	{		L out = new L();		if (out.openTextOutputStream(filePath)) return;		out.writeLCells(cell);		if (out.closeTextOutputStream()) return;		System.out.println(filePath + " written");	}	/**	 * Creates a new instance of the L netlister.	 */	L() {}	/**	 * Method to write all cells below a given Cell.	 * @param cell the top Cell of the hierarchy to write.	 */	private void writeLCells(Cell cell)	{		printWriter.println("L:: TECH ANY");		cellsSeen = new HashSet<Cell>();		writeLCell(cell);	}	/**	 * Method to write "L" for a cell.	 * @param cell the Cell to write.	 */	private void writeLCell(Cell cell)	{		// if there are any sub-cells that have not been written, write them		for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )		{			NodeInst ni = it.next();			if (!ni.isCellInstance()) continue;			if (ni.isIconOfParent()) continue;			Cell np = (Cell)ni.getProto();			// convert body cells to contents cells			Cell oNp = np.contentsView();			if (oNp != null) np = oNp;			// don't recurse if this cell has already been written			if (cellsSeen.contains(np)) continue;			// recurse to the bottom			writeLCell(np);		}		cellsSeen.add(cell);		// write the cell header		printWriter.println("");		if (cell.getView() == View.LAYOUT) printWriter.print("LAYOUT ");		if (cell.isSchematic()) printWriter.print("SCHEMATIC ");		if (cell.isIcon()) printWriter.print("ICON ");		if (cell.getView() == View.LAYOUTSKEL) printWriter.print("BBOX ");		printWriter.println("CELL " + getLegalName(cell.getName()) + " ( )\n{");		// write the bounding box		Rectangle2D bounds = cell.getBounds();		printWriter.println("#bbox: ll= (" + TextUtils.formatDouble(bounds.getMinX()) + "," +			TextUtils.formatDouble(bounds.getMinY()) + ") ur= (" +			TextUtils.formatDouble(bounds.getMaxX()) + "," +			TextUtils.formatDouble(bounds.getMaxY()) + ")");		// write the ports		for(Iterator<PortProto> it = cell.getPorts(); it.hasNext(); )		{			Export e = (Export)it.next();			Poly poly = e.getOriginalPort().getPoly();			double xPos = poly.getCenterX();			double yPos = poly.getCenterY();			String type = "";			if (e.getCharacteristic() == PortCharacteristic.GND) type = "GND"; else				if (e.getCharacteristic() == PortCharacteristic.PWR) type = "VDD"; else					if (e.getCharacteristic() == PortCharacteristic.IN) type = "IN"; else						if (e.getCharacteristic() == PortCharacteristic.OUT) type = "OUT"; else							if (e.getCharacteristic() == PortCharacteristic.BIDIR) type = "INOUT";			ArcProto ap = e.getBasePort().getConnection();			String lay = getArcFunctionName(ap, ap.getName());			printWriter.println("\t" + type + " " + lay + " " + getLegalName(e.getName()) +				" (" + TextUtils.formatDouble(xPos) + "," + TextUtils.formatDouble(yPos) + ") ;");		}		printWriter.println("");		// write the components		for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )		{			NodeInst ni = it.next();			if (getNodeType(ni) == TRUEPIN) continue;			NodeProto np = ni.getProto();			PrimitiveNode.Function fun = ni.getFunction();			// determine type of component			String type = np.getName();			if (ni.isCellInstance())			{				// ignore recursive references (showing icon in contents)				if (ni.isIconOfParent()) continue;				// convert body cells to contents cells				Cell oNp = ((Cell)np).contentsView();				if (oNp != null) np = oNp;				type = np.getName();				printWriter.print("\tINST " + type + " " + getLegalName(ni.getName()));			} else			{				PrimitiveNode npPrim = (PrimitiveNode)np;				if (fun == PrimitiveNode.Function.PIN)				{					// if pin is an export, don't write separate node statement					if (ni.hasExports()) continue;					PrimitivePort primPp = npPrim.getPort(0);					ArcProto ap = primPp.getConnection();					type = "NODE " + getArcFunctionName(ap, "???");				}				// special type names for well/substrate contacts				if (fun == PrimitiveNode.Function.WELL) type = "MNSUB";				if (fun == PrimitiveNode.Function.SUBSTRATE) type = "MPSUB";				// special type names for contacts				if (fun == PrimitiveNode.Function.CONTACT || fun == PrimitiveNode.Function.CONNECT)				{					boolean conMetal1 = false, conMetal2 = false, conPActive = false, conNActive = false, conPoly = false;					for(int j=0; j<npPrim.getNumPorts(); j++)					{						PrimitivePort primPp = npPrim.getPort(j);						ArcProto [] arcs = primPp.getConnections();						for(int k=0; k<arcs.length; k++)						{							ArcProto ap = arcs[k];							ArcProto.Function aFun = ap.getFunction();							if (aFun == ArcProto.Function.METAL1) conMetal1 = true;							if (aFun == ArcProto.Function.METAL2) conMetal2 = true;							if (aFun == ArcProto.Function.POLY1) conPoly = true;							if (aFun == ArcProto.Function.DIFFP) conPActive = true;							if (aFun == ArcProto.Function.DIFFN) conNActive = true;						}					}					if (conMetal1)					{						if (conMetal2) type = "M1M2"; else							if (conPoly) type = "MPOLY"; else								if (conPActive) type = "MPDIFF"; else									if (conNActive) type = "MNDIFF";					}				}				// special type names for transistors				if (fun.isNTypeTransistor()) type = "TN"; else					if (fun.isPTypeTransistor()) type = "TP"; else						if (fun == PrimitiveNode.Function.TRADMOS ||							fun == PrimitiveNode.Function.TRAPMOSD) type = "TD";				// write the type and name				printWriter.print("\t" + type + " " + getLegalName(ni.getName()));			}			// write rotation			Orientation or = ni.getOrient();			int oldRotation = or.getCAngle();			int oldTranspose = or.isCTranspose() ? 1 : 0;			if (oldRotation != 0 || oldTranspose != 0)			{				if (oldTranspose != 0)				{					printWriter.print(" RX");					oldRotation = (oldRotation+2700) % 3600;				}				printWriter.print(" R" + TextUtils.formatDouble(oldRotation/10));			}			// write size if nonstandard			if (ni.getXSize() != np.getDefWidth() || ni.getYSize() != np.getDefHeight())			{				double wid = ni.getLambdaBaseXSize();				double len = ni.getLambdaBaseYSize();				if (fun.isFET())				{					TransistorSize ts = ni.getTransistorSize(null);					len = ts.getDoubleLength();					wid = ts.getDoubleWidth();				}

⌨️ 快捷键说明

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