Skip to content

Commit c2d8a68

Browse files
authored
Merge pull request #10570 from gadfort/odb-areas
odb: convert areas from double/int/uint to int64_t
2 parents f8ecbda + 4c2f57f commit c2d8a68

39 files changed

Lines changed: 240 additions & 104 deletions

src/dbSta/src/IpChecker.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -660,7 +660,6 @@ void IpChecker::checkPinMinDimensions(odb::dbMaster* master)
660660
void IpChecker::checkPinMinArea(odb::dbMaster* master)
661661
{
662662
std::string master_name = master->getName();
663-
int dbu_per_micron = db_->getTech()->getDbUnitsPerMicron();
664663

665664
for (odb::dbMTerm* mterm : master->getMTerms()) {
666665
for (odb::dbMPin* mpin : mterm->getMPins()) {
@@ -670,10 +669,8 @@ void IpChecker::checkPinMinArea(odb::dbMaster* master)
670669
continue;
671670
}
672671

673-
// getArea() returns microns^2, convert to DBU^2
674-
double min_area_um2 = layer->getArea();
675-
int64_t min_area_dbu2 = static_cast<int64_t>(
676-
min_area_um2 * dbu_per_micron * dbu_per_micron);
672+
// getArea() returns DBU^2
673+
const int64_t min_area_dbu2 = layer->getArea();
677674

678675
odb::Rect rect = box->getBox();
679676
int64_t shape_area

src/drt/src/io/io.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,8 +2167,7 @@ void io::Parser::addRoutingLayer(odb::dbTechLayer* layer)
21672167
setRoutingLayerProperties(layer, tmpLayer);
21682168
// read minArea rule
21692169
if (layer->hasArea()) {
2170-
frCoord minArea = frCoord(round(layer->getArea() * getTech()->getDBUPerUU()
2171-
* getTech()->getDBUPerUU()));
2170+
frCoord minArea = frCoord(layer->getArea());
21722171
std::unique_ptr<frConstraint> uCon
21732172
= std::make_unique<frAreaConstraint>(minArea);
21742173
auto rptr = static_cast<frAreaConstraint*>(uCon.get());
@@ -2226,7 +2225,7 @@ void io::Parser::addRoutingLayer(odb::dbTechLayer* layer)
22262225
"minEnclosedArea constraint with width is not supported, skipped.");
22272226
continue;
22282227
}
2229-
frUInt4 _minEnclosedArea;
2228+
int64_t _minEnclosedArea;
22302229
rule->getEnclosure(_minEnclosedArea);
22312230
frCoord minEnclosedArea = _minEnclosedArea;
22322231
auto minEnclosedAreaConstraint

src/grt/src/cugr/src/Layers.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ MetalLayer::MetalLayer(odb::dbTechLayer* tech_layer,
2626

2727
// Design rules not parsed thoroughly
2828
// Min area
29-
const int database_unit = tech_layer->getTech()->getDbUnitsPerMicron();
30-
const int min_area = tech_layer->getArea() * database_unit * database_unit;
31-
min_length_ = std::max(min_area / width_ - width_, 0);
29+
const int64_t min_area = tech_layer->getArea();
30+
min_length_ = std::max(static_cast<int>(min_area / width_) - width_, 0);
3231

3332
// Parallel run spacing
3433
std::vector<std::vector<uint32_t>> spacing_table;

src/gui/src/dbDescriptors.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,9 +3035,9 @@ Descriptor::Properties DbTechLayerDescriptor::getDBProperties(
30353035
Property::convert_dbu(layer->getSpacing(), true));
30363036
}
30373037
if (layer->hasArea()) {
3038-
props.emplace_back(
3039-
"Minimum area",
3040-
convertUnits(layer->getArea() * 1e-6 * 1e-6, true) + "");
3038+
const double dbu_per_meter = db_->getDbuPerMicron() * 1e6;
3039+
const double area = layer->getArea() / (dbu_per_meter * dbu_per_meter);
3040+
props.emplace_back("Minimum area", convertUnits(area, true) + "");
30413041
}
30423042
if (layer->getResistance() != 0.0) {
30433043
props.emplace_back("Resistance",

src/odb/include/odb/db.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6507,7 +6507,7 @@ class dbTechLayerSpacingRule : public dbObject
65076507
bool getCutCenterToCenter() const;
65086508
bool getCutSameNet() const;
65096509
bool getCutParallelOverlap() const;
6510-
uint32_t getCutArea() const;
6510+
int64_t getCutArea() const;
65116511

65126512
void setSameNetPgOnly(bool pgonly);
65136513
bool getSameNetPgOnly();
@@ -6528,7 +6528,7 @@ class dbTechLayerSpacingRule : public dbObject
65286528
void setCutCenterToCenter(bool c2c);
65296529
void setCutSameNet(bool same_net);
65306530
void setCutParallelOverlap(bool overlap);
6531-
void setCutArea(uint32_t area);
6531+
void setCutArea(int64_t area);
65326532
void setEol(uint32_t width,
65336533
uint32_t within,
65346534
bool parallelEdge,
@@ -6591,8 +6591,8 @@ class dbTechMinCutRule : public dbObject
65916591
class dbTechMinEncRule : public dbObject
65926592
{
65936593
public:
6594-
bool getEnclosure(uint32_t& area) const;
6595-
void setEnclosure(uint32_t area);
6594+
bool getEnclosure(int64_t& area) const;
6595+
void setEnclosure(int64_t area);
65966596
bool getEnclosureWidth(uint32_t& width) const;
65976597
void setEnclosureWidth(uint32_t width);
65986598

@@ -9437,8 +9437,8 @@ class dbTechLayer : public dbObject
94379437
/// reasonable default exists.
94389438
///
94399439
bool hasArea() const;
9440-
double getArea() const;
9441-
void setArea(double area);
9440+
int64_t getArea() const;
9441+
void setArea(int64_t area);
94429442

94439443
///
94449444
/// Get/set MAXWIDTH parameter. This interface is used when a
@@ -9576,9 +9576,9 @@ class dbTechLayer : public dbObject
95769576
class dbTechLayerAreaRule : public dbObject
95779577
{
95789578
public:
9579-
void setArea(int area);
9579+
void setArea(int64_t area);
95809580

9581-
int getArea() const;
9581+
int64_t getArea() const;
95829582

95839583
void setExceptMinWidth(int except_min_width);
95849584

@@ -10115,9 +10115,9 @@ class dbTechLayerCutSpacingRule : public dbObject
1011510115

1011610116
uint32_t getParLength() const;
1011710117

10118-
void setCutArea(int cut_area);
10118+
void setCutArea(int64_t cut_area);
1011910119

10120-
int getCutArea() const;
10120+
int64_t getCutArea() const;
1012110121

1012210122
void setCenterToCenter(bool center_to_center);
1012310123

@@ -10737,9 +10737,9 @@ class dbTechLayerMinCutRule : public dbObject
1073710737

1073810738
int getLengthWithinDist() const;
1073910739

10740-
void setArea(int area);
10740+
void setArea(int64_t area);
1074110741

10742-
int getArea() const;
10742+
int64_t getArea() const;
1074310743

1074410744
void setAreaWithinDist(int area_within_dist);
1074510745

src/odb/include/odb/dbStream.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ class dbOStream
7373
return *this;
7474
}
7575

76+
dbOStream& operator<<(int64_t c)
77+
{
78+
writeValueAsBytes(c);
79+
return *this;
80+
}
81+
7682
dbOStream& operator<<(uint64_t c)
7783
{
7884
writeValueAsBytes(c);
@@ -316,6 +322,12 @@ class dbIStream
316322
return *this;
317323
}
318324

325+
dbIStream& operator>>(int64_t& c)
326+
{
327+
f_.read(reinterpret_cast<char*>(&c), sizeof(c));
328+
return *this;
329+
}
330+
319331
dbIStream& operator>>(uint64_t& c)
320332
{
321333
f_.read(reinterpret_cast<char*>(&c), sizeof(c));

src/odb/include/odb/lefin.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ class lefinReader
5555
// convert distance value to db-units
5656
int dbdist(double value) { return lround(value * dist_factor_); }
5757

58+
// convert area value to squared db-units
59+
int64_t dbarea(const double value) { return llround(value * area_factor_); }
60+
5861
enum AntennaType
5962
{
6063
ANTENNA_INPUT_GATE_AREA,
@@ -172,9 +175,6 @@ class lefinReader
172175
void init();
173176
void setDBUPerMicron(int dbu);
174177

175-
// convert area value to squared db-units
176-
int dbarea(const double value) { return lround(value * area_factor_); }
177-
178178
bool readLefInner(const char* lef_file);
179179
bool readLef(const char* lef_file);
180180
bool addGeoms(dbObject* object,
@@ -225,6 +225,9 @@ class lefin
225225
// convert distance value to db-units
226226
int dbdist(double value);
227227

228+
// convert area value to db-units^2
229+
int64_t dbarea(double value);
230+
228231
// Create a technology from the tech-data of this LEF file.
229232
dbTech* createTech(const char* name, const char* lef_file);
230233

src/odb/include/odb/lefout.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class lefout
4646
{
4747
public:
4848
double lefdist(int value) { return value * dist_factor_; }
49-
double lefarea(int value) { return value * area_factor_; }
49+
double lefarea(int64_t value) { return value * area_factor_; }
5050

5151
lefout(utl::Logger* logger, std::ostream& out) : _out(out)
5252
{

src/odb/src/codeGenerator/gen.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
STD_TYPE_HDR = {
3333
"int16_t": "cstdint",
3434
"uint32_t": "cstdint",
35+
"int64_t": "cstdint",
3536
"pair": "utility",
3637
}
3738

src/odb/src/codeGenerator/helper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"std::string",
2626
"uint32_t",
2727
"uint8_t",
28+
"int64_t",
2829
}
2930

3031
# Value structs that are comparison leaves in components() but are not scalars.
@@ -60,8 +61,9 @@
6061
"uint8_t",
6162
"uint16_t",
6263
"uint32_t",
63-
"uint64_t",
6464
"size_t",
65+
"uint64_t",
66+
"int64_t",
6567
}
6668

6769
_removable = {"const", "static", "unsigned"}

0 commit comments

Comments
 (0)