Skip to content

Commit ec119f0

Browse files
committed
odb: refactor dbSBox
Signed-off-by: Matt Liberty <[email protected]>
1 parent bfcd6b8 commit ec119f0

File tree

4 files changed

+86
-98
lines changed

4 files changed

+86
-98
lines changed

src/odb/include/odb/db.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -428,37 +428,37 @@ class dbSBox : public dbBox
428428
///
429429
/// Get the shape type of this wire.
430430
///
431-
dbWireShapeType getWireShapeType();
431+
dbWireShapeType getWireShapeType() const;
432432

433433
///
434434
/// Return the specified direction of this segment
435435
///
436-
Direction getDirection();
436+
Direction getDirection() const;
437437

438438
///
439439
/// Get the swire of this shape
440440
///
441-
dbSWire* getSWire();
441+
dbSWire* getSWire() const;
442442

443443
///
444444
/// Get Oct Wire Shape
445445
///
446-
Oct getOct();
446+
Oct getOct() const;
447447

448448
///
449449
/// Get via mask for bottom layer of via
450450
///
451-
uint getViaBottomLayerMask();
451+
uint getViaBottomLayerMask() const;
452452

453453
///
454454
/// Get via mask for cut layer of via
455455
///
456-
uint getViaCutLayerMask();
456+
uint getViaCutLayerMask() const;
457457

458458
///
459459
/// Get via mask for top layer of via
460460
///
461-
uint getViaTopLayerMask();
461+
uint getViaTopLayerMask() const;
462462

463463
///
464464
/// Set via masks
@@ -468,7 +468,7 @@ class dbSBox : public dbBox
468468
///
469469
/// Has via mask
470470
///
471-
bool hasViaLayerMasks();
471+
bool hasViaLayerMasks() const;
472472

473473
///
474474
/// Create a set of new sboxes from a via array

src/odb/src/db/dbBox.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ Point _dbBox::getViaXY() const
390390
default:
391391
break;
392392
}
393+
return {};
393394
}
394395

395396
void _dbBox::checkMask(const int mask) const

src/odb/src/db/dbSBox.cpp

Lines changed: 72 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -130,55 +130,55 @@ bool _dbSBox::operator<(const _dbSBox& rhs) const
130130
//
131131
////////////////////////////////////////////////////////////////////
132132

133-
dbWireShapeType dbSBox::getWireShapeType()
133+
dbWireShapeType dbSBox::getWireShapeType() const
134134
{
135-
_dbSBox* box = (_dbSBox*) this;
135+
const _dbSBox* box = (const _dbSBox*) this;
136136
return dbWireShapeType(box->_sflags._wire_type);
137137
}
138138

139-
dbSBox::Direction dbSBox::getDirection()
139+
dbSBox::Direction dbSBox::getDirection() const
140140
{
141-
_dbSBox* box = (_dbSBox*) this;
141+
const _dbSBox* box = (const _dbSBox*) this;
142142
return (dbSBox::Direction) box->_sflags._direction;
143143
}
144144

145-
dbSWire* dbSBox::getSWire()
145+
dbSWire* dbSBox::getSWire() const
146146
{
147147
return (dbSWire*) getBoxOwner();
148148
}
149149

150-
Oct dbSBox::getOct()
150+
Oct dbSBox::getOct() const
151151
{
152-
_dbSBox* box = (_dbSBox*) this;
152+
const _dbSBox* box = (const _dbSBox*) this;
153153
return box->_shape._oct;
154154
}
155155

156-
uint dbSBox::getViaBottomLayerMask()
156+
uint dbSBox::getViaBottomLayerMask() const
157157
{
158-
_dbSBox* box = (_dbSBox*) this;
158+
const _dbSBox* box = (const _dbSBox*) this;
159159
return box->_sflags._via_bottom_mask;
160160
}
161161

162-
uint dbSBox::getViaCutLayerMask()
162+
uint dbSBox::getViaCutLayerMask() const
163163
{
164-
_dbSBox* box = (_dbSBox*) this;
164+
const _dbSBox* box = (const _dbSBox*) this;
165165
return box->_sflags._via_cut_mask;
166166
}
167167

168-
uint dbSBox::getViaTopLayerMask()
168+
uint dbSBox::getViaTopLayerMask() const
169169
{
170-
_dbSBox* box = (_dbSBox*) this;
170+
const _dbSBox* box = (const _dbSBox*) this;
171171
return box->_sflags._via_top_mask;
172172
}
173173

