?? gds.java
字號:
str = str.substring(0, str.indexOf("_")); } outputString(str, HDR_STRING); outputHeader(HDR_ENDEL, 0); } /** * Method to determine whether or not to merge geometry. */ protected boolean mergeGeom(int hierLevelsFromBottom) { return IOTool.isGDSOutMergesBoxes(); } /** * Method to determine whether or not to include the original Geometric with a Poly */ protected boolean includeGeometric() { return false; } private boolean selectLayer(Layer layer) { GDSLayers numbers = layerNumbers.get(layer); if (numbers == null) { Technology tech = layer.getTechnology(); for (Iterator<Layer> it = tech.getLayers(); it.hasNext(); ) { Layer l = it.next(); layerNumbers.put(l, GDSLayers.EMPTY); } for (Map.Entry<Layer,String> e: tech.getGDSLayers().entrySet()) { Layer l = e.getKey(); String gdsLayer = e.getValue(); layerNumbers.put(l, GDSLayers.parseLayerString(gdsLayer)); } numbers = layerNumbers.get(layer); } // might be null because Artwork layers are auto-generated and not in the Technology list if (numbers == null) numbers = GDSLayers.EMPTY; currentLayerNumbers = numbers; // validLayer false if layerName = "" like for pseudo metals return numbers.getNumLayers() > 0; } protected void writePoly(PolyBase poly, int layerNumber, int layerType) { // ignore negative layer numbers if (layerNumber < 0) return; Point2D [] points = poly.getPoints(); if (poly.getStyle() == Poly.Type.DISC) { // Make a square of the size of the diameter double r = points[0].distance(points[1]); if (r <= 0) return; Poly newPoly = new Poly(points[0].getX(), points[0].getY(), r*2, r*2); outputBoundary(newPoly, layerNumber, layerType); return; } Rectangle2D polyBounds = poly.getBox(); if (polyBounds != null) { // rectangular manhattan shape: make sure it has positive area if (polyBounds.getWidth() == 0 || polyBounds.getHeight() == 0) return; outputBoundary(poly, layerNumber, layerType); return; } // non-manhattan or worse .. direct output if (points.length == 1) { System.out.println("WARNING: Single point cannot be written in GDS-II"); return; } if (points.length > 200) { System.out.println("WARNING: GDS-II Polygons may not have more than 200 points (this has " + points.length + ")"); return; } if (points.length == 2) outputPath(poly, layerNumber, layerType); else outputBoundary(poly, layerNumber, layerType); } protected void writeNodable(Nodable no) { NodeInst ni = (NodeInst)no; // In layout cell all Nodables are NodeInsts Cell subCell = (Cell)ni.getProto(); // figure out transformation int transValue = 0; int angle = ni.getAngle(); if (ni.isXMirrored() != ni.isYMirrored()) transValue |= STRANS_REFLX; if (ni.isYMirrored()) angle = (3600 - angle)%3600; if (ni.isXMirrored()) angle = (1800 - angle)%3600; // write a call to a cell outputHeader(HDR_SREF, 0); String name = cellNames.get(subCell); outputName(HDR_SNAME, name, HDR_M_SNAME); outputHeader(HDR_STRANS, transValue); outputAngle(angle); outputShort((short)12); outputShort(HDR_XY); outputInt(scaleDBUnit(ni.getAnchorCenterX())); outputInt(scaleDBUnit(ni.getAnchorCenterY())); outputHeader(HDR_ENDEL, 0); } /****************************** VISITOR SUBCLASS ******************************/ private BloatVisitor makeBloatVisitor(int maxDepth) { BloatVisitor visitor = new BloatVisitor(this, maxDepth); return visitor; } /** * Class to override the Geometry visitor and add bloating to all polygons. * Currently, no bloating is being done. */ private class BloatVisitor extends Geometry.Visitor { BloatVisitor(Geometry outGeom, int maxHierDepth) { super(outGeom, maxHierDepth); } public void addNodeInst(NodeInst ni, AffineTransform trans) { PrimitiveNode prim = (PrimitiveNode)ni.getProto(); Technology tech = prim.getTechnology(); Poly [] polys = tech.getShapeOfNode(ni); Layer firstLayer = null; for (int i=0; i<polys.length; i++) { Poly poly = polys[i]; if (poly.isPseudoLayer()) continue; Layer thisLayer = poly.getLayer(); if (thisLayer != null && firstLayer == null) firstLayer = thisLayer; if (poly.getStyle().isText()) { // dump this text field outputHeader(HDR_TEXT, 0); if (firstLayer != null) selectLayer(firstLayer); Integer firstLayerVal = currentLayerNumbers.getFirstLayer(); int layerNum = firstLayerVal.intValue() & 0xFFFF; int layerType = (firstLayerVal.intValue() >> 16) & 0xFFFF; outputHeader(HDR_LAYER, layerNum); outputHeader(HDR_TEXTTYPE, layerType); outputHeader(HDR_PRESENTATION, EXPORTPRESENTATION); // figure out transformation int transValue = 0; int angle = ni.getAngle(); if (ni.isXMirrored() != ni.isYMirrored()) transValue |= STRANS_REFLX; if (ni.isYMirrored()) angle = (3600 - angle)%3600; if (ni.isXMirrored()) angle = (1800 - angle)%3600; outputHeader(HDR_STRANS, transValue); outputAngle(angle); outputShort((short)12); outputShort(HDR_XY); Point2D [] points = poly.getPoints(); outputInt(scaleDBUnit(points[0].getX())); outputInt(scaleDBUnit(points[0].getY())); // now the string String str = poly.getString(); outputString(str, HDR_STRING); outputHeader(HDR_ENDEL, 0); } poly.transform(trans); } cellGeom.addPolys(polys, ni); } public void addArcInst(ArcInst ai) { ArcProto ap = ai.getProto(); Technology tech = ap.getTechnology(); Poly [] polys = tech.getShapeOfArc(ai); cellGeom.addPolys(polys, ai); } } /*************************** GDS OUTPUT ROUTINES ***************************/ /** * Method to initialize various fields, get some standard values */ private void initOutput() { blockCount = 0; bufferPosition = 0; // all zeroes for (int i=0; i<DSIZE; i++) emptyBuffer[i] = 0; Technology tech = topCell.getTechnology(); scaleFactor = tech.getScale(); layerNumbers = new HashMap<Layer,GDSLayers>(); nameRemapping = new HashMap<String,Set<String>>(); // precache the layers in this technology boolean foundValid = false; for(Iterator<Layer> it = tech.getLayers(); it.hasNext(); ) { Layer layer = it.next(); if (selectLayer(layer)) foundValid = true; } if (!foundValid) { System.out.println("Warning: there are no GDS II layers defined for the " + tech.getTechName() + " technology"); } // make a hashmap of all names to use for cells cellNames = new HashMap<Cell,String>(); buildUniqueNames(topCell, cellNames); } /** * Recursive method to add all cells in the hierarchy to the hashMap * with unique names. * @param cell the cell whose nodes and subnode cells will be given unique names. * @param cellNames a hashmap, key: cell, value: unique name (String). */ public static void buildUniqueNames(Cell cell, Map<Cell,String> cellNames) { if (!cellNames.containsKey(cell)) cellNames.put(cell, makeUniqueName(cell, cellNames)); for (Iterator<NodeInst> it = cell.getNodes(); it.hasNext(); ) { NodeInst ni = it.next(); if (ni.isCellInstance()) { Cell c = (Cell)ni.getProto(); Cell cproto = c.contentsView(); if (cproto == null) cproto = c; if (!cellNames.containsKey(cproto)) cellNames.put(cproto, makeUniqueName(cproto, cellNames)); buildUniqueNames(cproto, cellNames); } } } public static String makeUniqueName(Cell cell, Map<Cell,String> cellNames) { String name = makeGDSName(cell.getName(), IOTool.getGDSCellNameLenMax()); if (cell.getNewestVersion() != cell) name += "_" + cell.getVersion(); // see if the name is unique String baseName = name; Collection existing = cellNames.values(); // try prepending the library name first if (existing.contains(name)) { int liblen = IOTool.getGDSCellNameLenMax() - (name.length() + concatStr.length()); // space for lib name if (liblen > 0) { String lib = cell.getLibrary().getName(); liblen = (liblen > lib.length()) ? lib.length() : liblen; String libname = lib.substring(0, liblen) + concatStr + name; if (!existing.contains(libname)) { System.out.println("Warning: GDSII out renaming cell "+cell.describe(false)+" to "+libname); return libname; } baseName = libname; } } for(int index = 1; ; index++) { if (!existing.contains(name)) break; name = baseName + "_" + index; int extra = name.length() - IOTool.getGDSCellNameLenMax(); if (extra > 0) { name = baseName.substring(0, baseName.length()-extra); name +="_" + index; } } if (!name.equals(cell.getName())) System.out.println("Warning: GDSII out renaming cell "+cell.describe(false)+" to "+name); return name; } /** * function to create proper GDSII names with restricted character set * from input string str. * Uses only 'A'-'Z', '_', $, ?, and '0'-'9' */ private static String makeGDSName(String str, int maxLen) { // filter the name string for the GDS output cell StringBuffer ret = new StringBuffer(); int max = str.length(); if (max > maxLen-3) max = maxLen-3; for(int k=0; k<max; k++) { char ch = str.charAt(k); if (IOTool.isGDSOutUpperCase()) ch = Character.toUpperCase(ch); if (ch != '$' && !TextUtils.isDigit(ch) && ch != '?' && !Character.isLetter(ch)) ch = '_'; ret.append(ch); } return ret.toString(); } /** * Get the name map. GDS output may mangle cell names * because of all cells occupy the same name space (no libraries). */ public Map<Cell,String> getCellNames() { return cellNames; } /** * Close the file, pad to make the file match the tape format */ private void doneWritingOutput() { try { // Write out the current buffer if (bufferPosition > 0) { // Pack with zeroes for (int i = bufferPosition; i < DSIZE; i++) dataBufferGDS[i] = 0; dataOutputStream.write(dataBufferGDS, 0, DSIZE); blockCount++; } // Pad to 2048 while (blockCount%4 != 0) { dataOutputStream.write(emptyBuffer, 0, DSIZE); blockCount++; } } catch (IOException e) { System.out.println("End of file reached while finishing GDS"); } } /** * Method to write a library header, get the date information */ private void outputBeginLibrary(Cell cell) { outputHeader(HDR_HEADER, GDSVERSION); outputHeader(HDR_BGNLIB, 0); outputDate(cell.getCreationDate()); outputDate(cell.getRevisionDate()); outputName(HDR_LIBNAME, makeGDSName(cell.getName(), HDR_M_ASCII), HDR_M_ASCII); outputShort(HDR_N_UNITS); outputShort(HDR_UNITS); /* GDS floating point values - - * 0x3E418937,0x4BC6A7EF = 0.001 * 0x3944B82F,0xA09B5A53 = 1e-9 * 0x3F28F5C2,0x8F5C28F6 = 0.01 * 0x3A2AF31D,0xC4611874 = 1e-8 */ // set units outputDouble(1e-3); outputDouble(1.0e-9); } void outputBeginStruct(Cell cell) { outputHeader(HDR_BGNSTR, 0); outputDate(cell.getCreationDate()); outputDate(cell.getRevisionDate()); String name = cellNames.get(cell); System.out.println("Warning, sub"+cell+" in hierarchy is not the same view" + " as top level cell");
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -