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

📄 edif.java

📁 The ElectricTM VLSI Design System is an open-source Electronic Design Automation (EDA) system that c
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
		return curLibrary;	}	/**	 * Method to load the edif netlist into memory	 * Does a simple keyword lookup to load the lisp structured	 * EDIF language into Electric's database	 */	private void loadEDIF()		throws IOException	{		int saveStack = -1;		// now read and parse the edif netlist		for(;;)		{			String token = getKeyword();			if (token == null) break;			// locate the keyword			EDIFKEY key = edifKeys.get(TextUtils.canonicString(token));			if (key == null)			{				System.out.println("Warning, line " + lineReader.getLineNumber() + ": unknown keyword <" + token + ">");				warningCount++;				keyStack[keyStackDepth++] = curKeyword;				curKeyword = KUNKNOWN;				continue;			}			// found the keyword, check state			if (key.stateArray != null && curKeyword != KUNKNOWN)			{				boolean found = false;				for(int i=0; i<key.stateArray.length; i++)					if (key.stateArray[i] == curKeyword) { found = true;   break; }				if (!found)				{					System.out.println("Error, line " + lineReader.getLineNumber() + ": illegal state (" + curKeyword.name + ") for keyword <" + token + ">");					errorCount++;				}			}			// call the function			keyStack[keyStackDepth++] = curKeyword;			curKeyword = key;			if (saveStack >= keyStackDepth)			{				saveStack = -1;				ignoreBlock = false;			}			if (!ignoreBlock)			{				key.push();				if (ignoreHigherBlock)				{					ignoreHigherBlock = false;					ignoreBlock = true;					saveStack = keyStackDepth-1;				}			}			if (ignoreBlock)			{				if (saveStack == -1) saveStack = keyStackDepth;			}		}		if (curKeyword != KINIT)		{			System.out.println("Error, line " + lineReader.getLineNumber() + ": unexpected end-of-file encountered");			errorCount++;		}		cleanupAtEnd();	}	/**	 * Method to get a keyword.	 */	private String getKeyword()		throws IOException	{		// look for a '(' before the edif keyword		for(;;)		{			String p = getToken((char)0);			if (p == null) break;			if (p.equals("(")) break;			if (p.equals(")"))			{				// pop the keyword state stack, called when ')' is encountered.				if (keyStackDepth != 0)				{					if (!ignoreBlock)					{						curKeyword.pop();					}					if (keyStackDepth != 0) curKeyword = keyStack[--keyStackDepth]; else						curKeyword = KINIT;				}			} else			{//				if (TextUtils.isANumber(inputBuffer)) processInteger(TextUtils.atoi(inputBuffer));				if (TextUtils.isANumber(p)) processInteger(TextUtils.atoi(p));			}		}		return getToken((char)0);	}	private void cleanupAtEnd()	{		// clean-up schematic cells with isolated pins		for(Cell cell : builtCells)		{			if (cell.isSchematic())			{				List<NodeInst> deletePins = new ArrayList<NodeInst>();				for(Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); )				{					NodeInst ni = it.next();					if (ni.getProto() == Schematics.tech().wirePinNode)					{						if (!ni.hasConnections() && !ni.hasExports())							deletePins.add(ni);					}				}				for(NodeInst ni : deletePins)				{					ni.kill();				}			}		}		// put names on named arcs		for(Cell cell : namedArcs.keySet())		{			Netlist nl = cell.acquireUserNetlist();			Map<String,List<ArcInst>> arcsInCell = namedArcs.get(cell);			Map<ArcInst,String> arcsToName = new HashMap<ArcInst,String>();			for(String name : arcsInCell.keySet())			{				List<ArcInst> arcsWithName = arcsInCell.get(name);				Collections.sort(arcsWithName, new ArcsByLength());				Set<Network> netsNamed = new HashSet<Network>();				for(int i=0; i<arcsWithName.size(); i++)				{					ArcInst ai = arcsWithName.get(i);					if (!ai.isLinked()) continue;					Network net = nl.getNetwork(ai, 0);					if (netsNamed.contains(net)) continue;					netsNamed.add(net);					arcsToName.put(ai, name);				}			}			for(ArcInst ai : arcsToName.keySet())			{				String arcName = arcsToName.get(ai);				if (ai.getName().equals(arcName)) continue;				if (ai.getNameKey().isTempname())				{					ai.setName(arcName);				} else				{					// two names on one arc: duplicate the arc					ArcInst second = ArcInst.newInstanceBase(ai.getProto(), ai.getLambdaBaseWidth(),						ai.getHeadPortInst(), ai.getTailPortInst(), ai.getHeadLocation(), ai.getTailLocation(),						arcName, ai.getAngle(), ai.getD().flags);					TextDescriptor td = TextDescriptor.getArcTextDescriptor().withOff(0, -1);					second.setTextDescriptor(ArcInst.ARC_NAME, td);				}			}		}	}	/**	 * Comparator class for sorting ArcInst by their length.	 */	private static class ArcsByLength implements Comparator<ArcInst>	{		/**		 * Method to sort ArcInst by their length.		 */		public int compare(ArcInst a1, ArcInst a2)		{			double len1 = a1.getHeadLocation().distance(a1.getTailLocation());			double len2 = a2.getHeadLocation().distance(a2.getTailLocation());			if (len1 == len2) return 0;			if (len1 < len2) return 1;			return -1;		}	}	/**	 * Method to do cleanup processing of an integer argument such as in (array (...) 1 2)	 */	private void processInteger(int value)	{		if (keyStackDepth > 0)		{			if (!ignoreBlock)			{				if (curKeyword == KARRAY)				{					if (arrayXVal == 0) arrayXVal = value;						else if (arrayYVal == 0) arrayYVal = value;				} else if (curKeyword == KMEMBER)				{					if (memberXVal == -1) memberXVal = value;						else if (memberYVal == -1) memberYVal = value;				}			}		}	}	/**************************************** SUPPORT ****************************************/	/**	 * Method to position to the next token	 * @return true on EOF.	 */	private boolean positionToNextToken()		throws IOException	{		for(;;)		{			if (inputBuffer == null) return true;			if (inputBufferPos >= inputBuffer.length())			{				inputBuffer = readWholeLine();				if (inputBuffer == null) return true;				inputBufferPos = 0;				continue;			}			char chr = inputBuffer.charAt(inputBufferPos);			if (chr == ' ' || chr == '\t')			{				inputBufferPos++;				continue;			}			return false;		}	}	/**	 * Method to get a delimeter routine	 */	private void getDelimeter(char delim)		throws IOException	{		if (positionToNextToken())		{			throw new IOException("Unexpected end-of-file");		}		char chr = inputBuffer.charAt(inputBufferPos);		if (chr != delim)		{			throw new IOException("Illegal delimeter");		}		inputBufferPos++;	}	/**	 * Method to get a token	 */	private String getToken(char iDelim)		throws IOException	{		// locate the first non-white space character for non-delimited searches		char delim = iDelim;		if (delim == 0)		{			if (positionToNextToken()) return null;		}		// set up the string copy		StringBuffer sBuf = new StringBuffer();		char chr = inputBuffer.charAt(inputBufferPos);		if (delim == 0 && chr == '"')		{			// string search			delim = '"';			sBuf.append(chr);			inputBufferPos++;		}		// now locate the next white space or the delimiter		for(;;)		{			if (inputBufferPos >= inputBuffer.length())			{				// end of string, get the next line				inputBuffer = readWholeLine();				if (inputBuffer == null)				{					// end-of-file, if no delimiter return NULL, otherwise the string					if (delim != 0) break;					return sBuf.toString();				}				inputBufferPos = 0;			} else if (delim == 0)			{				chr = inputBuffer.charAt(inputBufferPos);				switch (chr)				{					case ' ':					case '\t':						// skip to the next character						inputBufferPos++;						return sBuf.toString();						// special EDIF delimiters					case '(':					case ')':						if (sBuf.length() == 0)						{							sBuf.append(chr);							inputBufferPos++;						}						return sBuf.toString();					default:						sBuf.append(chr);						inputBufferPos++;						break;				}			} else			{				// check for user specified delimiter				chr = inputBuffer.charAt(inputBufferPos);				if (chr == delim)				{					// skip the delimiter, unless string					if (delim != iDelim) sBuf.append(chr);					inputBufferPos++;					return sBuf.toString();				}				sBuf.append(chr);				inputBufferPos++;			}		}		return null;	}	private void makeFigure()		throws IOException	{		// get the layer name; check for figuregroup override		if (positionToNextToken()) return;		if (inputBuffer.charAt(inputBufferPos) == '(') return;		String layer = getToken((char)0);		// now look for this layer in the list of layers		for(NameEntry nt : nameEntryList)		{			if (nt.original.equalsIgnoreCase(layer))			{				// found the layer				curFigureGroup = nt.node;				textHeight = nt.textHeight;				textJustification = nt.justification;				textVisible = nt.visible;				// allow new definitions				curNameEntry = nt;				return;			}		}		NameEntry nt = new NameEntry();		nameEntryList.add(nt);		nt.original = layer;		nt.replace = nt.original;		curFigureGroup = nt.node = Artwork.tech().boxNode;		textHeight = nt.textHeight = 0;		textJustification = nt.justification = TextDescriptor.Position.DOWNRIGHT;		textVisible = nt.visible = true;		// allow new definitions		curNameEntry = nt;	}	/**	 * Method to determine whether a name has multiple signals in it.	 * @param name the name to check.	 * @return true if it is a bus name.	 */	private boolean isBusName(String name)	{		if (name == null || name.length() <= 0) return false;		Name nn = Name.findName(name);		if (nn == null) return false;		return nn.isBus();	}	private boolean checkName()		throws IOException	{		positionToNextToken();		char chr = inputBuffer.charAt(inputBufferPos);		if (chr != '(' && chr != ')')		{			String aName = getToken((char)0);			objectName = fixLeadingAmpersand(aName);			return true;		}		return false;	}	private void freePointList()	{		curPoints = new ArrayList<Point2D>();	}	private void freeSavedPointList()	{		saveTextPoints = new ArrayList<Point2D>();	}	private double getNumber()		throws IOException	{		String value = getToken((char)0);		if (value == null) throw new IOException("No integer value");		if (value.startsWith("("))		{			// must be in e notation

⌨️ 快捷键说明

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