grt: pins on the inner edges of a rectilinear (L-shaped) macro are entered through the macro (pin edge taken from the bounding box)

オープン
#12,544 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@jfgava がすでに取り組んでいます。

2026年12月2日 から。

  • #12576 @jfgava による — オープン

評価

この issue はまだ評価されていません。

説明

bug grt
Describe the bug

initialize_floorplan accepts a polygonal die, and write_abstract_lef of such a block writes its outline as OBS polygons (and, when the technology has one, on the OVERLAP layer). When that abstract is used as a macro in a parent, global routing picks the side from which each macro pin is entered with Pin::determineEdge, which measures distances to the instance bounding box (src/grt/src/Pin.cpp, determineEdge(iterm->getInst()->getBBox()->getBox(), layers)).

For a pin on an inner (notch) edge of an L-shaped macro, the nearest bounding-box side lies across the macro. addResourcesForPinAccess, isPinReachable and getPositionNearInstEdge then treat the pin as reachable from that side, and FastRoute routes the net through the macro's blocked area:

  • global_route ends with [ERROR GRT-0116] Global routing finished with congestion; the congestion report shows the overflowing GCells inside the macro's arms, all on nets that connect notch-edge pins.
  • With -allow_congestion, detailed_route follows the guides and reports a Short between the net and the macro obstruction (an M3 wire running straight through the macro's arm to the notch-edge pin).

The same parent with a rectangular macro of the same design and the same nets routes with no overflow and no DRC. Notch-edge nets whose two pins abut (both pins in the same or adjacent GCells) are not affected.

Expected behavior

The entry side of a macro pin should be the side of the macro's real outline (OVERLAP obstruction, if present) nearest the pin, so a notch-edge pin is entered from the notch.

To reproduce (public data only: test/asap7 and test/aes_asap7)
  1. Block: run test/flow.tcl for aes_asap7 with a polygonal die and core, e.g.
    -die_area {0 0 104.112 0 104.112 26.19 33.102 26.19 33.102 96.39 0 96.39}
    -core_area {2.052 2.16 102.06 2.16 102.06 24.03 31.05 24.03 31.05 94.23 2.052 94.23}.
    The flow routes with 0 DRC; place_pins puts many pins on the two inner edges. Write write_abstract_lef -bloat_occupied_layers aes_L.lef and write_timing_model aes_L.lib (optionally create an OVERLAP layer first so the LEF carries the outline on OVERLAP).
  2. Parent: a 112.32 x 105.84 um die; instantiate aes_cipher_top at (4.32, 4.32) FIRM and the gcd_asap7 abstract (rectangular) at (41.472, 34.56), inside the L's notch. Connect a few gcd outputs to aes pins on the inner edges (and to aes pins elsewhere), place_pins, then global_route -verbose -congestion_report_file grt.rpt.
  3. Result: GRT-0116, overflow GCells inside the L. Control: replace the L-shaped aes abstract by the same design hardened on a 69 x 69 um rectangle and place gcd beside it: no overflow, detailed route 0 violations.

Scripts can be attached (they use only OpenROAD's test platform and designs).

Proposed fix

Compute the entry side from the instance outline: the master's OVERLAP obstructions transformed to the design, falling back to the bounding box when there are none (identical behavior for rectangular macros). For each pin box, take the distance the pin travels in each direction before leaving the outline (crossing touching rectangles), and pick the smallest. The same applies to block-level ports on a polygonal die (determineEdge(bterm->getBlock()->getDieArea(), ...) uses the die bounding box). A draft patch touching only Pin.cpp/Pin.h is below. It has not been compiled or tested; it is here to show the idea.

Possibly related: PR #12490 (gpl/dpl place around the OVERLAP outline of rectilinear blocks), PR #12019 (place_pin -force_to_die_boundary on polygon floorplans).

Environment

OpenROAD 26Q4 (26Q4-3-gc3aec97051), Linux. The relevant code is unchanged on the 26Q4 tag.

Draft patch (not compiled, not tested)
diff -ru a/src/grt/src/Pin.cpp b/src/grt/src/Pin.cpp
--- a/src/grt/src/Pin.cpp	2026-12-01 06:51:07.156898123 -0500
+++ b/src/grt/src/Pin.cpp	2026-12-01 06:51:26.620082230 -0500
@@ -13,9 +13,94 @@
 #include "odb/db.h"
 #include "odb/dbTypes.h"
 #include "odb/geom.h"
+#include "odb/poly_decomp.h"
 
 namespace grt {
 
+namespace {
+
+// The outline of an instance as rectangles in design coordinates: its master's
+// OVERLAP obstructions, which describe a rectilinear (e.g. L-shaped) block,
+// or its bounding box when the master has none.
+std::vector<odb::Rect> instanceOutline(odb::dbInst* inst)
+{
+  std::vector<odb::Rect> outline;
+  const odb::dbTransform transform = inst->getTransform();
+  for (odb::dbBox* box : inst->getMaster()->getObstructions()) {
+    odb::dbTechLayer* layer = box->getTechLayer();
+    if (layer != nullptr
+        && layer->getType() == odb::dbTechLayerType::OVERLAP) {
+      odb::Rect rect = box->getBox();
+      transform.apply(rect);
+      outline.push_back(rect);
+    }
+  }
+  if (outline.empty()) {
+    outline.push_back(inst->getBBox()->getBox());
+  }
+  return outline;
+}
+
+// The die outline as rectangles; a rectilinear die is decomposed.
+std::vector<odb::Rect> dieOutline(odb::dbBlock* block)
+{
+  const odb::Polygon die = block->getDieAreaPolygon();
+  if (die.isRect()) {
+    return {die.getEnclosingRect()};
+  }
+  std::vector<odb::Point> points = die.getPoints();
+  if (points.size() > 1 && points.front() == points.back()) {
+    points.pop_back();
+  }
+  if (!odb::polygon_is_clockwise(points)) {
+    std::ranges::reverse(points);
+  }
+  std::vector<odb::Rect> rects;
+  odb::decompose_polygon(points, rects);
+  if (rects.empty()) {
+    rects.push_back(die.getEnclosingRect());
+  }
+  return rects;
+}
+
+// Distance a point moving from (x, y) in the given direction travels before
+// it leaves the outline. Rectangles that touch are crossed in turn, so the
+// result is the distance to the outline's boundary, not to its bounding box.
+int exitDistance(const std::vector<odb::Rect>& outline,
+                 const int x,
+                 const int y,
+                 const PinEdge dir)
+{
+  const bool vertical = dir == PinEdge::north || dir == PinEdge::south;
+  const bool positive = dir == PinEdge::north || dir == PinEdge::east;
+  const int start = vertical ? y : x;
+  int pos = start;
+  bool moved = true;
+  while (moved) {
+    moved = false;
+    for (const odb::Rect& r : outline) {
+      const int across = vertical ? x : y;
+      const int lo = vertical ? r.yMin() : r.xMin();
+      const int hi = vertical ? r.yMax() : r.xMax();
+      const int across_lo = vertical ? r.xMin() : r.yMin();
+      const int across_hi = vertical ? r.xMax() : r.yMax();
+      if (across < across_lo || across > across_hi) {
+        continue;
+      }
+      if (positive && lo <= pos && pos < hi) {
+        pos = hi;
+        moved = true;
+      } else if (!positive && lo < pos && pos <= hi) {
+        pos = lo;
+        moved = true;
+      }
+    }
+  }
+  return positive ? pos - start : start - pos;
+}
+
+}  // namespace
+
 Pin::Pin(odb::dbITerm* iterm,
          const odb::Point& position,
          const std::vector<odb::dbTechLayer*>& layers,
@@ -38,7 +123,7 @@
   }
 
   if (connected_to_pad_or_macro) {
-    determineEdge(iterm->getInst()->getBBox()->getBox(), layers);
+    determineEdge(instanceOutline(iterm->getInst()), layers);
   } else {
     connection_layer_ = layers_.back();
   }
@@ -65,27 +150,25 @@
     boxes_per_layer_[layer->getRoutingLevel()] = boxes;
   }
 
-  determineEdge(bterm->getBlock()->getDieArea(), layers);
+  determineEdge(dieOutline(bterm->getBlock()), layers);
 }
 
-void Pin::determineEdge(const odb::Rect& bounds,
+void Pin::determineEdge(const std::vector<odb::Rect>& outline,
                         const std::vector<odb::dbTechLayer*>& layers)
 {
-  odb::Point lower_left;
-  odb::Point upper_right;
   int n_count = 0;
   int s_count = 0;
   int e_count = 0;
   int w_count = 0;
   for (const auto& [layer, boxes] : boxes_per_layer_) {
     for (const auto& box : boxes) {
-      lower_left = box.ll();
-      upper_right = box.ur();
-      // Determine which edge is closest to the pin box
-      const int n_dist = bounds.yMax() - upper_right.y();
-      const int s_dist = lower_left.y() - bounds.yMin();
-      const int e_dist = bounds.xMax() - upper_right.x();
-      const int w_dist = lower_left.x() - bounds.xMin();
+      // Determine which side of the outline is closest to the pin box
+      const int cx = box.xCenter();
+      const int cy = box.yCenter();
+      const int n_dist = exitDistance(outline, cx, box.yMax(), PinEdge::north);
+      const int s_dist = exitDistance(outline, cx, box.yMin(), PinEdge::south);
+      const int e_dist = exitDistance(outline, box.xMax(), cy, PinEdge::east);
+      const int w_dist = exitDistance(outline, box.xMin(), cy, PinEdge::west);
       const int min_dist = std::min({n_dist, s_dist, w_dist, e_dist});
       if (n_dist == min_dist) {
         n_count += 1;
diff -ru a/src/grt/src/Pin.h b/src/grt/src/Pin.h
--- a/src/grt/src/Pin.h	2026-12-01 06:51:07.193898473 -0500
+++ b/src/grt/src/Pin.h	2026-12-01 06:51:26.622082249 -0500
@@ -70,7 +70,7 @@
   bool isCorePin() const;
 
  private:
-  void determineEdge(const odb::Rect& bounds,
+  void determineEdge(const std::vector<odb::Rect>& outline,
                      const std::vector<odb::dbTechLayer*>& layers);
 
   union
主要言語
Verilog
スター
3.3k
フォーク
1.1k
平均マージ
3日 11時間
マージ済み PR(30日)
247

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

The-OpenROAD-Project/OpenROAD のほかの issue

The-OpenROAD-Project/OpenROAD の issue をすべて見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。