Skip to content

Commit 663acb0

Browse files
authored
Merge pull request #8920 from The-OpenROAD-Project-staging/odb-refactor
Odb refactor dbBox/dbSBox
2 parents 90d89cf + a47a96c commit 663acb0

33 files changed

+696
-735
lines changed

src/dpl/src/PlacementDRC.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "odb/dbTransform.h"
1414
#include "odb/dbTypes.h"
1515
#include "odb/geom.h"
16+
#include "odb/isotropy.h"
1617

1718
namespace dpl {
1819

@@ -36,7 +37,7 @@ odb::Rect transformEdgeRect(const odb::Rect& edge_rect,
3637
odb::Rect getQueryRect(const odb::Rect& edge_box, const int spc)
3738
{
3839
odb::Rect query_rect(edge_box);
39-
bool is_vertical_edge = edge_box.getDir() == 0;
40+
bool is_vertical_edge = edge_box.getDir() == odb::vertical;
4041
if (is_vertical_edge) {
4142
// vertical edge
4243
query_rect = query_rect.bloat(spc, odb::Orientation2D::Horizontal);
@@ -89,7 +90,7 @@ bool PlacementDRC::checkEdgeSpacing(const Node* cell,
8990
+ 1; // +1 to account for EXACT rules
9091
odb::Rect edge1_box = cell_edges::transformEdgeRect(
9192
edge1.getBBox(), cell, x_real, y_real, orient);
92-
bool is_vertical_edge = edge1_box.getDir() == 0;
93+
bool is_vertical_edge = edge1_box.getDir() == odb::vertical;
9394
odb::Rect query_rect = cell_edges::getQueryRect(edge1_box, max_spc);
9495
GridX xMin = grid_->gridX(DbuX(query_rect.xMin()));
9596
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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "gc/FlexGC_impl.h"
2222
#include "odb/dbTypes.h"
2323
#include "odb/geom.h"
24+
#include "odb/isotropy.h"
2425

2526
using odb::dbTechLayerType;
2627

@@ -3873,7 +3874,8 @@ void FlexGCWorker::Impl::patchMetalShape_minStep()
38733874
} else {
38743875
continue;
38753876
}
3876-
if (enc_box.getDir() == 1 && markerBBox.yMin() == enc_box.yMin()
3877+
if (enc_box.getDir() == odb::horizontal
3878+
&& markerBBox.yMin() == enc_box.yMin()
38773879
&& markerBBox.yMax() == enc_box.yMax()) {
38783880
int bloating_dist = std::max(0, min_step_length - markerBBox.dx());
38793881
if (markerBBox.xMin() >= enc_box.xMin()
@@ -3885,7 +3887,7 @@ void FlexGCWorker::Impl::patchMetalShape_minStep()
38853887
} else {
38863888
continue;
38873889
}
3888-
} else if (enc_box.getDir() == 0
3890+
} else if (enc_box.getDir() == odb::vertical
38893891
&& markerBBox.xMin() == enc_box.xMin()
38903892
&& markerBBox.xMax() == enc_box.xMax()) {
38913893
int bloating_dist = std::max(0, min_step_length - markerBBox.dy());

src/drt/src/io/io.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -958,9 +958,7 @@ void io::Parser::updateNetRouting(frNet* netIn, odb::dbNet* net)
958958
== getTech()->name2via_.end()) {
959959
logger_->error(DRT, 109, "Unsupported via in db.");
960960
} else {
961-
int x, y;
962-
box->getViaXY(x, y);
963-
odb::Point p(x, y);
961+
const odb::Point p = box->getViaXY();
964962
auto viaDef = getTech()->name2via_[viaName];
965963
auto tmpP = std::make_unique<frVia>(viaDef);
966964
tmpP->setOrigin(p);
@@ -2666,11 +2664,10 @@ void io::Parser::setMasters(odb::dbDatabase* db)
26662664
master->getName(),
26672665
_term->getName());
26682666
}
2669-
int x, y;
2670-
box->getViaXY(x, y);
2667+
const odb::Point pt = box->getViaXY();
26712668
auto viaDef = getTech()->name2via_[box->getTechVia()->getName()];
26722669
auto tmpP = std::make_unique<frVia>(viaDef);
2673-
tmpP->setOrigin({x, y});
2670+
tmpP->setOrigin(pt);
26742671
// layer1 rect
26752672
addPinFig(
26762673
tmpP->getLayer1BBox(), viaDef->getLayer1Num(), pinIn.get());

src/odb/include/odb/db.h

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -192,74 +192,69 @@ class dbBox : public dbObject
192192
///
193193
/// Get the lower coordinate.
194194
///
195-
int xMin();
195+
int xMin() const;
196196

197197
///
198198
/// Get the lower y coordinate.
199199
///
200-
int yMin();
200+
int yMin() const;
201201

202202
///
203203
/// Get the high x coordinate.
204204
///
205-
int xMax();
205+
int xMax() const;
206206

207207
///
208208
/// Get the high y coordinate.
209209
///
210-
int yMax();
210+
int yMax() const;
211211

212212
///
213213
/// Returns true if this box represents a via
214214
///
215-
bool isVia();
215+
bool isVia() const;
216216

217217
///
218218
/// Get tech-via this box represents.
219219
/// returns nullptr if this box does not represent a tech-via
220220
///
221-
dbTechVia* getTechVia();
221+
dbTechVia* getTechVia() const;
222222

223223
///
224224
/// Get block-via this box represents.
225225
/// returns nullptr if this box does not represent a block-via
226226
///
227-
dbVia* getBlockVia();
228-
229-
///
230-
/// Return the placed location of this via.
231-
///
232-
void getViaXY(int& x, int& y);
227+
dbVia* getBlockVia() const;
233228

234229
///
235230
/// Return the placed location of this via.
236231
///
237-
Point getViaXY();
232+
Point getViaXY() const;
238233

239234
///
240235
/// Get the box bounding points.
241236
///
242-
Rect getBox();
237+
Rect getBox() const;
243238

244239
///
245240
/// Get the translated boxes of this via
246241
///
247-
void getViaBoxes(std::vector<dbShape>& shapes);
242+
void getViaBoxes(std::vector<dbShape>& shapes) const;
248243

249244
///
250245
/// Get the translated boxes of this via on the given layer
251246
///
252-
void getViaLayerBoxes(dbTechLayer* layer, std::vector<dbShape>& shapes);
247+
void getViaLayerBoxes(dbTechLayer* layer, std::vector<dbShape>& shapes) const;
253248

254249
///
255-
/// Get the width (xMax-xMin) of the box.
250+
/// Get the orientation of the box.
256251
///
257-
int getDir();
252+
Orientation2D getDir() const;
258253

259254
///
260255
/// Get the width (xMax-xMin) of the box.
261256
///
262-
uint getDX();
257+
uint getDX() const;
263258

264259
int getDesignRuleWidth() const;
265260

@@ -268,25 +263,25 @@ class dbBox : public dbObject
268263
///
269264
/// Get the height (yMax-yMin) of the box.
270265
///
271-
uint getDY();
272-
uint getWidth(uint dir = 1);
273-
uint getLength(uint dir = 1);
266+
uint getDY() const;
267+
uint getWidth(uint dir = 1) const;
268+
uint getLength(uint dir = 1) const;
274269

275270
///
276271
/// Set temporary flag visited
277272
///
278273
void setVisited(bool value);
279-
bool isVisited();
274+
bool isVisited() const;
280275

281276
///
282277
/// Get the owner of this box
283278
///
284-
dbObject* getBoxOwner();
279+
dbObject* getBoxOwner() const;
285280

286281
///
287282
/// Get the owner type of this box
288283
///
289-
dbBoxOwner getOwnerType();
284+
dbBoxOwner getOwnerType() const;
290285

291286
///
292287
/// Get the layer of this box.
@@ -300,13 +295,13 @@ class dbBox : public dbObject
300295
/// These bboxes have no layer.
301296
/// All dbBox(s) that represent VIA's.
302297
///
303-
dbTechLayer* getTechLayer();
298+
dbTechLayer* getTechLayer() const;
304299

305300
///
306301
/// Get the layer mask assigned to this box.
307302
/// Returns 0 is not assigned or bbox has no layer
308303
///
309-
uint getLayerMask();
304+
uint getLayerMask() const;
310305

311306
///
312307
/// Sets the layer mask for this box.
@@ -433,37 +428,37 @@ class dbSBox : public dbBox
433428
///
434429
/// Get the shape type of this wire.
435430
///
436-
dbWireShapeType getWireShapeType();
431+
dbWireShapeType getWireShapeType() const;
437432

438433
///
439434
/// Return the specified direction of this segment
440435
///
441-
Direction getDirection();
436+
Direction getDirection() const;
442437

443438
///
444439
/// Get the swire of this shape
445440
///
446-
dbSWire* getSWire();
441+
dbSWire* getSWire() const;
447442

448443
///
449444
/// Get Oct Wire Shape
450445
///
451-
Oct getOct();
446+
Oct getOct() const;
452447

453448
///
454449
/// Get via mask for bottom layer of via
455450
///
456-
uint getViaBottomLayerMask();
451+
uint getViaBottomLayerMask() const;
457452

458453
///
459454
/// Get via mask for cut layer of via
460455
///
461-
uint getViaCutLayerMask();
456+
uint getViaCutLayerMask() const;
462457

463458
///
464459
/// Get via mask for top layer of via
465460
///
466-
uint getViaTopLayerMask();
461+
uint getViaTopLayerMask() const;
467462

468463
///
469464
/// Set via masks
@@ -473,7 +468,7 @@ class dbSBox : public dbBox
473468
///
474469
/// Has via mask
475470
///
476-
bool hasViaLayerMasks();
471+
bool hasViaLayerMasks() const;
477472

478473
///
479474
/// Create a set of new sboxes from a via array

src/odb/include/odb/dbShape.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ class dbInstShapeItr
364364
dbTechVia* _via;
365365
dbSet<dbBox> _via_boxes;
366366
dbSet<dbBox>::iterator _via_box_itr;
367-
int _via_x;
368-
int _via_y;
367+
Point _via_pt;
369368
bool _expand_vias;
370369
int _prev_state;
371370

@@ -399,8 +398,7 @@ class dbITermShapeItr
399398
dbTechVia* _via;
400399
dbSet<dbBox> _via_boxes;
401400
dbSet<dbBox>::iterator _via_box_itr;
402-
int _via_x;
403-
int _via_y;
401+
Point _via_pt;
404402
bool _expand_vias;
405403

406404
void getShape(dbBox* box, dbShape& shape);

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/dbBPin.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ void dbBPin::destroy(dbBPin* bpin_)
251251
dbId<_dbBox> nextBox = bpin->_boxes;
252252
while (nextBox) {
253253
_dbBox* b = block->_box_tbl->getPtr(nextBox);
254-
nextBox = b->_next_box;
254+
nextBox = b->next_box_;
255255
dbProperty::destroyProperties(b);
256-
block->remove_rect(b->_shape._rect);
256+
block->remove_rect(b->shape_.rect);
257257
block->_box_tbl->destroy(b);
258258
}
259259

@@ -294,7 +294,7 @@ void _dbBPin::removeBox(_dbBox* box)
294294
dbId<_dbBox> boxid = box->getOID();
295295
if (boxid == _boxes) {
296296
// at head of list, need to move head
297-
_boxes = box->_next_box;
297+
_boxes = box->next_box_;
298298
} else {
299299
// in the middle of the list, need to iterate and relink
300300
dbId<_dbBox> id = _boxes;
@@ -303,10 +303,10 @@ void _dbBPin::removeBox(_dbBox* box)
303303
}
304304
while (id != 0) {
305305
_dbBox* nbox = block->_box_tbl->getPtr(id);
306-
dbId<_dbBox> nid = nbox->_next_box;
306+
dbId<_dbBox> nid = nbox->next_box_;
307307

308308
if (nid == boxid) {
309-
nbox->_next_box = box->_next_box;
309+
nbox->next_box_ = box->next_box_;
310310
break;
311311
}
312312

0 commit comments

Comments
 (0)