174-
bool dbSBox::hasViaLayerMasks()
174+
bool dbSBox::hasViaLayerMasks() const
175175
{
176-
_dbSBox* box = (_dbSBox*) this;
176+
const _dbSBox* box = (const _dbSBox*) this;
177177
return box->_sflags._via_bottom_mask != 0 || box->_sflags._via_cut_mask != 0
178178
|| box->_sflags._via_top_mask != 0;
179179
}
180180

181-
void dbSBox::setViaLayerMask(uint bottom, uint cut, uint top)
181+
void dbSBox::setViaLayerMask(const uint bottom, const uint cut, const uint top)
182182
{
183183
_dbSBox* box = (_dbSBox*) this;
184184
box->checkMask(bottom);
@@ -192,31 +192,20 @@ void dbSBox::setViaLayerMask(uint bottom, uint cut, uint top)
192192

193193
dbSBox* dbSBox::create(dbSWire* wire_,
194194
dbTechLayer* layer_,
195-
int x1,
196-
int y1,
197-
int x2,
198-
int y2,
199-
dbWireShapeType type,
200-
Direction dir,
201-
int width)
195+
const int x1,
196+
const int y1,
197+
const int x2,
198+
const int y2,
199+
const dbWireShapeType type,
200+
const Direction dir,
201+
const int width)
202202
{
203203
_dbSWire* wire = (_dbSWire*) wire_;
204204
_dbBlock* block = (_dbBlock*) wire->getOwner();
205205
_dbSBox* box = block->_sbox_tbl->create();
206206

207-
uint dx;
208-
if (x2 > x1) {
209-
dx = x2 - x1;
210-
} else {
211-
dx = x1 - x2;
212-
}
213-
214-
uint dy;
215-
if (y2 > y1) {
216-
dy = y2 - y1;
217-
} else {
218-
dy = y1 - y2;
219-
}
207+
const uint dx = std::abs(x2 - x1);
208+
const uint dy = std::abs(y2 - y1);
220209

221210
switch (dir) {
222211
case UNDEFINED:
@@ -247,8 +236,8 @@ dbSBox* dbSBox::create(dbSWire* wire_,
247236
box->_flags._layer_id = layer_->getImpl()->getOID();
248237
box->_flags._owner_type = dbBoxOwner::SWIRE;
249238
if (dir == OCTILINEAR) {
250-
Point p1(x1, y1);
251-
Point p2(x2, y2);
239+
const Point p1(x1, y1);
240+
const Point p2(x2, y2);
252241
new (&box->_shape._oct) Oct();
253242
box->_shape._oct.init(p1, p2, width);
254243
box->_flags._octilinear = true;
@@ -269,9 +258,9 @@ dbSBox* dbSBox::create(dbSWire* wire_,
269258

270259
dbSBox* dbSBox::create(dbSWire* wire_,
271260
dbVia* via_,
272-
int x,
273-
int y,
274-
dbWireShapeType type)
261+
const int x,
262+
const int y,
263+
const dbWireShapeType type)
275264
{
276265
_dbSWire* wire = (_dbSWire*) wire_;
277266
_dbVia* via = (_dbVia*) via_;
@@ -282,10 +271,10 @@ dbSBox* dbSBox::create(dbSWire* wire_,
282271
}
283272

284273
_dbBox* vbbox = block->_box_tbl->getPtr(via->_bbox);
285-
int xmin = vbbox->_shape._rect.xMin() + x;
286-
int ymin = vbbox->_shape._rect.yMin() + y;
287-
int xmax = vbbox->_shape._rect.xMax() + x;
288-
int ymax = vbbox->_shape._rect.yMax() + y;
274+
const int xmin = vbbox->_shape._rect.xMin() + x;
275+
const int ymin = vbbox->_shape._rect.yMin() + y;
276+
const int xmax = vbbox->_shape._rect.xMax() + x;
277+
const int ymax = vbbox->_shape._rect.yMax() + y;
289278
_dbSBox* box = block->_sbox_tbl->create();
290279
box->_flags._owner_type = dbBoxOwner::SWIRE;
291280
box->_shape._rect.init(xmin, ymin, xmax, ymax);
@@ -302,9 +291,9 @@ dbSBox* dbSBox::create(dbSWire* wire_,
302291

303292
dbSBox* dbSBox::create(dbSWire* wire_,
304293
dbTechVia* via_,
305-
int x,
306-
int y,
307-
dbWireShapeType type)
294+
const int x,
295+
const int y,
296+
const dbWireShapeType type)
308297
{
309298
_dbSWire* wire = (_dbSWire*) wire_;
310299
_dbTechVia* via = (_dbTechVia*) via_;
@@ -316,10 +305,10 @@ dbSBox* dbSBox::create(dbSWire* wire_,
316305

317306
_dbTech* tech = (_dbTech*) via->getOwner();
318307
_dbBox* vbbox = tech->_box_tbl->getPtr(via->_bbox);
319-
int xmin = vbbox->_shape._rect.xMin() + x;
320-
int ymin = vbbox->_shape._rect.yMin() + y;
321-
int xmax = vbbox->_shape._rect.xMax() + x;
322-
int ymax = vbbox->_shape._rect.yMax() + y;
308+
const int xmin = vbbox->_shape._rect.xMin() + x;
309+
const int ymin = vbbox->_shape._rect.yMin() + y;
310+
const int xmax = vbbox->_shape._rect.xMax() + x;
311+
const int ymax = vbbox->_shape._rect.yMax() + y;
323312
_dbSBox* box = block->_sbox_tbl->create();
324313
box->_flags._owner_type = dbBoxOwner::SWIRE;
325314
box->_shape._rect.init(xmin, ymin, xmax, ymax);
@@ -417,4 +406,35 @@ std::vector<dbSBox*> dbSBox::smashVia()
417406
return new_boxes;
418407
}
419408

409+
_dbSBox::_dbSBox(_dbDatabase* db, const _dbSBox& b)
410+
: _dbBox(db, b), _sflags(b._sflags)
411+
{
412+
}
413+
414+
_dbSBox::_dbSBox(_dbDatabase* db) : _dbBox(db)
415+
{
416+
_sflags._wire_type = dbWireShapeType::COREWIRE;
417+
_sflags._direction = 0;
418+
_sflags._via_bottom_mask = 0;
419+
_sflags._via_cut_mask = 0;
420+
_sflags._via_top_mask = 0;
421+
_sflags._spare_bits = 0;
422+
}
423+
424+
dbOStream& operator<<(dbOStream& stream, const _dbSBox& box)
425+
{
426+
stream << (_dbBox&) box;
427+
uint* bit_field = (uint*) &box._sflags;
428+
stream << *bit_field;
429+
return stream;
430+
}
431+
432+
dbIStream& operator>>(dbIStream& stream, _dbSBox& box)
433+
{
434+
stream >> (_dbBox&) box;
435+
uint* bit_field = (uint*) &box._sflags;
436+
stream >> *bit_field;
437+
return stream;
438+
}
439+
420440
} // namespace odb

src/odb/src/db/dbSBox.h

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -30,52 +30,19 @@ struct _dbSBoxFlags
3030
class _dbSBox : public _dbBox
3131
{
3232
public:
33-
// PERSISTANT-MEMBERS
34-
_dbSBoxFlags _sflags;
35-
3633
_dbSBox(_dbDatabase*, const _dbSBox& b);
3734
_dbSBox(_dbDatabase*);
38-
~_dbSBox();
3935

4036
bool operator==(const _dbSBox& rhs) const;
4137
bool operator!=(const _dbSBox& rhs) const { return !operator==(rhs); }
4238
bool operator<(const _dbSBox& rhs) const;
4339
int equal(const _dbSBox& rhs) const;
44-
};
45-
46-
inline _dbSBox::_dbSBox(_dbDatabase* db, const _dbSBox& b)
47-
: _dbBox(db, b), _sflags(b._sflags)
48-
{
49-
}
50-
51-
inline _dbSBox::_dbSBox(_dbDatabase* db) : _dbBox(db)
52-
{
53-
_sflags._wire_type = dbWireShapeType::COREWIRE;
54-
_sflags._direction = 0;
55-
_sflags._via_bottom_mask = 0;
56-
_sflags._via_cut_mask = 0;
57-
_sflags._via_top_mask = 0;
58-
_sflags._spare_bits = 0;
59-
}
6040

61-
inline _dbSBox::~_dbSBox()
62-
{
63-
}
64-
65-
inline dbOStream& operator<<(dbOStream& stream, const _dbSBox& box)
66-
{
67-
stream << (_dbBox&) box;
68-
uint* bit_field = (uint*) &box._sflags;
69-
stream << *bit_field;
70-
return stream;
71-
}
41+
// PERSISTANT-MEMBERS
42+
_dbSBoxFlags _sflags;
43+
};
7244

73-
inline dbIStream& operator>>(dbIStream& stream, _dbSBox& box)
74-
{
75-
stream >> (_dbBox&) box;
76-
uint* bit_field = (uint*) &box._sflags;
77-
stream >> *bit_field;
78-
return stream;
79-
}
45+
dbOStream& operator<<(dbOStream& stream, const _dbSBox& box);
46+
dbIStream& operator>>(dbIStream& stream, _dbSBox& box);
8047

8148
} // namespace odb

0 commit comments

Comments
 (0)