📄 readabledump.java
字号:
/* -*- tab-width: 4 -*- * * Electric(tm) VLSI Design System * * File: ReadableDump.java * Input/output tool: "Readable Dump" Library input * Written by Steven M. Rubin, Sun Microsystems. * * Copyright (c) 2003 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.ImmutableArcInst;import com.sun.electric.database.ImmutableExport;import com.sun.electric.database.geometry.EPoint;import com.sun.electric.database.geometry.Poly;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.hierarchy.View;import com.sun.electric.database.id.ArcProtoId;import com.sun.electric.database.id.CellId;import com.sun.electric.database.id.ExportId;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.technology.ArcProto;import com.sun.electric.database.prototype.NodeProto;import com.sun.electric.database.prototype.PortCharacteristic;import com.sun.electric.database.prototype.PortProto;import com.sun.electric.database.text.CellName;import com.sun.electric.database.text.Name;import com.sun.electric.database.text.TextUtils;import com.sun.electric.database.text.Version;import com.sun.electric.database.topology.ArcInst;import com.sun.electric.database.topology.NodeInst;import com.sun.electric.database.topology.PortInst;import com.sun.electric.database.variable.CodeExpression;import com.sun.electric.database.variable.TextDescriptor;import com.sun.electric.database.variable.Variable;import com.sun.electric.technology.PrimitiveNode;import com.sun.electric.technology.Technology;import com.sun.electric.technology.technologies.Artwork;import com.sun.electric.technology.technologies.Generic;import com.sun.electric.tool.Tool;import com.sun.electric.tool.io.ELIBConstants;import com.sun.electric.tool.io.FileType;import java.awt.geom.Point2D;import java.io.File;import java.io.IOException;import java.util.ArrayList;import java.util.HashMap;import java.util.HashSet;import java.util.Map;import java.util.Set;import java.util.TreeSet;/** * This class reads files in readable-dump (.txt) format. */public class ReadableDump extends LibraryFiles{ // ------------------------- private data ---------------------------- private static class ArcInstList { private ArcInst [] arcList; private String [] arcProtoName; private ArcProto [] arcProto; private String [] arcInstName; private TextDescriptor[] arcNameDescriptor; private int [] arcWidth; private int [] arcHeadNode; private String [] arcHeadPort; private int [] arcHeadX; private int [] arcHeadY; private int [] arcTailNode; private String [] arcTailPort; private int [] arcTailX; private int [] arcTailY; private int [] arcUserBits; private Variable[][] arcVars; }; private static class ExportList { private Export [] exportList; private String [] exportName; private TextDescriptor[] exportNameDescriptor; private int [] exportSubNode; private String [] exportSubPort; private int [] exportUserBits; private Variable[][] exportVars; };// /** The current position in the file. */ private int filePosition; /** The state of reading the file. */ private int textLevel; /** A counter for reading multiple Tools, Technologies, etc. */ private int bitCount;// /** The current Cell in the Library. */ private int mainCell; /** The current ArcInst end being processed. */ private int curArcEnd; /** The current object type being processed. */ private int varPos; /** The index of the current Cell being processed. */ private int curCellNumber; /** The index of the current NodeInst being processed. */ private int curNodeInstIndex; /** The index of the current ArcInst being processed. */ private int curArcInstIndex; /** The index of the current Export being processed. */ private int curExportIndex; /** Offset values for cells being read. */ private double [] nodeProtoOffX, nodeProtoOffY; /** Proto strings for NodeInsts in each Cell. */ private String [][] nodeProtoTypeList; /** All data for NodeInsts in each Cell. */ private LibraryFiles.NodeInstList[] nodeInstList; /** All data for ArcInsts in each Cell. */ private ArcInstList[] arcInstList; /** All data for Exports in each Cell. */ private ExportList [] exportList; /** The maximum characters in a keyword. */ private int keywordArrayLen; /** An array of keyword data. */ private char [] keywordArray = null; /** The current keyword from the file. */ private String keyWord; /** Flags on the Library */ private int libBits; /** Variables on the Library */ private Variable[] libVars; /** All Tools found in the file. */ private Tool [] toolList; /** The current Tool being processed. */ private Tool curTool; /** All Technologies found in the file. */ private Technology [] techList; /** The current Technology being processed. */ private Technology curTech; /** The values of Lambda for each Technology. */ private int [] lambdaValues; /** The group numbers of the Cells being processed. */ private int [] cellGroups; /** The CellNames of the Cells being processed. */ private CellName [] cellNames; /** The creation dates of Cells being processed. */ private int [] cellCreationDates; /** The revision dates of the Cells being processed. */ private int [] cellRevisionDates; /** The technologies of the Cells being processed. */ private String [] cellTechNames; /** The userbits of the Cells being processed. */ private int [] cellUserbits; /** The variables of the Cells being processed. */ private Variable [][] cellVars; /** The low X bounds of the Cells being processed. */ private int [] cellLowX; /** The high X bounds of the Cells being processed. */ private int [] cellHighX; /** The low Y bounds of the Cells being processed. */ private int [] cellLowY; /** The high Y bounds of the Cells being processed. */ private int [] cellHighY; /** Library paths of the external Cells being processed. */ private String [] cellLibPaths; /** cells being processed from this or external libraries. */ private Cell [] allCellsArray; // state of input (value of "textLevel") /** Currently reading Library information. */ private static final int INLIB = 1; /** Currently reading Cell information. */ private static final int INCELL = 2; /** Currently reading Export information. */ private static final int INPORTPROTO = 3; /** Currently reading NodeInst information. */ private static final int INNODEINST = 4; /** Currently reading PortInst information. */ private static final int INPOR = 5; /** Currently reading ArcInst information. */ private static final int INARCINST = 6; /** Currently reading ArcInst end information. */ private static final int INARCEND = 7; // state of variable reading (value of "varPos") /** Currently reading a Tool. */ private static final int INVTOOL = 1; /** Currently reading a Technology. */ private static final int INVTECHNOLOGY = 2; /** Currently reading a Library. */ private static final int INVLIBRARY = 3; /** Currently reading a Cell. */ private static final int INVNODEPROTO = 4; /** Currently reading a NodeInst. */ private static final int INVNODEINST = 5; /** Currently reading a Export. */ private static final int INVPORTPROTO = 6; /** Currently reading a ArcInst. */ private static final int INVARCINST = 7; ReadableDump() { } // ----------------------- public methods ------------------------------- @Override protected boolean readProjectSettings() { try { textLevel = INLIB; for(;;) { // get keyword from file if (getKeyword()) break; String thisKey = keyWord; // get argument to keyword if (getKeyword()) break; // determine which keyword table to use if (textLevel != INLIB || varPos != 0 && varPos != INVTOOL && varPos != INVTECHNOLOGY) break; if (thisKey.equals("****library:")) { keywordNewLib(); continue; } if (thisKey.equals("lambda:")) { keywordLambda(); continue; } if (thisKey.equals("version:")) { keywordVersn(); continue; } if (thisKey.equals("aids:")) { keywordLibKno(); continue; } if (thisKey.equals("aidname:")) { keywordLibAiN(); continue; } if (thisKey.equals("aidbits:")) { keywordLibAiB(); continue; } if (thisKey.equals("techcount:")) { keywordLibTe(); continue; } if (thisKey.equals("techname:")) { keywordLibTeN(); continue; } if (thisKey.equals("cellcount:")) { keywordLibCC(); continue; } if (thisKey.equals("variables:")) { keywordGetVar(); continue; } } return false; } catch (IOException e) { System.out.println("End of file reached while reading " + filePath); return true; } } /** * Method to read the .elib file. * Returns true on error. */ @Override boolean readTheLibrary(boolean onlyProjectSettings, LibraryStatistics.FileContents fc) throws IOException { textLevel = INLIB;// filePosition = 0; for(;;) { // get keyword from file if (getKeyword()) break; String thisKey = keyWord; // get argument to keyword if (getKeyword()) break; // determine which keyword table to use switch (textLevel) { case INLIB: if (thisKey.equals("****library:")) { keywordNewLib(); break; } if (thisKey.equals("bits:")) { keywordLibBit(); break; } if (thisKey.equals("lambda:")) { keywordLambda(); break; } if (thisKey.equals("version:")) { keywordVersn(); break; } if (thisKey.equals("aids:")) { keywordLibKno(); break; } if (thisKey.equals("aidname:")) { keywordLibAiN(); break; } if (thisKey.equals("aidbits:")) { keywordLibAiB(); break; } if (thisKey.equals("userbits:")) { keywordLibUsb(); break; } if (thisKey.equals("techcount:")) { keywordLibTe(); break; } if (thisKey.equals("techname:")) { keywordLibTeN(); break; } if (thisKey.equals("cellcount:")) { keywordLibCC(); break; } if (thisKey.equals("maincell:")) { keywordLibMS(); break; } if (thisKey.equals("view:")) { keywordLibVie(); break; } if (thisKey.equals("***cell:")) { keywordNewCel(); break; } if (thisKey.equals("variables:")) { keywordGetVar(); break; } break; case INCELL: if (thisKey.equals("bits:")) { keywordCelBit(); break; } if (thisKey.equals("userbits:")) { keywordCelUsb(); break; } if (thisKey.equals("name:")) { keywordCelNam(); break; } if (thisKey.equals("version:")) { keywordCelVer(); break; } if (thisKey.equals("creationdate:")) { keywordCelCre(); break; } if (thisKey.equals("revisiondate:")) { keywordCelRev(); break; } if (thisKey.equals("externallibrary:")) { keywordCelExt(); break; } if (thisKey.equals("lowx:")) { keywordCelLX(); break; } if (thisKey.equals("highx:")) { keywordCelHX(); break; } if (thisKey.equals("lowy:")) { keywordCelLY(); break; } if (thisKey.equals("highy:")) { keywordCelHY(); break; } if (thisKey.equals("nodes:")) { keywordCelNoC(); break; } if (thisKey.equals("arcs:")) { keywordCelArC(); break; } if (thisKey.equals("porttypes:")) { keywordCelPtC(); break; } if (thisKey.equals("technology:")) { keywordTech(); break; } if (thisKey.equals("**node:")) { keywordNewNo(); break; } if (thisKey.equals("**arc:")) { keywordNewAr(); break; } if (thisKey.equals("***cell:")) { keywordNewCel(); break; } if (thisKey.equals("variables:")) { keywordGetVar(); break; } break; case INPORTPROTO: if (thisKey.equals("bits:")) { keywordPtBit(); break; } if (thisKey.equals("userbits:")) { keywordPtUsb(); break; } if (thisKey.equals("subnode:")) { keywordPtSNo(); break; } if (thisKey.equals("subport:")) { keywordPtSPt(); break; } if (thisKey.equals("name:")) { keywordPtNam(); break; } if (thisKey.equals("descript:")) { keywordPtDes(); break; } if (thisKey.equals("aseen:")) { keywordPtKse(); break; } if (thisKey.equals("**porttype:")) { keywordNewPt(); break; } if (thisKey.equals("**arc:")) { keywordNewAr(); break; } if (thisKey.equals("**node:")) { keywordNewNo(); break; } if (thisKey.equals("***cell:")) { keywordNewCel(); break; } if (thisKey.equals("variables:")) { keywordGetVar(); break; } break; case INNODEINST: if (thisKey.equals("bits:")) { keywordNodBit(); break; } if (thisKey.equals("userbits:")) { keywordNodUsb(); break; } if (thisKey.equals("type:")) { keywordNodTyp(); break; } if (thisKey.equals("lowx:")) { keywordNodLX(); break; } if (thisKey.equals("highx:")) { keywordNodHX(); break; } if (thisKey.equals("lowy:")) { keywordNodLY(); break; } if (thisKey.equals("highy:")) { keywordNodHY(); break; } if (thisKey.equals("rotation:")) { keywordNodRot(); break; } if (thisKey.equals("transpose:")) { keywordNodTra(); break; } if (thisKey.equals("aseen:")) { keywordNodKse(); break; } if (thisKey.equals("name:")) { keywordNodNam(); break; } if (thisKey.equals("descript:")) { keywordNodDes(); break; } if (thisKey.equals("*port:")) { keywordNewPor(); break; } if (thisKey.equals("**node:")) { keywordNewNo(); break; } if (thisKey.equals("**porttype:")) { keywordNewPt(); break; } if (thisKey.equals("**arc:")) { keywordNewAr(); break; } if (thisKey.equals("variables:")) { keywordGetVar(); break; } if (thisKey.equals("***cell:")) { keywordNewCel(); break; } if (thisKey.equals("ports:")) { keywordNodPoC(); break; } break; case INPOR: if (thisKey.equals("*port:")) { keywordNewPor(); break; } if (thisKey.equals("**node:")) { keywordNewNo(); break; } if (thisKey.equals("**porttype:")) { keywordNewPt(); break; } if (thisKey.equals("**arc:")) { keywordNewAr(); break; } if (thisKey.equals("variables:")) { keywordGetVar(); break; } if (thisKey.equals("***cell:")) { keywordNewCel(); break; } break; case INARCINST: if (thisKey.equals("bits:")) { keywordArcBit(); break; } if (thisKey.equals("userbits:")) { keywordArcUsb(); break; } if (thisKey.equals("type:")) { keywordArcTyp(); break; } if (thisKey.equals("width:")) { keywordArcWid(); break; } if (thisKey.equals("aseen:")) { keywordArcKse(); break; } if (thisKey.equals("name:")) { keywordArcNam(); break; } if (thisKey.equals("*end:")) { keywordNewEnd(); break; } if (thisKey.equals("**arc:")) { keywordNewAr(); break; } if (thisKey.equals("**node:")) { keywordNewNo(); break; } if (thisKey.equals("variables:")) { keywordGetVar(); break; } if (thisKey.equals("***cell:")) { keywordNewCel(); break; } break; case INARCEND: if (thisKey.equals("node:")) { keywordEndNod(); break; } if (thisKey.equals("nodeport:")) { keywordEndPt(); break; } if (thisKey.equals("xpos:")) { keywordEndXP(); break; } if (thisKey.equals("ypos:")) { keywordEndYP(); break; } if (thisKey.equals("*end:")) { keywordNewEnd(); break; } if (thisKey.equals("**arc:")) { keywordNewAr(); break; } if (thisKey.equals("**node:")) { keywordNewNo(); break; } if (thisKey.equals("variables:")) { keywordGetVar(); break; } if (thisKey.equals("***cell:")) { keywordNewCel(); break; } break; } } // see if cellgroup information was included// for(np = lib->firstnodeproto; np != NONODEPROTO; np = np->nextnodeproto)// if (np->temp1 == -1) break;// if (np != NONODEPROTO)// {// // missing cellgroup information, construct it from names// if (emajor > 7 ||// (emajor == 7 && eminor > 0) ||// (emajor == 7 && eminor == 0 && edetail > 11))// {// ttyputmsg(M_("Unusual! Version %s library has no cellgroup information"), version);// }// buildcellgrouppointersfromnames(lib);// } else if (lib->firstnodeproto != NONODEPROTO)// {// // convert numbers to cellgroup pointers// if (emajor < 7 ||// (emajor == 7 && eminor == 0 && edetail <= 11))// {// ttyputmsg(M_("Unusual! Version %s library has cellgroup information"), version);// }// for(np = lib->firstnodeproto; np != NONODEPROTO; np = np->nextnodeproto)// np->nextcellgrp = NONODEPROTO;// for(np = lib->firstnodeproto; np != NONODEPROTO; np = np->nextnodeproto)// {// if (np->nextcellgrp != NONODEPROTO) continue;// prevmatch = np;// for(onp = np->nextnodeproto; onp != NONODEPROTO; onp = onp->nextnodeproto)// {// if (onp->temp1 != prevmatch->temp1) continue;// prevmatch->nextcellgrp = onp;// prevmatch = onp;// }// prevmatch->nextcellgrp = np;// }// } if (allCellsArray == null) return true; // error
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -