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

📄 pla.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: PLA.java * MOSIS CMOS PLA Generator. * Originally written by Wallace Kroeker at the University of Calgary * Translated to Java by Steven Rubin, Sun Microsystems. * * Copyright (c) 2005 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.generator.cmosPLA;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.Library;import com.sun.electric.database.prototype.PortProto;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.topology.PortInst;import com.sun.electric.database.variable.Variable;import com.sun.electric.lib.LibFile;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.JobException;import com.sun.electric.tool.io.FileType;import com.sun.electric.tool.io.input.LibraryFiles;import com.sun.electric.tool.user.User;import com.sun.electric.tool.user.dialogs.EDialog;import com.sun.electric.tool.user.dialogs.OpenFile;import com.sun.electric.tool.user.ui.WindowFrame;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.awt.geom.Point2D;import java.awt.geom.Rectangle2D;import java.net.URL;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JLabel;import javax.swing.JTextField;/** * Class to generate MOSIS CMOS PLAs from personality files. */public class PLA{	/** maximum number of columns */						static final int MAX_COL_SIZE = 500;	/** Lambda seperation between grid lines in array */	static final int X_SEP        =  10;	/** Lambda seperation between grid line */				static final int Y_MIR_SEP    =  10;	/** Lambda seperation between grid lines in array */	static final int Y_SEP        =  10;	static class UCItem	{		int       value;		NodeInst  nodeInst;		UCItem    rightItem;		UCItem    bottomItem;	};	/**	 * Row and column pointers	 */	static class UCRow	{		UCItem firstItem;		UCItem lastitem;		UCRow()		{			firstItem = new UCItem();			lastitem = new UCItem();		}	};	/** the cells in the pla_mocmos library */	Cell nmosOne, pmosOne, decoderInv, ioInv4, pullUps;	/** the generated cells */					private Cell pmosCell, nmosCell, orCell, decodeCell, orPlaneCell;	/** primitives in the mocmos technology */	PrimitiveNode m1Pin, m2Pin, m12Con, mpCon, maCon, mwBut, msBut, pwNode;	/** arcs in the mocmos technology */		ArcProto m1Arc, m2Arc, pArc, aArc;	UCRow [] columnList;	UCRow [][] rowList;	private NGrid ng;	private PGrid pg;	private Decode dec;	private String cellName;	private String andFileName;	private String orFileName;	private boolean inputsOnTop;	private boolean outputsOnBottom;	/**	 * Method called to generate a CMOS PLA.	 * Invokes a dialog to ask for options.	 */	public static void generate()	{		// prompt the user for some information		SetupPLAGen dialog = new SetupPLAGen();		if (dialog.failed()) return;		generate(Library.getCurrent(), dialog.getCellName(), dialog.getAndFileName(), dialog.getOrFileName(),			dialog.isInputsOnTop(), dialog.isOutputsOnBottom());	}	/**	 * Method called to generate a CMOS PLA, given all options.     * @param destLib library where create PLA cells.	 * @param cellName the name of the PLA cell to generate.	 * @param andFileName the disk file with the AND plane.	 * @param orFileName the disk file with the OR plane.	 * @param inputsOnTop true to place inputs on the top of the plane.	 * @param outputsOnBottom true to place outputs on the bottom of the plane.	 */	public static void generate(Library destLib, String cellName, String andFileName, String orFileName,                                boolean inputsOnTop, boolean outputsOnBottom)	{		// make sure the standard cell library is read in		String libName = "pla_mocmos";		if (Library.findLibrary(libName) == null)		{            // start a job to read the PLA support library			new ReadPLALibraryJob(libName, true);		}		new GeneratePLAJob(destLib, cellName, andFileName, orFileName, inputsOnTop, outputsOnBottom, true);	}	/**	 * Class to read the PLA support library in a new job.	 */	private static class ReadPLALibraryJob extends Job	{		private String libName;		private ReadPLALibraryJob(String libName, boolean doItNow)		{			super("Read PLA Library", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);			this.libName = libName;            if (doItNow)            {                try { doIt(); } catch (Exception e) { e.printStackTrace(); }            }            else			    startJob();		}		public boolean doIt() throws JobException		{			URL fileURL = LibFile.getLibFile(libName + ".jelib");    		LibraryFiles.readLibrary(fileURL, libName, FileType.JELIB, true);			return true;		}	}	/**	 * Class to build a CMOS PLA in a new Job.	 */	private static class GeneratePLAJob extends Job	{        private Library destLib;		private String cellName;		private String andFileName;		private String orFileName;		private boolean inputsOnTop;		private boolean outputsOnBottom;		private Cell newCell;        private boolean doItNow; // for regression		protected GeneratePLAJob(Library destLib, String cellName, String andFileName, String orFileName,                                 boolean inputsOnTop, boolean outputsOnBottom, boolean doItNow)		{			super("Generate MOSIS CMOS PLA", User.getUserTool(), Job.Type.CHANGE, null, null, Job.Priority.USER);            this.destLib = destLib;			this.cellName = cellName;			this.andFileName = andFileName;			this.orFileName = orFileName;			this.inputsOnTop = inputsOnTop;			this.outputsOnBottom = outputsOnBottom;            this.doItNow = doItNow;            if (!doItNow)			    startJob();            else            {                try {doIt();} catch (Exception e) { e.printStackTrace();}            }		}		public boolean doIt() throws JobException		{			PLA pla = new PLA(cellName, andFileName, orFileName, inputsOnTop, outputsOnBottom);			newCell = pla.doStep(destLib);            if (!doItNow)			    fieldVariableChanged("newCell");			return true;		}        public void terminateOK()        {            if (newCell != null)                WindowFrame.createEditWindow(newCell);        }	}	private PLA(String cellName, String andFileName, String orFileName, boolean inputsOnTop, boolean outputsOnBottom)	{		this.cellName = cellName;		this.andFileName = andFileName;		this.orFileName = orFileName;		this.inputsOnTop = inputsOnTop;		this.outputsOnBottom = outputsOnBottom;		pg = new PGrid(this);		ng = new NGrid(this);		dec = new Decode(this);	}	private Cell doStep(Library lib)		throws JobException	{		initialize();		// generate the AND plane (Decode unit of a ROM)		String thisCellName = cellName + "_p_cell{lay}";		pmosCell = pg.pmosGrid(lib, andFileName, thisCellName);		if (pmosCell == null) return null;		thisCellName = cellName + "_n_cell{lay}";		nmosCell = ng.nmosGrid(lib, andFileName, thisCellName);		if (nmosCell == null) return null;		thisCellName = cellName + "_decode{lay}";		decodeCell = dec.decodeGen(lib, pmosCell, nmosCell, thisCellName, inputsOnTop);		if (decodeCell == null) return null;		// Generate the OR plane		thisCellName = cellName + "_or_cell{lay}";		orCell = ng.nmosGrid(lib, orFileName, thisCellName);		if (orCell == null) return null;		thisCellName = cellName + "_or_plane{lay}";		orPlaneCell = makeOrPlane(lib, thisCellName, outputsOnBottom);		if (orPlaneCell == null) return null;		Cell plaCell = makePLA(lib, cellName + "{lay}");		return plaCell;	}	private void initialize()		throws JobException	{		// get the right technology and all its nodes and arcs		Technology theTech = Technology.getMocmosTechnology();		if (theTech == null) throw new JobException("Cannot find technology 'mocmos'");		m1Pin = theTech.findNodeProto("Metal-1-Pin");		if (m1Pin == null) throw new JobException("Cannot find Metal-1-Pin primitive");		m2Pin = theTech.findNodeProto("Metal-2-Pin");		if (m2Pin == null) throw new JobException("Cannot find Metal-2-Pin primitive");		m12Con = theTech.findNodeProto("Metal-1-Metal-2-Con");		if (m12Con == null) throw new JobException("Cannot find Metal-1-Metal-2-Con primitive");		mpCon = theTech.findNodeProto("Metal-1-Polysilicon-1-Con");		if (mpCon == null) throw new JobException("Cannot find Metal-1-Polysilicon-1-Con primitive");		maCon = theTech.findNodeProto("Metal-1-N-Active-Con");		if (maCon == null) throw new JobException("Cannot find Metal-1-N-Active-Con primitive");		mwBut = theTech.findNodeProto("Metal-1-P-Well-Con");		if (mwBut == null) throw new JobException("Cannot find Metal-1-P-Well-Con primitive");		msBut = theTech.findNodeProto("Metal-1-N-Well-Con");		if (msBut == null) throw new JobException("Cannot find Metal-1-N-Well-Con primitive");		pwNode = theTech.findNodeProto("P-Well-Node");		if (pwNode == null) throw new JobException("Cannot find P-Well-Node primitive");		m1Arc = theTech.findArcProto("Metal-1");		if (msBut == null) throw new JobException("Cannot find Metal-1 arc");		m2Arc = theTech.findArcProto("Metal-2");		if (msBut == null) throw new JobException("Cannot find Metal-2 arc");		pArc = theTech.findArcProto("Polysilicon-1");		if (msBut == null) throw new JobException("Cannot find Polysilicon-1 arc");		aArc = theTech.findArcProto("N-Active");		if (msBut == null) throw new JobException("Cannot find N-Active arc");		// make sure the standard cell library is read in		String libName = "pla_mocmos";		Library cellLib = Library.findLibrary(libName);		if (cellLib == null) throw new JobException("Cannot find the 'pla_mocmos' support library");		// find required cells in the library		nmosOne = cellLib.findNodeProto("nmos_one");		if (nmosOne == null) throw new JobException("Unable to find cell 'nmos_one'");		pmosOne = cellLib.findNodeProto("pmos_one");		if (pmosOne == null) throw new JobException("Unable to find cell 'pmos_one'");		decoderInv = cellLib.findNodeProto("decoder_inv1");		if (decoderInv == null) throw new JobException("Unable to find cell 'decoder_inv1'");		ioInv4 = cellLib.findNodeProto("io-inv-4");		if (ioInv4 == null) throw new JobException("Unable to find cell 'io-inv-4'");		pullUps = cellLib.findNodeProto("pullups");		if (pullUps == null) throw new JobException("Unable to find cell 'pullups'");		// initialize the global tables		columnList = new UCRow[MAX_COL_SIZE];		rowList = new UCRow[MAX_COL_SIZE][3];		for(int i=0; i<MAX_COL_SIZE; i++)		{			columnList[i] = new UCRow();			rowList[i][0] = new UCRow();			rowList[i][1] = new UCRow();			rowList[i][2] = new UCRow();		}	}	/**	 * This class displays a dialog to setup PLA generation.	 */	private static class SetupPLAGen extends EDialog	{		private JTextField andPlaneFile, orPlaneFile, cellName;		private JCheckBox inputs, outputs;		private boolean good;		/** Creates new form to setup PLA generation */		private SetupPLAGen()		{			super(null, true);			good = false;			initComponents();			setVisible(true);		}		protected void escapePressed() { exit(false); }		public boolean failed() { return !good; }		public String getAndFileName() { return andPlaneFile.getText(); }		public String getOrFileName() { return orPlaneFile.getText(); }		public boolean isInputsOnTop() { return inputs.isSelected(); }		public boolean isOutputsOnBottom() { return outputs.isSelected(); }		public String getCellName() { return cellName.getText(); }		// Call this method when the user clicks the OK button		private void exit(boolean goodButton)		{			good = goodButton;			setVisible(false);		}		private void browse(boolean andPlane)		{			String fileName = OpenFile.chooseInputFile(FileType.ANY,				(andPlane ? "AND Plane File:" : "OR Plane File:"));			if (fileName == null) return;			if (andPlane) andPlaneFile.setText(fileName); else				orPlaneFile.setText(fileName);		}		private void initComponents()		{			getContentPane().setLayout(new GridBagLayout());			setTitle("MOSIS CMOS PLA Generation Control");			setName("");			addWindowListener(new WindowAdapter()			{				public void windowClosing(WindowEvent evt) { exit(false); }			});			// the AND plane			JLabel lab1 = new JLabel("AND Plane File:");			GridBagConstraints gbc = new GridBagConstraints();			gbc.gridx = 0;   gbc.gridy = 0;			gbc.anchor = GridBagConstraints.WEST;			gbc.insets = new java.awt.Insets(4, 4, 4, 4);			getContentPane().add(lab1, gbc);			andPlaneFile = new JTextField();			andPlaneFile.setColumns(35);			gbc = new GridBagConstraints();			gbc.gridx = 1;   gbc.gridy = 0;			gbc.fill = GridBagConstraints.BOTH;			gbc.weightx = 1;   gbc.weighty = 0.5;

⌨️ 快捷键说明

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