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

📄 als.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
			{				--iPtr;				break;			}		}		return false;	}	/**	 * Method to set the delay transition type for the current input state.	 */	private boolean parseDelay()	{		String s1 = getAString();		if (s1 == null)		{			System.out.println("Timing declaration: EOF unexpectedly found");			return true;		}		if (!s1.equals("01") && !s1.equals("10") && !s1.equals("OZ") && !s1.equals("Z1") &&			!s1.equals("1Z") && !s1.equals("Z0") && !s1.equals("0X") && !s1.equals("X1") &&			!s1.equals("1X") && !s1.equals("X0") && !s1.equals("XZ") && !s1.equals("ZX"))		{			System.out.println("Invalid delay transition name '" + s1 + "'");			return true;		}		delay = s1;		return false;	}	/**	 * Method to set a flag in the model data structure regarding	 * if fanout calculations are to be performed for this models output.	 * If fanout calculations are required the model should have a single output.	 * Returns true on error.	 */	private boolean parseFanOut()	{		String s1 = getAString();		if (s1 == null)		{			System.out.println("Fanout declaration: EOF unexpectedly found");			return true;		}		if (!s1.startsWith("="))		{			System.out.println("Fanout declaration: Invalid Operator '" + s1 + "' (expecting '=')");			return true;		}		s1 = getAString();		if (s1 == null)		{			System.out.println("Fanout declaration: EOF unexpectedly found");			return true;		}		if (s1.equals("ON"))		{			modPtr2.fanOut = 1;			return false;		}		if (s1.equals("OFF"))		{			modPtr2.fanOut = 0;			return false;		}		System.out.println("Fanout declaration: Invalid option '" + s1 + "'");		return true;	}	/**	 * Method to enter the capacitive load rating (on per unit basis)	 * into the database for the specified node.  Returns true on error.	 */	private boolean parseLoad()	{		for(;;)		{			String s1 = getAName();			if (s1 == null || s1.equals("GATE") || s1.equals("FUNCTION") || s1.equals("MODEL") ||				s1.equals("I") || s1.equals("O") || s1.equals("T") || s1.equals("FANOUT") ||				s1.equals("LOAD") || s1.equals("PRIORITY") || s1.equals("SET"))			{				--iPtr;				break;			}			String s2 = getAString();			if (s2 == null)			{				System.out.println("Load declaration: EOF unexpectedly found");				return true;			}			if (s2.charAt(0) != '=')			{				System.out.println("Load declaration: Invalid Operator '" + s2 + "' (expecting '=')");				return true;			}			Double load = getADouble();			if (load == null)			{				System.out.println("Load declaration: EOF unexpectedly found");				return true;			}			Load loadPtr2 = new Load();			loadPtr2.ptr = s1;			loadPtr2.load = load.doubleValue();			modPtr2.loadList.add(loadPtr2);		}		return false;	}	/**	 * Method to parse the text used to describe a model entity.	 * The user specifies the interconnection of lower level primitives (gates and	 * functions) in this region of the netlist.  Returns true on error.	 */	private boolean parseModel()	{		for(;;)		{			String s1 = getAName();			if (s1 == null || s1.equals("GATE") || s1.equals("FUNCTION") || s1.equals("MODEL"))			{				--iPtr;				break;			}			if (s1.charAt(0) == '}') continue;			if (s1.equals("SET"))			{				ioPtr1 = modPtr2.setList;				if (parseNode()) return true;				continue;			}			for(Object conptr1 = modPtr2.ptr; conptr1 != null; conptr1 = ((Connect)conptr1).next)			{				Connect cp1 = (Connect)conptr1;				if (cp1.instName.equals(s1))				{					System.out.println("ERROR: Instance name '" + s1 + "' defined more than once");					return true;				}			}			Connect conPtr2 = new Connect();			conPtr2.instName = s1;			conPtr2.modelName = null;			conPtr2.exList = new ArrayList<ALSExport>();			conPtr2.next = (Connect)modPtr2.ptr;			modPtr2.ptr = conPtr2;			s1 = getAName();			if (s1 == null)			{				System.out.println("Model declaration: EOF unexpectedly found");				return true;			}			conPtr2.modelName = s1;			s1 = getAString();			if (s1 == null)			{				System.out.println("Model declaration: EOF unexpectedly found");				return true;			}			if (s1.charAt(0) != '(')			{				System.out.println("Model declaration: Expecting to find '(' in place of string '" + s1 + "'");				return true;			}			for(;;)			{				s1 = getAName();				if (s1 == null)				{					System.out.println("Model declaration: EOF unexpectedly found");					return true;				}				if (s1.charAt(0) == ')') break;				exPtr2 = new ALSExport();				exPtr2.nodePtr = null;				exPtr2.nodeName = s1;				conPtr2.exList.add(exPtr2);			}		}		return false;	}	/**	 * Method to parse the text used to describe a function entity.	 * The user specifies input entries, loading factors, and timing parameters	 * in this region of the netlist.	 */	private boolean parseFunction()	{		modPtr2.fanOut = 0;		Func funcHead = new Func();		modPtr2.ptr = funcHead;		funcHead.procPtr = null;		funcHead.inList = new ArrayList<ALSExport>();		funcHead.delta = 0;		funcHead.linear = 0;		funcHead.exp = 0;		funcHead.abs = 0;		funcHead.random = 0;		funcHead.userPtr = null;		for(;;)		{			String s1 = getAString();			if (s1 == null || s1.equals("GATE") || s1.equals("FUNCTION") || s1.equals("MODEL"))			{				--iPtr;				break;			}			if (s1.equals("I"))			{				parseFuncInput(funcHead);				continue;			}			if (s1.equals("O"))			{				if (parseFuncOutput()) return true;				continue;			}			if (s1.equals("T"))			{				if (parseTiming()) return true;				funcHead.delta = deltaDef;				funcHead.linear = linearDef;				funcHead.exp = expDef;				funcHead.abs = absDef;				funcHead.random = randomDef;				continue;			}			if (s1.equals("LOAD"))			{				if (parseLoad()) return true;				continue;			}			if (s1.equals("PRIORITY"))			{				Integer jj = getAnInt();				if (jj == null)				{					System.out.println("Priority declaration: EOF unexpectedly found");					return true;				}				modPtr2.priority = jj.intValue();				continue;			}			if (s1.equals("SET"))			{				ioPtr1 = modPtr2.setList;				parseNode();				continue;			}			System.out.println("ERROR: String '" + s1 + "' invalid function syntax");			return true;		}		return false;	}	/**	 * Method to create a list of input nodes which are used for event	 * driving the function.	 */	private void parseFuncInput(Func funcHead)	{		for(;;)		{			String s1 = getAName();			if (s1 == null || s1.equals("GATE") || s1.equals("FUNCTION") || s1.equals("MODEL") ||				s1.equals("I") || s1.equals("O") || s1.equals("T") || s1.equals("FANOUT") ||				s1.equals("LOAD") || s1.equals("PRIORITY") || s1.equals("SET"))			{				--iPtr;				break;			}			exPtr2 = new ALSExport();			exPtr2.nodePtr = null;			exPtr2.nodeName = s1;			funcHead.inList.add(exPtr2);		}	}	private Node dummyNode = new Node();	/**	 * Method to create a list of output nodes for the function.	 */	private boolean parseFuncOutput()	{		for(;;)		{			String s1 = getAName();			if (s1 == null || s1.equals("GATE") || s1.equals("FUNCTION") || s1.equals("MODEL") ||				s1.equals("I") || s1.equals("O") || s1.equals("T") || s1.equals("FANOUT") ||				s1.equals("LOAD") || s1.equals("PRIORITY") || s1.equals("SET"))			{				--iPtr;				break;			}			boolean found = false;			for(Iterator<ALSExport> it = modPtr2.exList.iterator(); it.hasNext(); )			{				exPtr2 = it.next();				if (s1.equals(exPtr2.nodeName))				{					exPtr2.nodePtr = dummyNode;					found = true;					break;				}			}			if (!found)			{				System.out.println("ERROR: Unable to find node " + s1 + " in port list");				return true;			}		}		return false;	}	/**	 * Method to get one string from the instruction buffer.	 * The procedure returns a null value if End Of File is encountered.	 */	private String getAString()	{		while (instPtr[iPtr] < 0 || instBuf[instPtr[iPtr]] == '#')		{			if (netlistStringPoint >= netlistStrings.length)			{				++iPtr;				return null;			}			String line = netlistStrings[netlistStringPoint++];			fragmentLine(line);			iPtr = 0;		}		StringBuffer sb = new StringBuffer();		for(int i=instPtr[iPtr]; instBuf[i] != 0; i++)			sb.append(instBuf[i]);		++iPtr;		return sb.toString();	}	/**	 * Method to read in the required number of strings to compose an	 * integer value.  It is possible to have a leading +/- sign before the actual	 * integer value.	 */	private Integer getAnInt()	{		String s1 = getAString();		if (s1 == null) return null;		if (s1.startsWith("+") || s1.startsWith("-"))		{			String s2 = getAString();			if (s2 == null) return null;			s1 += s2;		}		return new Integer(TextUtils.atoi(s1));	}	/**	 * Method to reads in the required number of strings to compose a	 * float value.  It is possible to have a leading +/- sign before the actual	 * float value combined with the chance that the number is entered in scientific	 * notation.	 */	private Double getADouble()	{		String s1 = getAString();		if (s1 == null) return null;		if (s1.startsWith("+") || s1.startsWith("-"))		{			String s2 = getAString();			if (s2 == null) return null;			s1 += s2;		}		if (!s1.endsWith("E"))		{			return new Double(TextUtils.atof(s1));		}		String s2 = getAString();		if (s2 == null) return null;		s1 += s2;		if (s2.startsWith("+") || s2.startsWith("-"))		{			String s3 = getAString();			if (s3 == null) return null;			s1 += s3;		}		return new Double(TextUtils.atof(s1));	}	/**	 * Method to read in the required number of strings to compose a	 * model/node name for the element. If array subscripting is used, the	 * brackets and argument string is spliced to the node name.	 */	private String getAName()	{		String s1 = getAString();		if (s1 == null) return null;		String s2 = getAString();		if (s2 == null || !s2.startsWith("["))		{			--iPtr;			return s1;		}		s1 = s2;		for(;;)		{			s2 = getAString();			if (s2 == null) return null;			s1 = s2;			if (s2.startsWith("]")) break;		}		return s1;	}	/**	 * Method to process the string specified by the calling argument	 * and fragments it into a series of smaller character strings, each of which	 * is terminated by a null character.	 */	private void fragmentLine(String line)	{		int j = 0, count = 0;		instPtr[0] = 0;		int k = 1;		for (int i = 0; ; ++i)		{			if (j > iBufSize - 3)			{				int newSize = iBufSize * 5;				char [] newBuf = new char[newSize];				for(int x=0; x<iBufSize; x++) newBuf[x] = instBuf[x];				instBuf = newBuf;				iBufSize = newSize;			}			if (k > iPtrSize - 2)			{				int newSize = iPtrSize * 5;				int [] newBuf = new int[newSize];				for(int x=0; x<iPtrSize; x++) newBuf[x] = instPtr[x];				instPtr = newBuf;				iPtrSize = newSize;			}			if (i >= line.length())			{				if (count != 0)				{					instBuf[j] = 0;					instPtr[k] = -1;				} else				{					instPtr[k-1] = -1;				}				break;			}			char chr = line.charAt(i);			switch (chr)			{				case ' ':				case ',':				case '\t':				case ':':					if (count != 0)					{						instBuf[j] = 0;						instPtr[k] = j+1;						++j;						++k;						count = 0;					}					break;				case '(':				case ')':				case '{':				case '}':				case '[':				case ']':				case '=':				case '!':				case '>':				case '<':				case '+':				case '-':				case '*':				case '/':				case '%':				case '@':				case ';':				case '#':					if (count != 0)					{						instBuf[j] = 0;						instBuf[j+1] = chr;						instBuf[j+2] = 0;						instPtr[k] = j+1;						instPtr[k+1] = j+3;						j += 3;						k += 2;						count = 0;					} else					{						instBuf[j] = chr;						instBuf[j+1] = 0;						instPtr[k] = j+2;						j += 2;						++k;					}					break;				default:					instBuf[j] = Character.toUpperCase(chr);					++j;					++count;			}		}	}}

⌨️ 快捷键说明

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