📄 stitchfilljob.java
字号:
List<Layer> listOfLayers = new ArrayList<Layer>(12); for (Iterator<Layer> itL = theCell.getTechnology().getLayers(); itL.hasNext(); ) { Layer l = itL.next(); if (!l.getFunction().isMetal()) continue; // only metals listOfLayers.add(l); } Collections.sort(listOfLayers, Layer.layerSortByName); Map<ArcProto,Integer> arcsCreatedMap = new HashMap<ArcProto,Integer>(); Map<NodeProto,Integer> nodesCreatedMap = new HashMap<NodeProto,Integer>(); boolean evenHorizontal = true; // even metal layers are horizontal. Basic assumption List<Route> routeList = new ArrayList<Route>(); Layer[] topLayers = new Layer[2]; Layer bottomLayer = null; Map<String,Area> totalAreas = new HashMap<String,Area>(); for (int i = 0; i < listOfLayers.size() - 1; i++) { Layer bottom = listOfLayers.get(i); boolean horizontal = isLayerHorizontal(bottom, evenHorizontal); List<ArcInst> arcs = getArcsInGivenLayer(theCell.getArcs(), horizontal, bottom, null, null); Layer top = listOfLayers.get(i+1); Map<String,Area> remainingGeos = new HashMap<String,Area>(); for (ArcInst ai : arcs) { // Picking only 1 export and considering the root name` Netlist netlist = theCell.getNetlist(); // getting new version of netlist after every routing. String bottomName = getExportRootName(ai, netlist); if (bottomName == null) continue; // nothing to export List<PinsArcPair> pairs = new ArrayList<PinsArcPair>(); Rectangle2D bounds = ai.getBounds(); Area bottomA = new Area(bounds); if (bottomLayer == null || bottom == bottomLayer) // only for the bottom layer, the first one { Area totalA = totalAreas.get(bottomName); if (totalA == null) { totalA = new Area(); totalAreas.put(bottomName, totalA); } totalA.add(bottomA); } for(Iterator<RTBounds> it = theCell.searchIterator(bounds); it.hasNext(); ) { Geometric nGeom = (Geometric)it.next(); if (!(nGeom instanceof ArcInst)) { continue; // only arcs } ArcInst nai = (ArcInst)nGeom; // Checking arc orientation with respect to layer // If the orientation is not correct, then ignore it // Must be perpendicular to the reference layer (bottom) if (!isArcAligned(nai, !horizontal)) continue; Layer nl = nai.getProto().getLayer(0); if (nl != top) continue; // ascending order is easy String topName = getExportRootName(nai, netlist); if (topName == null || !topName.equals(bottomName)) continue; // no export matching Rectangle2D nBnds = nai.getBounds(); Area topA = new Area(nBnds); topA.intersect(bottomA); Rectangle2D resultBnd = topA.getBounds2D(); // checking for full overlap. If horizontal -> width must be 100% boolean fullCoverageX = (horizontal) ? DBMath.areEquals(resultBnd.getWidth(), nBnds.getWidth()) : DBMath.areEquals(resultBnd.getHeight(), nBnds.getHeight()); boolean fullCoverageY = (horizontal) ? DBMath.areEquals(resultBnd.getHeight(), bounds.getHeight()) : DBMath.areEquals(resultBnd.getWidth(), bounds.getWidth()); if (!fullCoverageX || !fullCoverageY) { // adding to list of pieces of geometries Area a = remainingGeos.get(bottomName); if (a == null) { a = new Area(); remainingGeos.put(bottomName, a); } a.add(topA); continue; // skipping this case } EPoint insert = new EPoint(resultBnd.getCenterX(), resultBnd.getCenterY()); pairs.add(new PinsArcPair(nai, insert, resultBnd)); } Collections.sort(pairs, pinsArcSort); ArcInst mostLeft = ai; routeList.clear(); if (bottomLayer == null) bottomLayer = bottom; // Mark the layer as possible one of the top ones if (!pairs.isEmpty()) { topLayers[0] = bottom; topLayers[1] = top; } Area a = remainingGeos.get(bottomName); for (PinsArcPair pair : pairs) { //SplitContainter bottomSplit = splitArcAtPoint(mostLeft, pair.insert); //SplitContainter topSplit = splitArcAtPoint(pair.topArc, pair.insert); Route r = router.planRoute(theCell, mostLeft, pair.topArc, pair.insert, null, true, true, pair.cut); //mostLeft = bottomSplit.rightArc; routeList.add(r); // Extract area from possible remaining geometry. This will happen // when the wires are in zig-zag if (a != null) // there is a remainig area { Area remove = new Area(pair.cut); a.subtract(remove); } } for (Route r : routeList) { Router.createRouteNoJob(r, theCell, false, arcsCreatedMap, nodesCreatedMap); } } // Adding remaining contacts due to non-100% overlap with original arcs for (Map.Entry<String,Area> e : remainingGeos.entrySet()) { Area a = e.getValue(); Netlist netlist = theCell.getNetlist(); List<PolyBase> list = PolyBase.getPointsInArea(a, bottom, false, false); List<ArcInst> at = getArcsInGivenLayer(theCell.getArcs(), !horizontal, top, e.getKey(), netlist); List<PinsArcPair> pairs = new ArrayList<PinsArcPair>(2); // Add extra contacts. All points should be aligned in same horizontal or vertical line // first the top arcs. They should be less in number (less number of splits) for (PolyBase p : list) { Rectangle2D resultBnd = p.getBounds2D(); // look for the first pair of arcs in bottom/top arcs that overlap with geometry ArcInst topA = getArcInstOverlappingWithArea(resultBnd, at, horizontal, true); // perferct if fully contains the arc if (topA != null) { EPoint insert = new EPoint(resultBnd.getCenterX(), resultBnd.getCenterY()); pairs.add(new PinsArcPair(topA, insert, resultBnd)); } } // Sort the new pairs from left/top to right/bottom Collections.sort(pairs, pinsArcSort); // Look for bottomLayer arcs for those given positions List<ArcInst> ab = getArcsInGivenLayer(theCell.getArcs(), horizontal, bottom, e.getKey(), netlist); routeList.clear(); for (PinsArcPair pair : pairs) { ArcInst bottomA = getArcInstOverlappingWithArea(pair.cut, ab, horizontal, false); if (bottomA != null) { //SplitContainter bottomSplit = splitArcAtPoint(bottomA, pair.insert); //SplitContainter topSplit = splitArcAtPoint(pair.topArc, pair.insert); Route r = router.planRoute(theCell, bottomA, pair.topArc, pair.insert, null, true, true, pair.cut); // remove the old one and add new arc ab.remove(bottomA); //ab.add(bottomSplit.rightArc); topLayers[0] = bottom; topLayers[1] = top; routeList.add(r); } else if (Job.getDebug()) { bottomA = getArcInstOverlappingWithArea(pair.cut, ab, horizontal, false); System.out.println("AFG: It couldn't find bottom layer for " + pair.cut); } } for (Route r : routeList) { Router.createRouteNoJob(r, theCell, false, arcsCreatedMap, nodesCreatedMap); } } } Netlist netlist = theCell.getNetlist(); // Connect cell instances for (Iterator<NodeInst> itNi = theCell.getNodes(); itNi.hasNext();) { NodeInst ni = itNi.next(); // only cell instances if (!ni.isCellInstance()) continue; // Checking if the export overlaps with // Checking if there are exports overlapping with the arc List<String> doneExports = new ArrayList<String>(); routeList.clear(); SimpleWirer niRouter = new SimpleWirer(); for (Iterator<Export> itE = ni.getExports(); itE.hasNext(); ) { Export ex = itE.next(); String exportName = ex.getName(); String rootName = extractRootName(exportName); if (doneExports.contains(rootName)) // exportName continue; // export for this given NodeInst was done PrimitiveNode n = ex.getBasePort().getParent(); Layer layer = n.getLayerIterator().next(); // assuming only 1 PortInst pi = ex.getOriginalPort(); PortProto epi = pi.getPortProto(); EPoint exportCenter = pi.getCenter(); NodeProto np = epi.getParent(); if (!(np instanceof Cell)) continue; // not good for now. Cell c = (Cell)np; Netlist netl = c.getNetlist(); Network jExp = netl.getNetwork((Export)epi, 0); Area expA = new Area(); // Look for all arcs in the cell instances that are on the given layer and netwoek for (Iterator<ArcInst> itA = jExp.getArcs(); itA.hasNext();) { ArcInst ai = itA.next(); Layer l = ai.getProto().getLayer(0); if (l != layer) continue; expA.add(new Area(ai.getBounds())); } // Algorithm will look for the closest connection. Rectangle2D bestCut = null; // represents the best cut ArcInst bestArc = null; Point2D bestCenter = null; double bestDistance = Double.MAX_VALUE; List<Network> netList = getNetworkFromName(netlist, rootName);// jNet = getNetworkFromName(netlist, rootName); for (Network jNet : netList) { for (Iterator<ArcInst> itA = jNet.getArcs(); itA.hasNext();) { ArcInst ai = itA.next(); Layer l = ai.getProto().getLayer(0); if (l == layer) System.out.println("found in same layer"); else if (Math.abs(l.getIndex() - layer.getIndex()) <=1) { // Not selecting the closest element yet Area bnd = new Area(ai.getBounds()); bnd.intersect(expA); if (!bnd.isEmpty()) { Rectangle2D cut = bnd.getBounds2D(); Point2D center = new EPoint(cut.getCenterX(), cut.getCenterY()); double dist = DBMath.distBetweenPoints(center, exportCenter); if (bestCenter == null || DBMath.isLessThan(dist, bestDistance)) { // first time or the new distance is shorter bestCenter = center; bestCut = cut; bestArc = ai; bestDistance = dist; } } } } } if (bestCut != null) // best location found { Route r = niRouter.planRoute(theCell, bestArc, pi, bestCenter, null, true, true, bestCut); routeList.add(r); doneExports.add(rootName); } } for (Route r : routeList) { Router.createRouteNoJob(r, theCell, false, arcsCreatedMap, nodesCreatedMap); } } // Remove exports in lower layers Set<Export> toDelete = new HashSet<Export>(); Map<String,Export> inBottomLayer = new HashMap<String,Export>(); // enough with 1 export stored // find the highest level metal for a given network Map<Network,Layer> maximumLayer = new HashMap<Network,Layer>(); for (Iterator<Export> itE = theCell.getExports(); itE.hasNext();) { Export exp = itE.next(); PrimitiveNode n = exp.getBasePort().getParent(); Network net = netlist.getNetwork(exp, 0); Layer l = maximumLayer.get(net); for (Iterator<Layer> itL = n.getLayerIterator(); itL.hasNext();) { Layer lnew = itL.next(); if (l == null) { l = lnew; continue; } if (lnew.getFunction().getLevel() > l.getFunction().getLevel()) { l = lnew; } } maximumLayer.put(net, l); } for (Iterator<Export> itE = theCell.getExports(); itE.hasNext();) { Export exp = itE.next(); PrimitiveNode n = exp.getBasePort().getParent(); boolean found = false; String rootName = extractRootName(exp.getName()); Layer topLayer = maximumLayer.get(netlist.getNetwork(exp, 0)); int levelMax = topLayer.getFunction().getLevel(); for (Iterator<Layer> itL = n.getLayerIterator(); itL.hasNext();) { Layer l = itL.next(); int level = l.getFunction().getLevel(); if (level == levelMax || level == (levelMax-1)) { found = true; } else { inBottomLayer.put(rootName, exp); // put the last one in the network. } } if (!found) // delete the export toDelete.add(exp); } // Add extra export in the middle of the botoom layer. if (wideOption) { Map<String,List<PinsArcPair>> newExports = new HashMap<String,List<PinsArcPair>>(); boolean horizontal = isLayerHorizontal(bottomLayer, evenHorizontal); // For each export 1 export in the bottom layer should be insert for (Map.Entry<String,Export> e : inBottomLayer.entrySet()) { Export exp = e.getValue(); String rootName = extractRootName(exp.getName()); Network net = netlist.getNetwork(exp, 0); // Collect first all the arcs in that layer List<ArcInst> arcs = getArcsInGivenLayer(net.getArcs(), horizontal, bottomLayer, null, null); Area area = totalAreas.get(rootName);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -