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

📄 compilevhdl.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
	private static class BodyDeclare	{		/** type of declaration */		int				type;		/** pointer to part tree */		Object			pointer;		/** next in list */				BodyDeclare		next;	};	/********** Basic Declarations *****************************************/	private static final int NOBASICDECLARE				= 0;	private static final int BASICDECLARE_OBJECT		= 1;	private static final int BASICDECLARE_TYPE			= 2;	private static final int BASICDECLARE_SUBTYPE		= 3;	private static final int BASICDECLARE_CONVERSION	= 4;	private static final int BASICDECLARE_ATTRIBUTE		= 5;	private static final int BASICDECLARE_ATT_SPEC		= 6;	private static class BasicDeclare	{		/** type of basic declare */	int				type;		/** pointer to parse tree */	Object			pointer;	};	private static final int NOOBJECTDECLARE			= 0;	private static final int OBJECTDECLARE_CONSTANT		= 1;	private static final int OBJECTDECLARE_SIGNAL		= 2;	private static final int OBJECTDECLARE_VARIABLE		= 3;	private static final int OBJECTDECLARE_ALIAS		= 4;	private static class ObjectDeclare	{		/** type of object declare */	int				type;		/** pointer to parse tree */	Object			pointer;	};	private static class SignalDeclare	{		/** list of identifiers */		IdentList		names;		/** subtype indicator */		SubTypeInd		subType;	};	private static class VComponent	{		/** name of component */		TokenList		name;		/** ports of component */		FPortList		ports;	};	private static class ConstantDeclare	{		/** name of constant */			TokenList		identifier;		/** subtype indicator */		SubTypeInd		subType;		/** expression */				Expression		expression;	};	/********** Types ******************************************************/	private static class SubTypeInd	{		/** type of subtype */			VName			type;	};	private static final int TYPE_SCALAR		= 1;	private static final int TYPE_COMPOSITE		= 2;	private static class Type	{		/** name of type */				TokenList		identifier;		/** type definition */			int				type;		/** pointer to type */			Object			pointer;	};	private static final int COMPOSITE_ARRAY	= 1;	private static final int COMPOSITE_RECORD	= 2;	private static class Composite	{		/** type of composite */		int				type;		/** pointer to composite */		Object			pointer;	};	private static final int ARRAY_UNCONSTRAINED	= 1;	private static final int ARRAY_CONSTRAINED		= 2;	private static class Array	{		/** (un)constrained array */	int				type;		/** pointer to array */			Object			pointer;	};	private static class Constrained	{		/** index constraint */			IndexConstraint	constraint;		/** subtype indication */		SubTypeInd		subType;	};	private static class IndexConstraint	{		/** discrete range */			DiscreteRange	discrete;		/** possible more */			IndexConstraint	next;	};	/********** Architectural Statements ***********************************/	private static final int NOARCHSTATE			= 0;	private static final int ARCHSTATE_GENERATE		= 1;	private static final int ARCHSTATE_SIG_ASSIGN	= 2;	private static final int ARCHSTATE_IF			= 3;	private static final int ARCHSTATE_CASE			= 4;	private static final int ARCHSTATE_INSTANCE		= 5;	private static final int ARCHSTATE_NULL			= 6;	private static class Statements	{		/** type of statement */		int				type;		/** pointer to parse tree */	Object			pointer;		/** pointer to next */			Statements		next;	};	private static class VInstance	{		/** optional identifier */		TokenList		name;		/** entity of instance */		SimpleName		entity;		/** ports on instance */		APortList		ports;	};	private static final int APORTLIST_NAME			= 1;//	private static final int APORTLIST_TYPE_NAME	= 2;//	private static final int APORTLIST_EXPRESSION	= 3;	private static class APortList	{		/** type of actual port */		int				type;		/** pointer to parse tree */	Object			pointer;		/** next in list */				APortList		next;	};	private static class Generate	{		/** optional label */			TokenList		label;		/** generate scheme */			GenScheme		genScheme;		/** statements */				Statements		statements;	};	private static final int GENSCHEME_FOR		= 0;	private static final int GENSCHEME_IF		= 1;	private static class GenScheme	{		/** scheme (for or if) */		int				scheme;		/** if FOR scheme */			TokenList		identifier;		/** if FOR scheme */			DiscreteRange	range;		/** if IF scheme */				Expression		condition;	};	/********** Names ******************************************************/	private static final int NONAME				= 0;	private static final int NAME_SINGLE		= 1;	private static final int NAME_CONCATENATE	= 2;	private static final int NAME_ATTRIBUTE		= 3;	private static class VName	{		/** type of name */				int				type;		/** pointer to parse tree */	Object			pointer;	};	private static final int NOSINGLENAME			= 0;	private static final int SINGLENAME_SIMPLE		= 1;	private static final int SINGLENAME_SELECTED	= 2;	private static final int SINGLENAME_INDEXED		= 3;	private static final int SINGLENAME_SLICE		= 4;	private static class SingleName	{		/** type of simple name */		int				type;		/** pointer to parse tree */	Object			pointer;	};	private static class SimpleName	{		/** identifier */				TokenList		identifier;	};	private static final int PREFIX_NAME			= 1;	private static final int PREFIX_FUNCTION_CALL	= 2;	private static class Prefix	{		/** type of prefix */			int				type;		/** pointer to parse tree */	Object			pointer;	};	private static class IndexedName	{		/** prefix */					Prefix			prefix;		/** expression list */			ExprList		exprList;	};	private static class ExprList	{		/** expression */				Expression		expression;		/** next in list */				ExprList		next;	};	private static final int DISCRETERANGE_SUBTYPE	= 1;	private static final int DISCRETERANGE_RANGE	= 2;	private static class DiscreteRange	{		/** type of discrete range */	int				type;		/** pointer to parse tree */	Object			pointer;	};	private static final int RANGE_ATTRIBUTE	= 1;	private static final int RANGE_SIMPLE_EXPR	= 2;	private static class Range	{		/** type of range */			int				type;		/** pointer to parse tree */	Object			pointer;	};	private static class RangeSimple	{		/** start of range */			SimpleExpr		start;		/** end of range */				SimpleExpr		end;	};	private static class ConcatenatedName	{		/** single name */				SingleName		name;		/** next in list */				ConcatenatedName next;	};	/********** Expressions ************************************************/	private static final int NOLOGOP		= 0;	private static final int LOGOP_AND		= 1;	private static final int LOGOP_OR		= 2;	private static final int LOGOP_NAND		= 3;	private static final int LOGOP_NOR		= 4;	private static final int LOGOP_XOR		= 5;	private static class Expression	{		/** first relation */			Relation		relation;		/** more relations */			MRelations		next;	};	private static final int NORELOP		= 0;	private static final int RELOP_EQ		= 1;	private static final int RELOP_NE		= 2;	private static final int RELOP_LT		= 3;	private static final int RELOP_LE		= 4;	private static final int RELOP_GT		= 5;	private static final int RELOP_GE		= 6;	private static class Relation	{		/** simple expression */		SimpleExpr		simpleExpr;		/** possible operator */		int				relOperator;		/** possible expression */		SimpleExpr		simpleExpr2;	};	private static class MRelations	{		/** logical operator */			int				logOperator;		/** relation */					Relation		relation;		/** more relations */			MRelations		next;	};	private static final int NOADDOP			= 0;	private static final int ADDOP_ADD			= 1;	private static final int ADDOP_SUBTRACT		= 2;	private static class SimpleExpr	{		/** sign (1 or  -1) */			int				sign;		/** first term */				Term			term;		/** additional terms */			MTerms			next;	};	private static final int NOMULOP			= 0;	private static final int MULOP_MULTIPLY		= 1;	private static final int MULOP_DIVIDE		= 2;	private static final int MULOP_MOD			= 3;	private static final int MULOP_REM			= 4;	private static class Term	{		/** first factor */				Factor			factor;		/** additional factors */		MFactors		next;	};	private static class MTerms	{		/** add operator */				int				addOperator;		/** next term */				Term			term;		/** any more terms */			MTerms			next;	};	private static final int NOMISCOP			= 0;	private static final int MISCOP_POWER		= 1;	private static final int MISCOP_ABS			= 2;	private static final int MISCOP_NOT			= 3;	private static class Factor	{		/** first primary */			Primary			primary;		/** possible operator */		int				miscOperator;		/** possible primary */			Primary			primary2;	};	private static class MFactors	{		/** operator */					int				mulOperator;		/** next factor */				Factor			factor;		/** possible more factors */	MFactors		next;	};	private static final int NOPRIMARY					= 0;	private static final int PRIMARY_NAME				= 1;	private static final int PRIMARY_LITERAL			= 2;	private static final int PRIMARY_AGGREGATE			= 3;	private static final int PRIMARY_CONCATENATION		= 4;	private static final int PRIMARY_FUNCTION_CALL		= 5;	private static final int PRIMARY_TYPE_CONVERSION	= 6;	private static final int PRIMARY_QUALIFIED_EXPR		= 7;	private static final int PRIMARY_EXPRESSION			= 8;	private static class Primary	{		/** type of primary */			int				type;		/** pointer to primary */		Object			pointer;	};	private static final int NOLITERAL				= 0;	private static final int LITERAL_NUMERIC		= 1;	private static final int LITERAL_ENUMERATION	= 2;	private static final int LITERAL_STRING			= 3;	private static final int LITERAL_BIT_STRING		= 4;	private static class Literal	{		/** type of literal */			int				type;		/** pointer to parse tree */	Object			pointer;	};	/* special codes during VHDL generation *///	/** ordinary block */				private static final int BLOCKNORMAL   =  0;//	/** a MOS transistor */				private static final int BLOCKMOSTRAN  =  1;//	/** a buffer */						private static final int BLOCKBUFFER   =  2;//	/** an and, or, xor */				private static final int BLOCKPOSLOGIC =  3;//	/** an inverter */					private static final int BLOCKINVERTER =  4;//	/** a nand */						private static final int BLOCKNAND     =  5;//	/** a nor */						private static final int BLOCKNOR      =  6;//	/** an xnor */						private static final int BLOCKXNOR     =  7;//	/** a settable D flip-flop */		private static final int BLOCKFLOPDS   =  8;//	/** a resettable D flip-flop */		private static final int BLOCKFLOPDR   =  9;//	/** a settable T flip-flop */		private static final int BLOCKFLOPTS   = 10;//	/** a resettable T flip-flop */		private static final int BLOCKFLOPTR   = 11;//	/** a general flip-flop */			private static final int BLOCKFLOP     = 12;	private static String	delimiterStr = "&'()*+,-./:;<=>|";	private static String	doubleDelimiterStr = "=>..**:=/=>=<=<>";	private static VKeyword [] theKeywords =	{		new VKeyword("abs",				KEY_ABS),		new VKeyword("after",			KEY_AFTER),		new VKeyword("alias",			KEY_ALIAS),		new VKeyword("all",				KEY_ALL),		new VKeyword("and",				KEY_AND),		new VKeyword("architecture",	KEY_ARCHITECTURE),		new VKeyword("array",			KEY_ARRAY),		new VKeyword("assertion",		KEY_ASSERTION),		new VKeyword("attribute",		KEY_ATTRIBUTE),		new VKeyword("begin",			KEY_BEGIN),		new VKeyword("behavioral",		KEY_BEHAVIORAL),		new VKeyword("body",			KEY_BODY),		new VKeyword("case",			KEY_CASE),		new VKeyword("component",		KEY_COMPONENT),		new VKeyword("connect",			KEY_CONNECT),		new VKeyword("constant",		KEY_CONSTANT),		new VKeyword("convert",			KEY_CONVERT),		new VKeyword("dot",				KEY_DOT),		new VKeyword("downto",			KEY_DOWNTO),		new VKeyword("else",			KEY_ELSE),		new VKeyword("elsif",			KEY_ELSIF),		new VKeyword("end",				KEY_END),		new VKeyword("entity",			KEY_ENTITY),		new VKeyword("exit",			KEY_EXIT),		new VKeyword("for",				KEY_FOR),		new VKeyword("function",		KEY_FUNCTION),		new VKeyword("generate",		KEY_GENERATE),		new VKeyword("generic",			KEY_GENERIC),		new VKeyword("if",				KEY_IF),		new VKeyword("in",				KEY_IN),		new VKeyword("inout",			KEY_INOUT),		new VKeyword("is",				KEY_IS),		new VKeyword("library",			KEY_LIBRARY),		new VKeyword("linkage",			KEY_LINKAGE),		new VKeyword("loop",			KEY_LOOP),		new VKeyword("map",				KEY_MAP),		new VKeyword("mod",				KEY_MOD),		new VKeyword("nand",			KEY_NAND),		new VKeyword("next",			KEY_NEXT),		new VKeyword("nor",				KEY_NOR),		new VKeyword("not",				KEY_NOT),		new VKeyword("null",			KEY_NULL),		new VKeyword("of",				KEY_OF),		new VKeyword("open",			KEY_OPEN),		new VKeyword("or",				KEY_OR),		new VKeyword("others",			KEY_OTHERS),		new VKeyword("out",				KEY_OUT),		new VKeyword("package",			KEY_PACKAGE),		new VKeyword("port",			KEY_PORT),		new VKeyword("range",			KEY_RANGE),		new VKeyword("record",			KEY_RECORD),		new VKeyword("rem",				KEY_REM),		new VKeyword("report",			KEY_REPORT),		new VKeyword("resolve",			KEY_RESOLVE),		new VKeyword("return",			KEY_RETURN),		new VKeyword("severity",		KEY_SEVERITY),		new VKeyword("signal",			KEY_SIGNAL),		new VKeyword("standard",		KEY_STANDARD),		new VKeyword("static",			KEY_STATIC),		new VKeyword("subtype",			KEY_SUBTYPE),		new VKeyword("then",			KEY_THEN),		new VKeyword("to",				KEY_TO),		new VKeyword("type",			KEY_TYPE),		new VKeyword("units",			KEY_UNITS),		new VKeyword("use",				KEY_USE),		new VKeyword("variable",		KEY_VARIABLE),		new VKeyword("when",			KEY_WHEN),		new VKeyword("while",			KEY_WHILE),		new VKeyword("with",			KEY_WITH),		new VKeyword("xor",				KEY_XOR)	};	private Cell vhdlCell;	private HashSet<String> identTable;	private TokenList  tListStart;	private TokenList  tListEnd;	private int errorCount;	private boolean hasErrors;	private UnResList  unResolvedList;	/**	 * The constructor compiles the VHDL and produces a netlist.	 */	public CompileVHDL(Cell vhdlCell)	{		this.vhdlCell = vhdlCell;		hasErrors = true;		String [] strings = vhdlCell.getTextViewContents();		if (strings == null)		{			System.out.println("Cell " + vhdlCell.describe(true) + " has no text in it");			return;		}		// initialize		unResolvedList = null;		// build and clear identTable		identTable = new HashSet<String>();		errorCount = 0;		doScanner(strings);		if (doParser(tListStart)) return;		if (doSemantic()) return;		hasErrors = false;	}	/**	 * Method to report whether the VHDL compile was successful.	 * @return true if there were errors.	 */

⌨️ 快捷键说明

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