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

📄 jelib.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: JELIB.java * Input/output tool: JELIB Library input * Written by Steven M. Rubin, Sun Microsystems. * * Copyright (c) 2004 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.io.input;import com.sun.electric.database.geometry.EPoint;import com.sun.electric.database.hierarchy.Cell;import com.sun.electric.database.hierarchy.Export;import com.sun.electric.database.hierarchy.Library;import com.sun.electric.database.id.ArcProtoId;import com.sun.electric.database.id.CellId;import com.sun.electric.database.id.IdManager;import com.sun.electric.database.id.LibId;import com.sun.electric.database.id.NodeProtoId;import com.sun.electric.database.id.PrimitiveNodeId;import com.sun.electric.database.id.TechId;import com.sun.electric.database.prototype.NodeProto;import com.sun.electric.database.prototype.PortProto;import com.sun.electric.database.text.CellName;import com.sun.electric.database.text.Setting;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.Geometric;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.topology.PortInst;import com.sun.electric.database.variable.Variable;import com.sun.electric.technology.ArcProto;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.TechPool;import com.sun.electric.technology.Technology;import com.sun.electric.technology.technologies.Generic;import com.sun.electric.tool.Tool;import com.sun.electric.tool.io.FileType;import com.sun.electric.tool.user.ErrorLogger;import java.awt.geom.Point2D;import java.awt.geom.Rectangle2D;import java.io.IOException;import java.net.URL;import java.util.*;/** * This class reads files in new library file (.jelib) format. */public class JELIB extends LibraryFiles{    private final FileType fileType;    private final JelibParser parser;	JELIB(LibId libId, URL fileURL, FileType fileType) throws IOException	{        this.fileType = fileType;        parser = JelibParser.parse(libId, fileURL, fileType, false, Input.errorLogger);	}    public static Map<Setting,Object> readProjectSettings(URL fileURL, FileType fileType, TechPool techPool, ErrorLogger errorLogger) {        JelibParser parser;        try {            parser = parse(techPool.idManager, fileURL, fileType, true, errorLogger);        } catch (IOException e) {            errorLogger.logError("Error reading " + fileURL + ": " + e.getMessage(), -1);            return null;        }        HashMap<Setting,Object> projectSettings = new HashMap<Setting,Object>();        for (Map.Entry<TechId,Variable[]> e: parser.techIds.entrySet()) {            TechId techId = e.getKey();            Variable[] vars = e.getValue();            Technology tech = techPool.getTech(techId);            if (tech == null && techId.techName.equals("tsmc90"))                tech = techPool.getTech(techPool.idManager.newTechId("cmos90"));            if (tech == null) {                Input.errorLogger.logError(fileURL +                    ", Cannot identify technology " + techId.techName, -1);                continue;            }            realizeMeaningPrefs(projectSettings, tech, vars);        }        for (Map.Entry<String,Variable[]> e: parser.tools.entrySet()) {            String toolName = e.getKey();            Variable[] vars = e.getValue();			Tool tool = Tool.findTool(toolName);			if (tool == null) {				Input.errorLogger.logError(fileURL +                    ", Cannot identify tool " + toolName, -1);				continue;			}            realizeMeaningPrefs(projectSettings, tool, vars);        }        return projectSettings;    }    public static JelibParser parse(IdManager idManager, URL fileURL, FileType fileType, boolean onlyProjectSettings, ErrorLogger errorLogger) throws IOException {        LibId libId = idManager.newLibId(TextUtils.getFileNameWithoutExtension(fileURL));        return JelibParser.parse(libId, fileURL, fileType, onlyProjectSettings, errorLogger);    }	/**	 * Method to read a Library in new library file (.jelib) format.	 * @return true on error.	 */    @Override    boolean readTheLibrary(boolean onlyProjectSettings, LibraryStatistics.FileContents fc) {        return false;    }    @Override    Map<Cell,Variable[]> createLibraryCells(boolean onlyProjectSettings) {        lib.erase();        realizeVariables(lib, parser.libVars);        lib.setVersion(parser.version);        // Project settings        for (Map.Entry<TechId,Variable[]> e: parser.techIds.entrySet()) {            TechId techId = e.getKey();            Variable[] vars = e.getValue();            Technology tech = findTechnology(techId);            if (tech == null) {                Input.errorLogger.logError(filePath +                    ", Cannot identify technology " + techId.techName, -1);                continue;            }            realizeMeaningPrefs(tech, vars);        }        for (Map.Entry<String,Variable[]> e: parser.tools.entrySet()) {            String toolName = e.getKey();            Variable[] vars = e.getValue();			Tool tool = Tool.findTool(toolName);			if (tool == null) {				Input.errorLogger.logError(parser.fileURL +                    ", Cannot identify tool " + toolName, -1);				continue;			}            realizeMeaningPrefs(tool, vars);        }        for (Map.Entry<LibId,String> e: parser.externalLibIds.entrySet()) {            LibId libId = e.getKey();            String libFileName = e.getValue();            if (Library.findLibrary(libId.libName) == null)                readExternalLibraryFromFilename(libFileName, fileType);        }        nodeProtoCount = parser.allCells.size();        nodeProtoList = new Cell[nodeProtoCount];        cellLambda = new double[nodeProtoCount];        HashMap<Cell,Variable[]> originalVars = new HashMap<Cell,Variable[]>();        HashMap<CellName,Cell> cellGroupExamples = new HashMap<CellName,Cell>();        int cellNum = 0;        for (JelibParser.CellContents cc: parser.allCells.values()) {            CellId cellId = cc.cellId;            Cell cell = Cell.newInstance(lib, cellId.cellName.toString());            Technology tech = findTechnology(cc.techId);            cell.setTechnology(tech);            cell.lowLevelSetCreationDate(new Date(cc.creationDate));            cell.lowLevelSetRevisionDate(new Date(cc.revisionDate));            if (cc.expanded) cell.setWantExpanded();            if (cc.allLocked) cell.setAllLocked();            if (cc.instLocked) cell.setInstancesLocked();            if (cc.cellLib) cell.setInCellLibrary();            if (cc.techLib) cell.setInTechnologyLibrary();            originalVars.put(cell, cc.vars);            nodeProtoList[cellNum++] = cell;            Cell otherCell = cellGroupExamples.get(cc.groupName);            if (otherCell == null)                cellGroupExamples.put(cc.groupName, cell);            else                cell.joinGroup(otherCell);        }        lib.setFromDisk();        lib.setDelibCellFiles(parser.delibCellFiles);        return originalVars;	}    @Override    Variable[] findVarsOnExampleIcon(Cell parentCell, Cell iconCell) {        JelibParser.CellContents cc = parser.allCells.get(parentCell.getId());        if (cc == null) return null;        for (JelibParser.NodeContents nc: cc.nodes) {            if (nc.protoId == iconCell.getId())                return nc.vars;        }        return null;    }    	/**	 * Method to recursively create the contents of each cell in the library.	 */    @Override	protected void realizeCellsRecursively(Cell cell, HashSet<Cell> recursiveSetupFlag, String scaledCellName, double scale)	{		if (scaledCellName != null) return;		JelibParser.CellContents cc = parser.allCells.get(cell.getId());		if (cc == null || cc.filledIn) return;		instantiateCellContent(cell, cc, recursiveSetupFlag);		cellsConstructed++;        setProgressValue(cellsConstructed * 100 / totalCells);		recursiveSetupFlag.add(cell);        cell.loadExpandStatus();	}	/**	 * Method called after all libraries have been read to instantiate a single Cell.	 * @param cell the Cell to instantiate.	 * @param cc the contents of that cell (the strings from the file).	 */	private void instantiateCellContent(Cell cell, JelibParser.CellContents cc, HashSet<Cell> recursiveSetupFlag)	{        HashMap<Technology,Technology.SizeCorrector> sizeCorrectors = new HashMap<Technology,Technology.SizeCorrector>();		// place all nodes        for (JelibParser.NodeContents n: cc.nodes) {            int line = n.line;			String prefixName = lib.getName();			NodeProto np = null;            NodeProtoId protoId = n.protoId;            if (protoId instanceof CellId)                np = database.getCell((CellId)protoId);            else {                PrimitiveNodeId pnId = (PrimitiveNodeId)protoId;                np = findPrimitiveNode(pnId);                if (np == null) {					Input.errorLogger.logError(cc.fileName + ", line " + line +						", Cannot find primitive node " + pnId, cell, -1);                    Set<PrimitiveNodeId> primSet = undefinedTechsAndPrimitives.get(pnId.techId);                    if (primSet == null)                    {                        primSet = new HashSet<PrimitiveNodeId>();                        undefinedTechsAndPrimitives.put(pnId.techId, primSet);                    }                    primSet.add(pnId);                    CellName cellName = CellName.parseName(pnId.name);                    if (cellName.getVersion() <= 0)                        cellName = CellName.newName(cellName.getName(), cellName.getView(), 1);                    protoId = lib.getId().newCellId(cellName);                }            }			// make sure the subcell has been instantiated			if (np != null && np instanceof Cell)			{				Cell subCell = (Cell)np;				// subcell: make sure that cell is setup				if (!recursiveSetupFlag.contains(subCell))				{					LibraryFiles reader = this;					if (subCell.getLibrary() != cell.getLibrary())						reader = getReaderForLib(subCell.getLibrary());					// subcell: make sure that cell is setup

⌨️ 快捷键说明

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