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

📄 applicon860.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: Applicon860.java * Input tool: Applicon\860 input * * Copyright (c) 2008 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. * * This code only reads Apple/860 format, and it does not handle many of the * features.  It is built from Applicon document A-20482-002, November 1983. * The features that are not included are: * > Only polygons are read, not paths, areas, or CWHA rectangles * > Cell instances cannot scale or stretch and must be manhattan * > Groups are ignored * > Auxiliary records are ignored * > Multilevel polygons are not handled (must be on only one level) * > Polygon records must use default layer and not have their own color * > Text is handled poorly and should be commented out (see below) * The code can accomodate tape or disk format files with optional byte swapping. */package com.sun.electric.tool.io.input;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.Library;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.text.TextUtils.UnitScale;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.variable.TextDescriptor;import com.sun.electric.technology.Layer;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.Technology;import com.sun.electric.technology.Technology.NodeLayer;import com.sun.electric.technology.technologies.Artwork;import java.awt.geom.AffineTransform;import java.awt.geom.Point2D;import java.awt.geom.Rectangle2D;import java.io.IOException;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.Map;import java.util.Set;public class Applicon860 extends Input{	private static final int POLYSPLIT    = 999;	/* maximum polygon record size (was 62) */	private static final int BYTESSWAPPED = 1;		/* bit set if bytes are swapped */	private static final int TAPEFORMAT   = 2;		/* bit set if file is tape-blocked */	private static final int INITIALIZED  = 4;		/* bit set if file status is known */	private Map<Integer,PrimitiveNode> appleNodeMap = new HashMap<Integer,PrimitiveNode>();	private int appleState;	private int [] polylist;	private int polylistcount = 0;	private int [] px, py;	private Point2D [] ptrace;	/**	 * Method to import a library from disk.	 * @param lib the library to fill	 * @return the created library (null on error).	 */	protected Library importALibrary(Library lib)	{		try		{			if (!readAppleLibrary(lib)) return null; // error reading the file		} catch (IOException e) {}		return lib;	}	/**	 * Method to read the Applicon file.	 * @param lib the Library to fill.	 */    /**     * Method to read the Applicon file.     * @param lib the Library to fill.     * @return True if no error was found     * @throws IOException     */    private boolean readAppleLibrary(Library lib)		throws IOException	{		String str;		int chain, length, type, i, eitype, offset, lvlgrp, layer, polyptr, nfl, nfh, nfe, tcount,			st, levels, a1, a2, a3, a4, lx, hx, ly, hy;		int [] cidata = new int[32];		String name, units, cellname;		int x1, y1, xoff = 0, yoff = 0;		Cell curfacet, subnp = null;		PrimitiveNode layernp = null;		NodeInst ni = null;		double scale = 0;				// establish linkage between Apple numbers and primitives		setupAppleLayers();			curfacet = null;		Set<Integer> notFound = new HashSet<Integer>();		appleState = 0;		for(;;)		{			chain = appleGetChain();			if (chain != 3 && chain != 1)			{				System.out.println("CHAIN=" + chain + " at byte " + byteCount);				return false;			}			length = appleGetWord();			type = appleGetWord();			switch (type)			{				case 2:		// top global parameter record				case 254:		// cell global parameter record					if (length != 26)					{						if (type == 2)							System.out.println("Top global parameter length=" + length); else								System.out.println("Cell global parameter length=" + length);						return false;					}					name = "";					for(int k=0; k<30; k++) name += dataInputStream.readByte();					st = name.indexOf(']') + 1;					i = name.indexOf('.', st);					if (i >= 0) name = name.substring(0, i);					units = "";					for(int k=0; k<4; k++) units += dataInputStream.readByte();					nfl = appleGetWord();					nfh = appleGetWord();					nfe = appleGetWord();					scale = appleFloat(nfl, nfh, nfe) / 2147483648.0;					if (units.equals("MIL "))					{						// 25.4 microns to the mil						scale = TextUtils.convertFromDistance(scale*25.4, Technology.getCurrent(), UnitScale.MICRO);					} else if (units.equals("INCH"))					{						// 25400 microns to the inch						TextUtils.convertFromDistance(scale*25400.0, Technology.getCurrent(), UnitScale.MICRO);					} else					{						// presume microns						scale = TextUtils.convertFromDistance(scale, Technology.getCurrent(), UnitScale.MICRO);					}					xoff = appleGetWord() & 0xFFFF;					xoff |= (appleGetWord() & 0xFFFF) << 16;					yoff = appleGetWord() & 0xFFFF;					yoff |= (appleGetWord() & 0xFFFF) << 16;					curfacet = Cell.makeInstance(lib, name.substring(st));					if (curfacet == null)					{						System.out.println("Cannot create facet '" + name.substring(st) + "'");						return false;					}					break;					case 3:		// element instance record					if (length != 9)					{						System.out.println("Element instance length=" + length);						return false;					}					lvlgrp = appleGetWord();					levels = appleGetWord() & 0xFFFF;					levels |= (appleGetWord() & 0xFFFF) << 16;					for(i=0; i<32; i++) if (levels == (1 << i)) break;					if (i >= 32)					{						System.out.println("Unknown layer code " + levels);						return false;					}					layer = lvlgrp * 32 + i + 1;					appleGetWord();					eitype = appleGetWord();					appleGetWord();		// numeir					appleGetWord();		// textflg					switch (eitype)					{						case 0: break;	// polygon						case 1: break;	// area						case 2: break;	// path						case 3: break;	// rectangle					}					Integer layerInt = new Integer(layer);					layernp = appleNodeMap.get(layerInt);					if (layernp == null && !notFound.contains(layerInt))					{						System.out.println("Warning: Apple layer " + layer + " not found");						notFound.add(layerInt);					}					break;					case 101:		// polygon record					appleGetWord();		// color					appleGetWord();		// draw					offset = 4;					if (length-offset > polylistcount)					{						polylistcount = 0;						polylist = new int[length-offset];						px = new int[((length-offset)+4)/5];						py = new int[((length-offset)+4)/5];						ptrace = new Point2D[((length-offset)+4)/5];						polylistcount = length - offset;					}					polyptr = 0;					while (length > POLYSPLIT)					{						for(i=0; i<POLYSPLIT-offset; i++)							polylist[polyptr++] = appleGetWord();						chain = appleGetChain();						if (chain != 2 && chain != 0)						{							System.out.println("END CHAIN=" + chain + " at byte " + byteCount);							return false;						}						length -= POLYSPLIT;						offset = 0;					}					for(i=0; i<length-offset; i++)						polylist[polyptr++] = appleGetWord();					if (polyptr > polylistcount)						System.out.println("Just overflowed " + polylistcount + " long array with " + polyptr + " points");					if ((chain&2) == 0) appleGetWord();						// process data into a set of points					polyptr /= 5;					for(i=0; i<polyptr; i++)					{						px[i] = polylist[i*5] & 0xFFFF;						px[i] |= (polylist[i*5+1] & 0xFFFF) << 16;						py[i] = polylist[i*5+2] & 0xFFFF;						py[i] |= (polylist[i*5+3] & 0xFFFF) << 16;						px[i] = appleScale(px[i], xoff, scale);						py[i] = appleScale(py[i], yoff, scale);						if ((polylist[i*5+4]&2) != 0 && i != 0)							System.out.println("Warning: point " + i + " of polygon has s=" + polylist[i*5+4]);						if ((polylist[i*5+4]&1) != 0 && i != polyptr-1)							System.out.println("Warning: point " + i + " of polygon has s=" + polylist[i*5+4]);					}					if (px[polyptr-1] == px[0] && py[polyptr-1] == py[0]) polyptr--;					lx = hx = px[0];					ly = hy = py[0];					for(i=1; i<polyptr; i++)					{						if (px[i] < lx) lx = px[i];						if (px[i] > hx) hx = px[i];						if (py[i] < ly) ly = py[i];						if (py[i] > hy) hy = py[i];					}					for(i=0; i<polyptr; i++)						ptrace[i] = new Point2D.Double(px[i] - (lx+hx) / 2, py[i] - (ly+hy) / 2);						// now create the polygon					if (layernp != null && curfacet != null)					{						Point2D center = new Point2D.Double((lx+hx)/2, (ly+hy)/2);						ni = NodeInst.newInstance(layernp, center, hx-lx, hy-ly, curfacet);						if (ni == null) return false;						ni.newVar(NodeInst.TRACE, ptrace);					}					break;					case 107:		// flag record					if (length != 3)					{						System.out.println("Flag length=" + length);						return false;					}					appleGetWord();	// flag					break;					case 117:		// text record					appleGetWord();	// vnumb					appleGetWord();	// color					appleGetWord();	// lvlgrp					appleGetWord();	// levels1					appleGetWord();	// levels2					appleGetWord();	// txtdx low					appleGetWord();	// txtdx high					appleGetWord();	// txtdy low					appleGetWord();	// txtdy high					appleGetWord();	// txtsiz low					appleGetWord();	// txtsiz high

⌨️ 快捷键说明

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