Skip to content

Commit 6138cd3

Browse files
committed
odb: change dbBox::getDir() return type from int to Orientation2D
Signed-off-by: Matt Liberty <[email protected]>
1 parent ec119f0 commit 6138cd3

File tree

11 files changed

+32
-30
lines changed

11 files changed

+32
-30
lines changed

src/dpl/src/PlacementDRC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ odb::Rect transformEdgeRect(const odb::Rect& edge_rect,
3636
odb::Rect getQueryRect(const odb::Rect& edge_box, const int spc)
3737
{
3838
odb::Rect query_rect(edge_box);
39-
bool is_vertical_edge = edge_box.getDir() == 0;
39+
bool is_vertical_edge = edge_box.getDir() == odb::vertical;
4040
if (is_vertical_edge) {
4141
// vertical edge
4242
query_rect = query_rect.bloat(spc, odb::Orientation2D::Horizontal);
@@ -89,7 +89,7 @@ bool PlacementDRC::checkEdgeSpacing(const Node* cell,
8989
+ 1; // +1 to account for EXACT rules
9090
odb::Rect edge1_box = cell_edges::transformEdgeRect(
9191
edge1.getBBox(), cell, x_real, y_real, orient);
92-
bool is_vertical_edge = edge1_box.getDir() == 0;
92+
bool is_vertical_edge = edge1_box.getDir() == odb::vertical;
9393
odb::Rect query_rect = cell_edges::getQueryRect(edge1_box, max_spc);
9494
GridX xMin = grid_->gridX(DbuX(query_rect.xMin()));
9595
GridX xMax = grid_->gridEndX(DbuX(query_rect.xMax()));

src/dpl/src/infrastructure/Grid.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ void Grid::markBlocked(odb::dbBlock* block)
149149
if (routing_level <= 1 || routing_level > 3) { // considering M2, M3
150150
return;
151151
}
152-
if (wire_rect.getDir() == 1) { // horizontal
152+
if (wire_rect.getDir() == odb::horizontal) {
153153
return;
154154
}
155155
wire_rect.moveDelta(-core.xMin(), -core.yMin());

src/drt/src/gc/FlexGC_main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3873,7 +3873,8 @@ void FlexGCWorker::Impl::patchMetalShape_minStep()
38733873
} else {
38743874
continue;
38753875
}
3876-
if (enc_box.getDir() == 1 && markerBBox.yMin() == enc_box.yMin()
3876+
if (enc_box.getDir() == odb::horizontal
3877+
&& markerBBox.yMin() == enc_box.yMin()
38773878
&& markerBBox.yMax() == enc_box.yMax()) {
38783879
int bloating_dist = std::max(0, min_step_length - markerBBox.dx());
38793880
if (markerBBox.xMin() >= enc_box.xMin()
@@ -3885,7 +3886,7 @@ void FlexGCWorker::Impl::patchMetalShape_minStep()
38853886
} else {
38863887
continue;
38873888
}
3888-
} else if (enc_box.getDir() == 0
3889+
} else if (enc_box.getDir() == odb::vertical
38893890
&& markerBBox.xMin() == enc_box.xMin()
38903891
&& markerBBox.xMax() == enc_box.xMax()) {
38913892
int bloating_dist = std::max(0, min_step_length - markerBBox.dy());

src/odb/include/odb/db.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,9 @@ class dbBox : public dbObject
247247
void getViaLayerBoxes(dbTechLayer* layer, std::vector<dbShape>& shapes) const;
248248

249249
///
250-
/// Get the width (xMax-xMin) of the box.
250+
/// Get the orientation of the box.
251251
///
252-
int getDir() const;
252+
Orientation2D getDir() const;
253253

254254
///
255255
/// Get the width (xMax-xMin) of the box.

src/odb/include/odb/geom.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ class Rect
352352

353353
int minDXDY() const;
354354
int maxDXDY() const;
355-
int getDir() const;
355+
Orientation2D getDir() const;
356356

357357
void set_xlo(int x);
358358
void set_xhi(int x);
@@ -669,17 +669,14 @@ inline int Rect::maxDXDY() const
669669
return std::max(dx(), dy());
670670
}
671671

672-
inline int Rect::getDir() const
672+
inline Orientation2D Rect::getDir() const
673673
{
674674
const int DX = dx();
675675
const int DY = dy();
676676
if (DX < DY) {
677-
return 0;
677+
return vertical;
678678
}
679-
if (DX > DY) {
680-
return 1;
681-
}
682-
return -1;
679+
return horizontal;
683680
}
684681

685682
inline void Rect::moveTo(int x, int y)

src/odb/include/odb/isotropy.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class Orientation2D
8787
Orientation2D& operator=(const Orientation2D& other) = default;
8888

8989
constexpr operator Value() const { return static_cast<Value>(value_); }
90+
Value value() const { return static_cast<Value>(value_); } // for swig
9091

9192
// [Horizontal -> Vertical] [Vertical -> Horizontal]
9293
Orientation2D turn_90() const { return Value(value_ ^ 1); }
@@ -289,6 +290,8 @@ inline constexpr Direction2D north{Direction2D::North};
289290
inline constexpr Direction3D down{Direction3D::Down};
290291
inline constexpr Direction3D up{Direction3D::Up};
291292

293+
#ifndef SWIG
292294
using utl::format_as;
295+
#endif
293296

294297
} // namespace odb

src/odb/src/db/dbBox.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ void dbBox::getViaLayerBoxes(dbTechLayer* layer,
535535
}
536536
}
537537

538-
int dbBox::getDir() const
538+
Orientation2D dbBox::getDir() const
539539
{
540540
Rect rect = getBox();
541541
return rect.getDir();

src/odb/src/db/tmg_conn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ void tmg_conn::loadSWire(dbNet* net)
258258
shape.setVia(via, rect);
259259
}
260260
} else {
261-
if (rect.getDir() == 1) {
261+
if (rect.getDir() == horizontal) {
262262
y1 = rect.yCenter();
263263
y2 = y1;
264264
x1 = rect.xMin() + (rect.yMax() - y1);

src/odb/src/swig/common/odb.i

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "odb/dbMap.h"
2020
#include "odb/dbSet.h"
2121
#include "odb/dbTypes.h"
22+
#include "odb/isotropy.h"
2223
#include "odb/geom.h"
2324
#include "odb/wOrder.h"
2425
#include "odb/util.h"
@@ -61,6 +62,7 @@ using namespace odb;
6162
%include "dbtypes.i"
6263
%include "dbtypes_common.i"
6364

65+
%include "odb/isotropy.h"
6466
%include "odb/geom.h"
6567
%include "polygon.i"
6668
%include "odb/db.h"

src/odb/test/gcd_pdn_def_access.tcl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,15 @@ check "wire isVia" {$wire isVia} 0
8282
check "wire width" {$wire getWidth} 340
8383
check "wire length" {$wire getLength} 159980
8484
check "wire shape" {$wire getWireShapeType} FOLLOWPIN
85-
check "wire direction" {$wire getDir} 1 ;# 1 = HORIZONTAL
85+
check "wire direction" {[$wire getDir] value} [$odb::horizontal value]
8686

8787
set wire [lindex $wires 30]
8888
check "wire layer name" {[$wire getTechLayer] getName} metal4
8989
check "wire isVia" {$wire isVia} 0
9090
check "wire width" {$wire getWidth} [expr 179200 - 22400]
9191
check "wire length" {$wire getLength} 960
9292
check "wire shape" {$wire getWireShapeType} STRIPE
93-
check "wire direction" {$wire getDir} 0 ;# 0 = VERTICAL
93+
check "wire direction" {[$wire getDir] value} [$odb::vertical value]
9494

9595
set wire [lindex $wires 34]
9696
check "wire isVia" {$wire isVia} 1
@@ -100,7 +100,7 @@ check "wire block via" {[$wire getBlockVia] getName} via2_960x340
100100
check "wire via xy" {$wire getViaXY} "24140 22400"
101101
check "wire num via boxes" {llength [$wire getViaBoxes 0]} 5 ;# 3 cut shapes + upper and lower metal
102102
# A via doesnt really have a direction, so any vaue is okay here I think
103-
check "wire direction" {$wire getDir} 1
103+
check "wire direction" {[$wire getDir] value} [$odb::horizontal value]
104104

105105
set via [lindex $vias 0]
106106

0 commit comments

Comments
 (0)