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

📄 flat.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: Flat.java * Asynchronous Logic Simulator network flattening * Original C Code written by Brent Serbin and Peter J. Gallant * Translated to Java by Steven M. 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.simulation.als;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.text.TextUtils;import com.sun.electric.tool.simulation.als.ALS.IO;import com.sun.electric.tool.simulation.als.ALS.Stat;import java.util.ArrayList;import java.util.Iterator;import java.util.List;/** * Class to flatten circuitry for the ALS Simulator. */public class Flat{	private ALS       als;	private ALS.Model primPtr2;	Flat(ALS als)	{		this.als = als;	}	/**	 * Method to call a series of routines which convert the hierarchical	 * network description into a flattened database representation.  The actual	 * simulation must take place on the flattened network.  Returns true on error.	 */	boolean flattenNetwork(Cell cell)	{		/*		 * create a "dummy" level to use as a mixed signal destination for plotting and		 * screen display.  This level should be bypassed for structure checking and general		 * simulation, however, so in the following code, references to "als.cellRoot"		 * have been changed to als.cellRoot.next (pointing to mainCell).		 * Peter Gallant July 16, 1990		 */		als.cellRoot = new ALS.Connect();		als.cellRoot.instName = "[MIXED_SIGNAL_LEVEL]";		als.cellRoot.modelName = als.cellRoot.instName;		als.cellRoot.exList = new ArrayList<ALS.ALSExport>();		als.cellRoot.parent = null;		als.cellRoot.child = null;		als.cellRoot.next = null;		ALS.Connect tempRoot = als.cellRoot;		// get upper-case version of main proto		String mainName = cell.getName().toUpperCase();		als.cellRoot = new ALS.Connect();		als.cellRoot.instName = mainName;		als.cellRoot.modelName = als.cellRoot.instName;		als.cellRoot.exList = new ArrayList<ALS.ALSExport>();		als.cellRoot.parent = null;		als.cellRoot.child = null;		als.cellRoot.next = null;		// these lines link the mixed level as the head followed by mainCell PJG		tempRoot.next = als.cellRoot;		// shouldn't this be null? ... smr		tempRoot.child = als.cellRoot;		als.cellRoot = tempRoot;		// this code checks to see if model mainCell is present in the netlist PJG		ALS.Model modHead = findModel(mainName);		if (modHead == null) return true;		for(ALS.ALSExport exHead : modHead.exList)		{			findXRefEntry(als.cellRoot.next, (String)exHead.nodeName);		}		if (flattenModel(als.cellRoot.next)) return true;		for(ALS.Node nodeHead : als.nodeList)		{			if (nodeHead.load < 1) nodeHead.load = 1;		}		return false;	}	/**	 * Method to flatten a single model.  If other models are referenced	 * in connection statements in the netlist, this routine is called recursively	 * until a totally flat model is obtained.  Returns true on error.	 *	 * Calling Arguments:	 *	cellHead = pointer to a data structure containing information about	 *		  the model that is going to be flattened	 */	private boolean flattenModel(ALS.Connect cellHead)	{		ALS.Model modHead = findModel(cellHead.modelName);		if (modHead == null) return true;		switch (modHead.type)		{			case 'F':				if (processFunction(cellHead, modHead)) return true;				break;			case 'G':				processGate(cellHead, modHead);				break;			case 'M':				if (processConnectList(cellHead, (ALS.Connect)modHead.ptr)) return true;				for (ALS.Connect subCell = cellHead.child; subCell != null; subCell = subCell.next)				{					if (flattenModel(subCell)) return true;				}				break;		}		if (modHead.setList.size() != 0)		{			processSetEntry(cellHead, modHead.setList);		}		return false;	}	/**	 * Method to step through the connection list specified by the	 * connection list pointer (conHead).  Values are entered into the cross	 * reference table for the present level of hierarchy and new data structures	 * are created for the lower level of hierarchy to store their cross	 * reference tables.  Returns true on error.	 *	 * Calling Arguments:	 *	cellHead = pointer to the cross reference data structure for the model	 *		  that is going to be flattened	 *	conHead  = pointer to a list of connection statements for the model	 *		  that is being flattened by this procedure	 */	private boolean processConnectList(ALS.Connect cellHead, ALS.Connect conHead)	{		while (conHead != null)		{			ALS.Connect cellPtr2 = new ALS.Connect();			cellPtr2.instName = conHead.instName;			cellPtr2.modelName = conHead.modelName;			cellPtr2.exList = new ArrayList<ALS.ALSExport>();			cellPtr2.parent = cellHead;			cellPtr2.child = null;			cellPtr2.next = cellHead.child;			cellHead.child = cellPtr2;			ALS.Model modHead = findModel(conHead.modelName);			if (modHead == null) return true;			Iterator<ALS.ALSExport> it = modHead.exList.iterator();			for(ALS.ALSExport exHead : conHead.exList)			{				if (!it.hasNext()) break;				als.exPtr2 = it.next();				ALS.ALSExport xRefHead = findXRefEntry(cellHead, (String)exHead.nodeName);				if (als.exPtr2 == null)				{					System.out.println("Insufficient parameters declared for model '" + conHead.modelName + "' in netlist");					return true;				}				for(ALS.ALSExport xRefPtr1 : cellPtr2.exList)				{					if (xRefPtr1.nodeName.equals(als.exPtr2.nodeName))					{						System.out.println("Node '" + als.exPtr2.nodeName + "' in model '" +							conHead.modelName + "' connected more than once");						return true;					}				}				ALS.ALSExport xRefPtr2 = new ALS.ALSExport();				xRefPtr2.nodeName = als.exPtr2.nodeName;				xRefPtr2.nodePtr = xRefHead.nodePtr;				cellPtr2.exList.add(xRefPtr2);			}			conHead = conHead.next;		}		return false;	}	/**	 * Method to return a pointer to the model referenced by the	 * calling argument character string.  Returns zero on error.	 *	 * Calling Arguments:	 *	modelName = pointer to a string which contains the name of the model	 *		    to be located by the search procedure	 */	private ALS.Model findModel(String modelName)	{		// convert to proper name		StringBuffer sb = new StringBuffer();		for(int i=0; i<modelName.length(); i++)		{			char chr = modelName.charAt(i);			if (!TextUtils.isLetterOrDigit(chr)) chr = '_';			sb.append(chr);		}		String properName = sb.toString();		for(ALS.Model modHead : als.modelList)		{			if (modHead.name.equals(properName)) return modHead;		}		System.out.println("ERROR: Model '" + properName + "' not found, simulation aborted");		return null;	}	/**	 * Method to return the flattened database node number for the	 * specified model and node name.	 *	 * Calling Arguments:	 *	cellHead = pointer to the xref table for the model being processed	 *	name    = pointer to a char string containing the node name	 */	private ALS.ALSExport findXRefEntry(ALS.Connect cellHead, String name)	{		for(ALS.ALSExport xRefPtr1 : cellHead.exList)		{			if (xRefPtr1.nodeName.equals(name)) return xRefPtr1;		}		ALS.ALSExport xRefPtr2 = new ALS.ALSExport();		xRefPtr2.nodeName = name;		cellHead.exList.add(xRefPtr2);		ALS.Node nodePtr2 = new ALS.Node();		nodePtr2.cellPtr = cellHead;		nodePtr2.statList = new ArrayList<Stat>();		nodePtr2.pinList = new ArrayList<ALS.Load>();		nodePtr2.load = -1;		nodePtr2.visit = 0;		nodePtr2.traceNode = false;		als.nodeList.add(nodePtr2);		xRefPtr2.nodePtr = nodePtr2;		return xRefPtr2;	}	/**	 * Method to step through the gate truth tables and examines all

⌨️ 快捷键说明

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