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

📄 compilevhdl.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: CompileVHDL.java * Compile VHDL to a netlist * Written by Andrew R. Kostiuk, Queen's University. * 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.user;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.text.TextUtils;import com.sun.electric.database.variable.Variable;import com.sun.electric.tool.sc.SilComp;import java.util.ArrayList;import java.util.Date;import java.util.HashMap;import java.util.HashSet;import java.util.Iterator;import java.util.List;/** * This is the VHDL Compiler. */public class CompileVHDL{	/********** Token Definitions ******************************************/	/********** Delimiters **********/	private static final int TOKEN_AMPERSAND	= 0;	private static final int TOKEN_APOSTROPHE	= 1;	private static final int TOKEN_LEFTBRACKET	= 2;	private static final int TOKEN_RIGHTBRACKET	= 3;	private static final int TOKEN_STAR			= 4;	private static final int TOKEN_PLUS			= 5;	private static final int TOKEN_COMMA		= 6;	private static final int TOKEN_MINUS		= 7;	private static final int TOKEN_PERIOD		= 8;	private static final int TOKEN_SLASH		= 9;	private static final int TOKEN_COLON		= 10;	private static final int TOKEN_SEMICOLON	= 11;	private static final int TOKEN_LT			= 12;	private static final int TOKEN_EQ			= 13;	private static final int TOKEN_GT			= 14;	private static final int TOKEN_VERTICALBAR	= 15;	/********** Compound Delimiters **********/	private static final int TOKEN_ARROW		= 16;	private static final int TOKEN_DOUBLEDOT	= 17;	private static final int TOKEN_DOUBLESTAR	= 18;	private static final int TOKEN_VARASSIGN	= 19;	private static final int TOKEN_NE			= 20;	private static final int TOKEN_GE			= 21;	private static final int TOKEN_LE			= 22;	private static final int TOKEN_BOX			= 23;	/********** Other Token **********/	private static final int TOKEN_UNKNOWN		= 24;	private static final int TOKEN_IDENTIFIER	= 25;				/* alphanumeric (first char alpha) */	private static final int TOKEN_KEYWORD		= 26;				/* reserved keyword of the language */	private static final int TOKEN_DECIMAL		= 27;				/* decimal literal */	private static final int TOKEN_BASED		= 28;				/* based literal */	private static final int TOKEN_CHAR			= 29;				/* character literal */	private static final int TOKEN_STRING		= 30;				/* string enclosed in double quotes */	private static final int TOKEN_BIT_STRING	= 31;				/* bit string */	/********** Keyword Constants ******************************************/	private static final int KEY_ABS			= 0;	private static final int KEY_AFTER			= 1;	private static final int KEY_ALIAS			= 2;	private static final int KEY_AND			= 3;	private static final int KEY_ARCHITECTURE	= 4;	private static final int KEY_ARRAY			= 5;	private static final int KEY_ASSERTION		= 6;	private static final int KEY_ATTRIBUTE		= 7;	private static final int KEY_BEHAVIORAL		= 8;	private static final int KEY_BEGIN			= 9;	private static final int KEY_BODY			= 10;	private static final int KEY_CASE			= 11;	private static final int KEY_COMPONENT		= 12;	private static final int KEY_CONNECT		= 13;	private static final int KEY_CONSTANT		= 14;	private static final int KEY_CONVERT		= 15;	private static final int KEY_DOT			= 16;	private static final int KEY_DOWNTO			= 17;	private static final int KEY_ELSE			= 18;	private static final int KEY_ELSIF			= 19;	private static final int KEY_END			= 20;	private static final int KEY_ENTITY			= 21;	private static final int KEY_EXIT			= 22;	private static final int KEY_FOR			= 23;	private static final int KEY_FUNCTION		= 24;	private static final int KEY_GENERATE		= 25;	private static final int KEY_GENERIC		= 26;	private static final int KEY_IF				= 27;	private static final int KEY_IN				= 28;	private static final int KEY_INOUT			= 29;	private static final int KEY_IS				= 30;	private static final int KEY_LINKAGE		= 31;	private static final int KEY_LOOP			= 32;	private static final int KEY_MOD			= 33;	private static final int KEY_NAND			= 34;	private static final int KEY_NEXT			= 35;	private static final int KEY_NOR			= 36;	private static final int KEY_NOT			= 37;	private static final int KEY_NULL			= 38;	private static final int KEY_OF				= 39;	private static final int KEY_OR				= 40;	private static final int KEY_OTHERS			= 41;	private static final int KEY_OUT			= 42;	private static final int KEY_PACKAGE		= 43;	private static final int KEY_PORT			= 44;	private static final int KEY_RANGE			= 45;	private static final int KEY_RECORD			= 46;	private static final int KEY_REM			= 47;	private static final int KEY_REPORT			= 48;	private static final int KEY_RESOLVE		= 49;	private static final int KEY_RETURN			= 50;	private static final int KEY_SEVERITY		= 51;	private static final int KEY_SIGNAL			= 52;	private static final int KEY_STANDARD		= 53;	private static final int KEY_STATIC			= 54;	private static final int KEY_SUBTYPE		= 55;	private static final int KEY_THEN			= 56;	private static final int KEY_TO				= 57;	private static final int KEY_TYPE			= 58;	private static final int KEY_UNITS			= 59;	private static final int KEY_USE			= 60;	private static final int KEY_VARIABLE		= 61;	private static final int KEY_WHEN			= 62;	private static final int KEY_WHILE			= 63;	private static final int KEY_WITH			= 64;	private static final int KEY_XOR			= 65;	private static final int KEY_OPEN			= 66;	private static final int KEY_MAP			= 67;	private static final int KEY_ALL			= 68;	private static final int KEY_LIBRARY		= 69;	/********** Miscellaneous Constants *********************************/	/** enternal entities flag */		private static final boolean EXTERNALENTITIES = true;	/** warning flag, TRUE warn */		private static final boolean WARNFLAG = false;	/** flag the entity as called */	private static final int     TOP_ENTITY_FLAG	= 0x0001;	/** flag the entity as written */	private static final int     ENTITY_WRITTEN		= 0x0002;	/********** Keyword Structures *****************************************/	private static class VKeyword	{		/** string defining keyword */	String	name;		/** number of keyword */		int		num;		VKeyword(String name, int num) { this.name = name;   this.num = num; }	};	/********** Token Structures *****************************************/	private class TokenList	{		/** token number */								int	token;		/** NULL if delimiter,		 * pointer to global name space if identifier,		 * pointer to keyword table if keyword,		 * pointer to string if decimal literal,		 * pointer to string if based literal,		 * value of character if character literal,		 * pointer to string if string literal,		 * pointer to string if bit string literal */	Object	pointer;		 /** TRUE if space before next token */			boolean	space;		 /** line number token occurred */				int	lineNum;		 /** next in list */							TokenList next;		 /** previous in list */						TokenList last;		TokenList(int token, Object pointer, int lineNum, boolean space)		{			this.token = token;			this.pointer = pointer;			this.lineNum = lineNum;			this.space = true;			this.next = null;			this.last = tListEnd;			if (tListEnd == null)			{				tListStart = tListEnd = this;			} else			{				tListEnd.space = space;				tListEnd.next = this;				tListEnd = this;			}		}	};	/********** Symbol Trees **********************************************/	private static final int SYMBOL_ENTITY		= 1;	private static final int SYMBOL_BODY		= 2;	private static final int SYMBOL_TYPE		= 3;	private static final int SYMBOL_FPORT		= 4;	private static final int SYMBOL_COMPONENT	= 5;	private static final int SYMBOL_SIGNAL		= 6;	private static final int SYMBOL_INSTANCE	= 7;	private static final int SYMBOL_VARIABLE	= 8;	private static final int SYMBOL_LABEL		= 9;	private static final int SYMBOL_PACKAGE		= 10;	private static final int SYMBOL_CONSTANT	= 11;	private static class SymbolTree	{		/** identifier */				String			value;		/** type of item */				int				type;		/** pointer to item */			Object			pointer;		/** flag for deallocation */	int             seen;	};	private static class SymbolList	{		/** the symbol table map */		HashMap<String,SymbolTree> sym;		/** previous in stack */		SymbolList		           last;		/** next in list */				SymbolList		           next;	};	/********** Unresolved Reference List **********************************/	private static class UnResList	{		/** name of reference */		String			interfacef;		/** number of references */		int				numRef;		/** next in list */				UnResList		next;	};	/***********************************************************************/	private static class DBUnits	{		/** list of interfaces */		DBInterface		interfaces;		/** list of bodies */			DBBody			bodies;	};	private static class DBPackage	{		/** name of package */			String			name;		/** root of symbol tree */		SymbolList		root;	};	private static class DBInterface	{		/** name of interface */		String			name;		/** list of ports */			DBPortList		ports;		/** interface declarations */	Object			interfacef;		/** for later code gen */		int				flags;		/** associated bodies */		DBBody			bodies;		/** local symbols */			SymbolList		symbols;		/** next interface */			DBInterface		next;	};	private static final int DBMODE_IN			= 1;	private static final int DBMODE_OUT			= 2;//	private static final int DBMODE_DOTOUT		= 3;//	private static final int DBMODE_INOUT		= 4;//	private static final int DBMODE_LINKAGE		= 5;	private static class DBPortList	{		/** name of port */				String			name;		/** mode of port */				int				mode;		/** type of port */				DBLType			type;		/** general flags */			int				flags;		/** next in port list */		DBPortList		next;	};	private static final int DBTYPE_SINGLE		= 1;	private static final int DBTYPE_ARRAY		= 2;	private static class DBLType	{		/** name of type */				String			name;		/** type of type */				int				type;		/** pointer to info */			Object			pointer;		/** possible subtype */			DBLType			subType;	};	/********** Bodies *****************************************************/	private static class DBBody	{		/** name of body: identifier */	String			name;		/** parent entity of body */	String			entity;		/** declarations */				DBBodyDelcare	declare;		/** statements in body */		DBStatements	statements;		/** pointer to parent */		DBInterface		parent;		/** bodies of same parent */	DBBody			sameParent;		/** next body */				DBBody			next;	};	private static class DBBodyDelcare	{		/** components */				DBComponents	components;		/** signals */					DBSignals		bodySignals;	};	private static class DBComponents	{		/** name of component */		String			name;		/** list of ports */			DBPortList		ports;		/** next component */			DBComponents	next;	};	private static class DBSignals	{		/** name of signal */			String			name;		/** type of signal */			DBLType			type;		/** next signal */				DBSignals		next;	};	/********** Architectural Statements ***********************************/	private static class DBStatements	{		DBInstance		instances;	};	private static class DBInstance	{		/** identifier */				String			name;		/** component */				DBComponents	compo;		/** ports on instance */		DBAPortList		ports;		/** next instance in list */	DBInstance		next;	};	private static class DBAPortList	{		/** name of port */				DBName			name;		/** pointer to port on comp */	DBPortList		port;		/** flags for processing */		int				flags;		/** next in list */				DBAPortList		next;	};	/********** Names ******************************************************/	private static final int DBNAME_IDENTIFIER		= 1;	private static final int DBNAME_INDEXED			= 2;	private static final int DBNAME_CONCATENATED	= 3;	private static class DBName	{		/** name of name */				String			name;		/** type of name */				int				type;		/** null if identifier		 * DBExprList if indexed		 * DBNameList if concatenated */Object			pointer;		/** pointer to type */			DBLType			dbType;	};	private static class DBExprList	{		/** value */					int				value;		/** next in list */				DBExprList		next;	};	private static class DBDiscreteRange	{		/** start of range */			int				start;		/** end of range */				int				end;	};	private static class DBIndexRange	{		/** discrete range */			DBDiscreteRange	dRange;		/** next in list */				DBIndexRange	next;	};	private static class DBNameList	{		/** name in list */				DBName			name;		/** next in list */				DBNameList		next;	};	/******** Parser Constants and Structures ******************************/	private static final int NOUNIT			= 0;	private static final int UNIT_INTERFACE	= 1;	private static final int UNIT_FUNCTION	= 2;	private static final int UNIT_PACKAGE	= 3;	private static final int UNIT_BODY		= 4;	private static final int UNIT_USE		= 6;	private static class PTree	{		/** type of entity */			int				type;		/** pointer to design unit */	Object			pointer;		/** pointer to next */			PTree			next;	};	/********** Packages ***************************************************/	private static class Package	{		/** package name */				TokenList		name;		/** package declare part */		PackagedPart	declare;		/** package declare items */	List			packagedParts;	};	private static class PackagedPart	{		/** package declare item */		BasicDeclare	item;		/** pointer to next */			PackagedPart	next;	};	private static class Use	{		/** unit */						TokenList		unit;		/** next in list */				Use				next;	};	/********** Interfaces *************************************************/	private static class VInterface	{		/** name of entity */			TokenList		name;		/** list of ports */			FPortList		ports;		/** interface declarations */	Object			interfacef;	};	private static final int MODE_IN			= 1;	private static final int MODE_OUT			= 2;	private static final int MODE_DOTOUT		= 3;	private static final int MODE_INOUT			= 4;	private static final int MODE_LINKAGE		= 5;	private static class FPortList	{		/** names of port */			IdentList		names;		/** mode of port */				int				mode;		/** type of port */				VName			type;		/** next in port list */		FPortList		next;	};	private static class IdentList	{		/** identifier */				TokenList		identifier;		/** next in list */				IdentList		next;	};	/********** Bodies *****************************************************///	private static final int BODY_BEHAVIORAL	= 1;//	private static final int BODY_ARCHITECTURAL	= 2;	private static class Body	{		/** name of body: identifier */	TokenList		name;		/** parent entity of body */	SimpleName		entity;		/** body declarations */		BodyDeclare		bodyDeclare;		/** statements in body */		Statements		statements;	};	private static final int BODYDECLARE_BASIC		= 1;	private static final int BODYDECLARE_COMPONENT	= 2;	private static final int BODYDECLARE_RESOLUTION	= 3;	private static final int BODYDECLARE_LOCAL		= 4;

⌨️ 快捷键说明

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