📄 elib.java
字号:
try { if (readTheLibrary(true, null)) return true; createLibraryCells(true); 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 { // initialize clippedIntegers = 0; byteCount = 0; // read the magic number and determine whether bytes are swapped header = readHeader(); if (header == null) { System.out.println("Error reading header"); return true; } if (fc != null) fc.header = header; // get count of objects in the file toolCount = readBigInteger(); techCount = readBigInteger(); primNodeProtoCount = readBigInteger(); primPortProtoCount = readBigInteger(); arcProtoCount = readBigInteger(); nodeProtoCount = readBigInteger(); nodeCount = readBigInteger(); exportCount = readBigInteger(); arcCount = readBigInteger(); geomCount = readBigInteger(); if (header.magic <= ELIBConstants.MAGIC9 && header.magic >= ELIBConstants.MAGIC11) { // versions 9 through 11 stored a "cell count" cellCount = readBigInteger(); } else { cellCount = nodeProtoCount; } readBigInteger(); // ignore current cell // get the Electric version (version 8 and later) String versionString; if (header.magic <= ELIBConstants.MAGIC8) versionString = readString(); else versionString = "3.35"; version = Version.parseVersion(versionString); if (fc != null) fc.version = version; // for versions before 6.03q, convert MOSIS CMOS technology names convertMosisCmosTechnologies = version.compareTo(Version.parseVersion("6.03q")) < 0; // for versions before 6.04c, convert text descriptor values convertTextDescriptors = version.compareTo(Version.parseVersion("6.04c")) < 0; // for versions 6.05x and later, always have text descriptor values alwaysTextDescriptors = version.compareTo(Version.parseVersion("6.05x")) >= 0; // for Electric version 4 or earlier, scale lambda by 20 scaleLambdaBy20 = version.compareTo(Version.parseVersion("5")) < 0; // mirror bits rotationMirrorBits = version.compareTo(Version.parseVersion("7.01")) >= 0; // get the newly created views (version 9 and later) viewMapping = new HashMap<Integer,View>(); viewMapping.put(new Integer(-1), View.UNKNOWN); viewMapping.put(new Integer(-2), View.LAYOUT); viewMapping.put(new Integer(-3), View.SCHEMATIC); viewMapping.put(new Integer(-4), View.ICON); viewMapping.put(new Integer(-5), View.DOCWAVE); viewMapping.put(new Integer(-6), View.LAYOUTSKEL); viewMapping.put(new Integer(-7), View.VHDL); viewMapping.put(new Integer(-8), View.NETLIST); viewMapping.put(new Integer(-9), View.DOC); viewMapping.put(new Integer(-10), View.NETLISTNETLISP); viewMapping.put(new Integer(-11), View.NETLISTALS); viewMapping.put(new Integer(-12), View.NETLISTQUISC); viewMapping.put(new Integer(-13), View.NETLISTRSIM); viewMapping.put(new Integer(-14), View.NETLISTSILOS); viewMapping.put(new Integer(-15), View.VERILOG); viewMapping.put(new Integer(-16), View.LAYOUTCOMP); if (header.magic <= ELIBConstants.MAGIC9) { int numExtraViews = readBigInteger(); for(int i=0; i<numExtraViews; i++) { String viewName = readString(); String viewShortName = readString(); View view = View.findView(viewName); if (view == null) { // special conversion from old view names view = findOldViewName(viewName); if (view == null && !onlyProjectSettings) { view = View.newInstance(viewName, viewShortName); if (view == null) return true; } } viewMapping.put(new Integer(i+1), view); } } // get the number of toolbits to ignore if (header.magic <= ELIBConstants.MAGIC3 && header.magic >= ELIBConstants.MAGIC6) { // versions 3, 4, 5, and 6 find this in the file toolBCount = readBigInteger(); } else { // versions 1 and 2 compute this (versions 7 and later ignore it) toolBCount = toolCount; } // allocate pointers for the Technologies techIdList = new TechId[techCount]; techList = new Technology[techCount]; techError = new String[techCount]; techVars = new Variable[techCount][]; techLambda = new int[techCount]; arcProtoIdList = new ArcProtoId[arcProtoCount]; arcProtoList = new ArcProto[arcProtoCount]; arcProtoError = new String[arcProtoCount]; primitiveNodeIdList = new PrimitiveNodeId[primNodeProtoCount]; primNodeProtoList = new PrimitiveNode[primNodeProtoCount]; primNodeProtoError = new boolean[primNodeProtoCount]; primNodeProtoOrig = new String[primNodeProtoCount]; primNodeProtoTech = new int[primNodeProtoCount]; primitivePortIdList = new PrimitivePortId[primPortProtoCount]; primPortProtoList = new PrimitivePort[primPortProtoCount]; primPortProtoError = new String[primPortProtoCount]; // allocate pointers for the Tools toolList = new Tool[toolCount]; toolError = new String[toolCount]; toolVars = new Variable[toolCount][]; // allocate pointers for the Cells nodeProtoList = new Cell[nodeProtoCount]; cellProtoName = new String[nodeProtoCount]; cellCreationDate = new int[nodeProtoCount]; cellRevisionDate = new int[nodeProtoCount]; cellUserBits = new int[nodeProtoCount]; cellVars = new Variable[nodeProtoCount][]; cellLowX = new int[nodeProtoCount]; cellHighX = new int[nodeProtoCount]; cellLowY = new int[nodeProtoCount]; cellHighY = new int[nodeProtoCount]; cellLibraryPath = new String[nodeProtoCount]; nodeCounts = new int[nodeProtoCount]; firstNodeIndex = new int[nodeProtoCount+1]; arcCounts = new int[nodeProtoCount]; firstArcIndex = new int[nodeProtoCount+1]; portCounts = new int[nodeProtoCount]; firstPortIndex = new int[nodeProtoCount]; cellLambda = new double[nodeProtoCount]; cellXOff = new int[nodeProtoCount]; cellYOff = new int[nodeProtoCount]; cellNextInCellGroup = new int[nodeProtoCount]; xLibRefSatisfied = new boolean[nodeProtoCount]; Arrays.fill(cellNextInCellGroup, -1); // allocate pointers for the NodeInsts boolean hasAnchor = header.magic <= ELIBConstants.MAGIC13; nodeInstList = new LibraryFiles.NodeInstList(nodeCount, hasAnchor); nodeTypeList = new int[nodeCount]; // allocate pointers for the ArcInsts arcList = new ArcInst[arcCount]; arcTypeList = new int[arcCount]; arcNameList = new String[arcCount]; arcNameDescriptorList = new TextDescriptor[arcCount]; arcWidthList = new int[arcCount]; arcHeadXPosList = new int[arcCount]; arcHeadYPosList = new int[arcCount]; arcHeadNodeList = new int[arcCount]; arcHeadPortList = new int[arcCount]; arcTailXPosList = new int[arcCount]; arcTailYPosList = new int[arcCount]; arcTailNodeList = new int[arcCount]; arcTailPortList = new int[arcCount]; arcUserBits = new int[arcCount]; arcVariables = new Variable[arcCount][]; for(int i = 0; i < arcCount; i++) { arcHeadNodeList[i] = -1; arcHeadPortList[i] = -1; arcTailNodeList[i] = -1; arcTailPortList[i] = -1; arcNameList[i] = null; arcUserBits[i] = 0; } // allocate pointers for the Exports exportList = new Object[exportCount]; exportSubNodeList = new int[exportCount]; exportSubPortList = new int[exportCount]; exportNameList = new String[exportCount]; exportNameDescriptors = new TextDescriptor[exportCount]; exportUserbits = new int[exportCount]; exportVariables = new Variable[exportCount][]; // versions 9 to 11 allocate fake-cell pointers if (header.magic <= ELIBConstants.MAGIC9 && header.magic >= ELIBConstants.MAGIC11) { fakeCellList = new FakeCell[cellCount]; for(int i=0; i<cellCount; i++) fakeCellList[i] = new FakeCell(); } // versions 4 and earlier allocate geometric pointers if (header.magic > ELIBConstants.MAGIC5) { geomType = new boolean [geomCount]; geomMoreUp = new int [geomCount]; } // get number of arcinsts and nodeinsts in each cell if (header.magic != ELIBConstants.MAGIC1) { // versions 2 and later find this in the file int nodeInstPos = 0, arcInstPos = 0, portProtoPos = 0; for(int i=0; i<nodeProtoCount; i++) { arcCounts[i] = readBigInteger(); nodeCounts[i] = readBigInteger(); portCounts[i] = readBigInteger(); // the arc and node counts are negative for external cell references if (arcCounts[i] > 0 || nodeCounts[i] > 0) { arcInstPos += arcCounts[i]; nodeInstPos += nodeCounts[i]; } portProtoPos += portCounts[i]; } // verify that the number of node instances is equal to the total in the file if (nodeInstPos != nodeCount) { System.out.println("Error: cells have " + nodeInstPos + " nodes but library has " + nodeCount); return true; } if (arcInstPos != arcCount) { System.out.println("Error: cells have " + arcInstPos + " arcs but library has " + arcCount); return true; } if (portProtoPos != exportCount) { System.out.println("Error: cells have " + portProtoPos + " ports but library has " + exportCount); return true; } } else { // version 1 computes this information arcCounts[0] = arcCount; nodeCounts[0] = nodeCount; portCounts[0] = exportCount; for(int i=1; i<nodeProtoCount; i++) arcCounts[i] = nodeCounts[i] = portCounts[i] = 0; }// // allocate all cells in the library// for(int i=0; i<nodeProtoCount; i++)// {// if (arcCounts[i] < 0 && nodeCounts[i] < 0)// {// // this cell is from an external library// nodeProtoList[i] = null;// xLibRefSatisfied[i] = false;// } else// {// nodeProtoList[i] = Cell.lowLevelAllocate(lib);// if (nodeProtoList[i] == null) return true;// xLibRefSatisfied[i] = true;// }// } // setup pointers for technology and primitive ids IdManager idManager = fc != null ? fc.idManager() : this.idManager; primNodeProtoCount = 0; primPortProtoCount = 0; arcProtoCount = 0; for(int techIndex=0; techIndex<techCount; techIndex++) { // get the technology String name = readString(); TechId techId = idManager.newTechId(name); techIdList[techIndex] = techId; // get the number of primitive node prototypes int numPrimNodes = readBigInteger(); for(int j=0; j<numPrimNodes; j++) { name = readString(); PrimitiveNodeId primitiveNodeId = techId.newPrimitiveNodeId(name); primitiveNodeIdList[primNodeProtoCount] = primitiveNodeId; primNodeProtoTech[primNodeProtoCount] = techIndex; // get the number of primitive port prototypes int numPrimPorts = readBigInteger(); for(int i=0; i<numPrimPorts; i++) { name = readString(); PrimitivePortId primitivePortId = primitiveNodeId.newPortId(name); primitivePortIdList[primPortProtoCount++] = primitivePortId; } primNodeProtoCount++; } // get the number of arc prototypes int numArcProtos = readBigInteger(); for(int j=0; j<numArcProtos; j++) { name = readString(); ArcProtoId arcProtoId = techId.newArcProtoId(name); arcProtoIdList[arcProtoCount++] = arcProtoId; } } // setup pointers for tools for(int i=0; i<toolCount; i++) { String name = readString(); toolError[i] = null; Tool t = Tool.findTool(name); if (t == null) { toolError[i] = name; } toolList[i] = t; } if (header.magic <= ELIBConstants.MAGIC3 && header.magic >= ELIBConstants.MAGIC6) { // versions 3, 4, 5, and 6 must ignore toolbits associations for(int i=0; i<toolBCount; i++) readString(); } // get the library userbits
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -