📄 lef.java
字号:
if (key.equalsIgnoreCase("SHAPE") || key.equalsIgnoreCase("CAPACITANCE") || key.equalsIgnoreCase("ANTENNASIZE")) { if (ignoreToSemicolon(key)) return true; continue; } if (key.equalsIgnoreCase("USE")) { key = getAKeyword(); if (key == null) { System.out.println("EOF reading USE clause"); return true; } if (key.equalsIgnoreCase("POWER")) useCharacteristics = PortCharacteristic.PWR; else if (key.equalsIgnoreCase("GROUND")) useCharacteristics = PortCharacteristic.GND; else if (key.equalsIgnoreCase("CLOCK")) useCharacteristics = PortCharacteristic.CLK; else if (!key.equalsIgnoreCase("SIGNAL") && !key.equalsIgnoreCase("DATA")) { System.out.println("Line " + lineReader.getLineNumber() + ": Unknown USE keyword (" + key + ")"); } if (ignoreToSemicolon("USE")) return true; continue; } if (key.equalsIgnoreCase("DIRECTION")) { key = getAKeyword(); if (key == null) { System.out.println("EOF reading DIRECTION clause"); return true; } if (key.equalsIgnoreCase("INPUT")) portCharacteristics = PortCharacteristic.IN; else if (key.equalsIgnoreCase("OUTPUT")) portCharacteristics = PortCharacteristic.OUT; else if (key.equalsIgnoreCase("INOUT")) portCharacteristics = PortCharacteristic.BIDIR; else { System.out.println("Line " + lineReader.getLineNumber() + ": Unknown DIRECTION keyword (" + key + ")"); } if (ignoreToSemicolon("DIRECTION")) return true; continue; } if (key.equalsIgnoreCase("PORT")) { if (useCharacteristics != PortCharacteristic.UNKNOWN) portCharacteristics = useCharacteristics; if (readPort(cell, pinName, portCharacteristics)) return true; continue; } System.out.println("Line " + lineReader.getLineNumber() + ": Unknown PIN keyword (" + key + ")"); return true; } return false; } private boolean readPort(Cell cell, String portname, PortCharacteristic portCharacteristics) throws IOException { ArcProto ap = null; NodeProto pureNp = null; LEFPath lefPaths = null; boolean first = true; double intWidth = 0; double lastIntX = 0, lastIntY = 0; Point2D singlePathPoint = null; for(;;) { String key = getAKeyword(); if (key == null) { System.out.println("EOF parsing PORT"); return true; } if (key.equalsIgnoreCase("END")) { break; } if (key.equalsIgnoreCase("CLASS")) { if (ignoreToSemicolon("LAYER")) return true; continue; } if (key.equalsIgnoreCase("LAYER")) { key = getAKeyword(); if (key == null) { System.out.println("EOF reading LAYER clause"); return true; } GetLayerInformation li = getLayerInformation(key); ap = li.arc; pureNp = li.pure; if (ignoreToSemicolon("LAYER")) return true; continue; } if (key.equalsIgnoreCase("WIDTH")) { key = getAKeyword(); if (key == null) { System.out.println("EOF reading WIDTH clause"); return true; } intWidth = convertLEFString(key); if (ignoreToSemicolon("WIDTH")) return true; continue; } if (key.equalsIgnoreCase("RECT")) { key = getAKeyword(); if (key == null) { System.out.println("EOF reading RECT low X"); return true; } double lX = convertLEFString(key); key = getAKeyword(); if (key == null) { System.out.println("EOF reading RECT low Y"); return true; } double lY = convertLEFString(key); key = getAKeyword(); if (key == null) { System.out.println("EOF reading RECT high X"); return true; } double hX = convertLEFString(key); key = getAKeyword(); if (key == null) { System.out.println("EOF reading RECT high Y"); return true; } double hY = convertLEFString(key); if (ignoreToSemicolon("RECT")) return true; // make the pin if (PLACELEFGEOMETRY) { if (pureNp == null) { System.out.println("Line " + lineReader.getLineNumber() + ": No layers for RECT"); return true; } Point2D ctr = new Point2D.Double((lX+hX)/2, (lY+hY)/2); double sX = Math.abs(hX - lX); double sY = Math.abs(hY - lY); NodeInst ni = NodeInst.makeInstance(pureNp, ctr, sX, sY, cell); if (ni == null) { System.out.println("Line " + lineReader.getLineNumber() + ": Cannot create pin for RECT"); return true; } if (first) { // create the port on the first pin first = false; Export pp = newPort(cell, ni, pureNp.getPort(0), portname); if (pp != null) pp.setCharacteristic(portCharacteristics); } } continue; } if (key.equalsIgnoreCase("PATH")) { if (ap == null) { System.out.println("Line " + lineReader.getLineNumber() + ": No layers for PATH"); return true; } for(int i=0; ; i++) { key = getAKeyword(); if (key == null) { System.out.println("EOF reading PATH clause"); return true; } if (key.equals(";")) break; double intx = convertLEFString(key); key = getAKeyword(); if (key == null) { System.out.println("EOF reading PATH clause"); return true; } double inty = convertLEFString(key); // plot this point if (i == 0) singlePathPoint = new Point2D.Double(intx, inty); else { // queue path LEFPath lp = new LEFPath(); lp.pt[0] = new Point2D.Double(lastIntX, lastIntY); lp.pt[1] = new Point2D.Double(intx, inty); lp.ni[0] = null; lp.ni[1] = null; lp.width = intWidth; lp.arc = ap; lp.nextLEFPath = lefPaths; lefPaths = lp; } lastIntX = intx; lastIntY = inty; } continue; } if (key.equalsIgnoreCase("VIA")) { // get the coordinates key = getAKeyword(); if (key == null) { System.out.println("EOF reading VIA clause"); return true; } double intX = convertLEFString(key); key = getAKeyword(); if (key == null) { System.out.println("EOF reading VIA clause"); return true; } double intY = convertLEFString(key); // find the proper via key = getAKeyword(); GetLayerInformation li = getLayerInformation(key); if (li.pin == null) { System.out.println("Line " + lineReader.getLineNumber() + ": No Via in current technology for '" + key + "'"); return true; } if (ignoreToSemicolon("VIA")) return true; // create the via if (PLACELEFGEOMETRY) { double sX = li.pin.getDefWidth(); double sY = li.pin.getDefHeight(); NodeInst ni = NodeInst.makeInstance(li.pin, new Point2D.Double(intX, intY), sX, sY, cell); if (ni == null) { System.out.println("Line " + lineReader.getLineNumber() + ": Cannot create VIA for PATH"); return true; } } continue; } System.out.println("Line " + lineReader.getLineNumber() + ": Unknown PORT keyword (" + key + ")"); return true; } if (!PLACELEFGEOMETRY) return false; // look for paths that end at vias for(LEFPath lp = lefPaths; lp != null; lp = lp.nextLEFPath) { for(int i=0; i<2; i++) { if (lp.ni[i] != null) continue; Rectangle2D bounds = new Rectangle2D.Double(lp.pt[i].getX(), lp.pt[i].getY(), 0, 0); for(Iterator<RTBounds> sea = cell.searchIterator(bounds); sea.hasNext(); ) { RTBounds geom = sea.next(); if (!(geom instanceof NodeInst)) continue; NodeInst ni = (NodeInst)geom; if (!DBMath.areEquals(ni.getTrueCenter(), lp.pt[i])) continue; lp.ni[i] = ni; break; } if (lp.ni[i] == null) continue; // use this via at other paths which meet here for(LEFPath oLp = lefPaths; oLp != null; oLp = oLp.nextLEFPath) { for(int j=0; j<2; j++) { if (oLp.ni[j] != null) continue; if (!DBMath.areEquals(oLp.pt[j], lp.pt[i])) continue; oLp.ni[j] = lp.ni[i]; } } } } // create pins at all other path ends for(LEFPath lp = lefPaths; lp != null; lp = lp.nextLEFPath) { for(int i=0; i<2; i++) { if (lp.ni[i] != null) continue; NodeProto pin = lp.arc.findPinProto(); if (pin == null) continue; double sX = pin.getDefWidth(); double sY = pin.getDefHeight(); lp.ni[i] = NodeInst.makeInstance(pin, lp.pt[i], sX, sY, cell); if (lp.ni[i] == null) { System.out.println("Line " + lineReader.getLineNumber() + ": Cannot create pin for PATH"); return true; } if (first) { // create the port on the first pin first = false; Export pp = newPort(cell, lp.ni[i], pin.getPort(0), portname); if (pp != null) pp.setCharacteristic(portCharacteristics); } // use this pin at other paths which meet here for(LEFPath oLp = lefPaths; oLp != null; oLp = oLp.nextLEFPath) { for(int j=0; j<2; j++) { if (oLp.ni[j] != null) continue; if (!DBMath.areEquals(oLp.pt[j], lp.pt[i])) continue; oLp.ni[j] = lp.ni[i]; } } } } // now instantiate the paths for(LEFPath lp = lefPaths; lp != null; lp = lp.nextLEFPath) { PortInst head = lp.ni[0].getPortInst(0); PortInst tail = lp.ni[1].getPortInst(0); Point2D headPt = lp.pt[0]; Point2D tailPt = lp.pt[1]; ArcInst ai = ArcInst.makeInstanceBase(lp.arc, lp.width, head, tail, headPt, tailPt, null); if (ai == null) { System.out.println("Line " + lineReader.getLineNumber() + ": Cannot create arc for PATH"); return true; } } if (lefPaths == null && singlePathPoint != null && ap != null && first) { // path was a single point: plot it NodeProto pin = ap.findPinProto(); if (pin != null) { double sX = pin.getDefWidth(); double sY = pin.getDefHeight(); NodeInst ni = NodeInst.makeInstance(pin, singlePathPoint, sX, sY, cell); if (ni == null) { System.out.println("Line " + lineReader.getLineNumber() + ": Cannot create pin for PATH"); return true; } // create the port on the pin Export pp = newPort(cell, ni, pin.getPort(0), portname); if (pp != null) pp.setCharacteristic(portCharacteristics); } } return false; } /** * Method to create a port called "thename" on port "pp" of node "ni" in cell "cell". * The name is modified if it already exists. */ private Export newPort(Cell cell, NodeInst ni, PortProto pp, String thename) { String portName = thename; String newName = null; for(int i=0; ; i++) { Export e = (Export)cell.findPortProto(portName); if (e == null) { PortInst pi = ni.findPortInstFromProto(pp); return Export.newInstance(cell, pi, portName); } // make space for modified name newName = thename + "-" + i; portName = newName; } } private boolean readLayer(Library lib) throws IOException { String layerName = getAKeyword(); if (layerName == null) { System.out.println("EOF parsing LAYER header"); return true; } String layerType = null; double defWidth = -1; for(;;) { // get the next keyword String key = getAKeyword(); if (key == null) { System.out.println("EOF parsing LAYER"); return true; } if (key.equalsIgnoreCase("END")) { key = getAKeyword(); break; } if (key.equalsIgnoreCase("WIDTH")) { key = getAKeyword(); if (key == null) { System.out.println("EOF reading WIDTH"); return true; } defWidth = convertLEFString(key); if (ignoreToSemicolon("WIDTH")) return true; continue; } if (key.equalsIgnoreCase("TYPE")) { layerType = getAKeyword(); if (ignoreToSemicolon("TYPE")) return true; continue; } if (key.equalsIgnoreCase("SPACING") || key.equalsIgnoreCase("PITCH") || key.equalsIgnoreCase("DIRECTION") || key.equalsIgnoreCase("CAPACITANCE") || key.equalsIgnoreCase("RESISTANCE")) { if (ignoreToSemicolon(key)) return true; continue; } } GetLayerInformation li = new GetLayerInformation(layerName, layerType); knownLayers.put(layerName, li); ArcProto ap = li.arc; if (ap != null && defWidth > 0) widthsFromLEF.put(ap, new Double(defWidth)); return false; } private boolean ignoreToSemicolon(String command) throws IOException { // ignore up to the next semicolon for(;;) { String key = getAKeyword(); if (key == null) { System.out.println("EOF parsing " + command); return true; } if (key.equals(";")) break; } return false; } private boolean ignoreToEnd(String endName) throws IOException { // ignore up to "END endName" boolean findEnd = true; for(;;) { String key = getAKeyword(); if (key == null) { System.out.println("EOF parsing " + endName); return true; } if (findEnd && key.equalsIgnoreCase("END")) { key = getAKeyword(); if (key == null) { System.out.println("EOF parsing " + endName); return true; } if (key.equals(endName)) break; continue; } if (key.equals(";")) findEnd = true; else findEnd = false; } return false; } private double convertLEFString(String key) { double v = TextUtils.atof(key) * OVERALLSCALE; return TextUtils.convertFromDistance(v, Technology.getCurrent(), TextUtils.UnitScale.MICRO); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -