Skip to content

Commit 96f312d

Browse files
committed
ifp: Check -gap value is positive.
Signed-off-by: Christian COSTA <christian.costa@st.com>
1 parent 85aba71 commit 96f312d

3 files changed

Lines changed: 32 additions & 8 deletions

File tree

src/ifp/include/ifp/InitFloorplan.hh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#pragma once
55

6+
#include <cstdint>
7+
#include <limits>
68
#include <set>
79
#include <string>
810
#include <vector>
@@ -51,7 +53,7 @@ class InitFloorplan
5153
const std::vector<odb::dbSite*>& additional_sites = {},
5254
RowParity row_parity = RowParity::NONE,
5355
const std::set<odb::dbSite*>& flipped_sites = {},
54-
int gap = -1);
56+
int gap = std::numeric_limits<std::int32_t>::min());
5557

5658
// The base_site determines the single-height rows. For hybrid rows it is
5759
// a site containing a row pattern.
@@ -61,7 +63,7 @@ class InitFloorplan
6163
const std::vector<odb::dbSite*>& additional_sites = {},
6264
RowParity row_parity = RowParity::NONE,
6365
const std::set<odb::dbSite*>& flipped_sites = {},
64-
int gap = -1);
66+
int gap = std::numeric_limits<std::int32_t>::min());
6567

6668
void insertTiecells(odb::dbMTerm* tie_term,
6769
const std::string& prefix = "TIEOFF_");
@@ -92,7 +94,7 @@ class InitFloorplan
9294
= {},
9395
RowParity row_parity = RowParity::NONE,
9496
const std::set<odb::dbSite*>& flipped_sites = {},
95-
int gap = -1);
97+
int gap = std::numeric_limits<std::int32_t>::min());
9698

9799
// The base_site determines the single-height rows. For hybrid rows it is
98100
// a site containing a row pattern.
@@ -101,15 +103,15 @@ class InitFloorplan
101103
const std::vector<odb::dbSite*>& additional_sites = {},
102104
RowParity row_parity = RowParity::NONE,
103105
const std::set<odb::dbSite*>& flipped_sites = {},
104-
int gap = -1);
106+
int gap = std::numeric_limits<std::int32_t>::min());
105107

106108
// Create rows for a polygon core area using true polygon-aware generation
107109
void makePolygonRows(const odb::Polygon& core_polygon,
108110
odb::dbSite* base_site,
109111
const std::vector<odb::dbSite*>& additional_sites = {},
110112
RowParity row_parity = RowParity::NONE,
111113
const std::set<odb::dbSite*>& flipped_sites = {},
112-
int gap = -1);
114+
int gap = std::numeric_limits<std::int32_t>::min());
113115

114116
void makeTracks();
115117
void makeTracks(odb::dbTechLayer* layer,
@@ -178,6 +180,8 @@ class InitFloorplan
178180
// this is a set of sets of all constructed site ids.
179181
std::set<std::set<int>> constructed_patterns_;
180182
std::vector<std::vector<odb::dbSite*>> repeating_row_patterns_;
183+
184+
void checkGap(int gap);
181185
};
182186

183187
} // namespace ifp

src/ifp/src/InitFloorplan.cc

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <algorithm>
77
#include <cmath>
88
#include <cstddef>
9+
#include <cstdint>
910
#include <limits>
1011
#include <map>
1112
#include <set>
@@ -88,6 +89,13 @@ InitFloorplan::InitFloorplan(dbBlock* block,
8889
{
8990
}
9091

92+
void InitFloorplan::checkGap(const int gap)
93+
{
94+
if (gap != std::numeric_limits<int32_t>::min() && gap <= 0) {
95+
logger_->error(IFP, 36, "Gap must be positive ({})", gap);
96+
}
97+
}
98+
9199
void InitFloorplan::initFloorplan(
92100
double utilization,
93101
double aspect_ratio,
@@ -101,6 +109,8 @@ void InitFloorplan::initFloorplan(
101109
const std::set<odb::dbSite*>& flipped_sites,
102110
const int gap)
103111
{
112+
checkGap(gap);
113+
104114
makeDieUtilization(utilization,
105115
aspect_ratio,
106116
core_space_bottom,
@@ -129,6 +139,8 @@ void InitFloorplan::initFloorplan(
129139
const std::set<odb::dbSite*>& flipped_sites,
130140
const int gap)
131141
{
142+
checkGap(gap);
143+
132144
makeDie(die);
133145
makeRows(core, base_site, additional_sites, row_parity, flipped_sites, gap);
134146
}
@@ -212,6 +224,8 @@ void InitFloorplan::makePolygonRows(
212224
const std::set<odb::dbSite*>& flipped_sites,
213225
const int gap)
214226
{
227+
checkGap(gap);
228+
215229
auto points = core_polygon.getPoints();
216230

217231
if (points.empty()) {
@@ -344,6 +358,8 @@ void InitFloorplan::makeRowsWithSpacing(
344358
const std::set<odb::dbSite*>& flipped_sites,
345359
const int gap)
346360
{
361+
checkGap(gap);
362+
347363
odb::Rect block_die_area = block_->getDieArea();
348364
if (block_die_area.area() == 0) {
349365
logger_->error(IFP, 64, "Floorplan die area is 0. Cannot build rows.");
@@ -381,6 +397,8 @@ void InitFloorplan::makeRows(const odb::Rect& core,
381397
const std::set<odb::dbSite*>& flipped_sites,
382398
const int gap)
383399
{
400+
checkGap(gap);
401+
384402
odb::Rect block_die_area = block_->getDieArea();
385403
if (block_die_area.area() == 0) {
386404
logger_->error(IFP, 63, "Floorplan die area is 0. Cannot build rows.");
@@ -522,7 +540,9 @@ void InitFloorplan::updateVoltageDomain(const int core_lx,
522540
}
523541
}
524542
// Default space is 6 times the minimum site height
525-
const int power_domain_y_space = (gap == -1) ? 6 * min_site_dy : gap;
543+
const int power_domain_y_space
544+
= (gap == std::numeric_limits<int32_t>::min()) ? 6 * min_site_dy
545+
: gap;
526546

527547
row_itr = rows.begin();
528548
for (int row_processed = 0; row_processed < total_row_count;

src/ifp/src/InitFloorplan.tcl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ proc make_rows_helper { key_array } {
111111
}
112112

113113
# Get gap space
114-
set gap -1
114+
set gap [expr -(2 ** 31)]
115115
if { [info exists keys(-gap)] } {
116116
set gap [ord::microns_to_dbu $keys(-gap)]
117117
}
@@ -450,7 +450,7 @@ proc make_polygon_rows_helper { key_array } {
450450
}
451451

452452
# Get gap space
453-
set gap -1
453+
set gap [expr -(2 ** 31)]
454454
if { [info exists keys(-gap)] } {
455455
set gap [ord::microns_to_dbu $keys(-gap)]
456456
}

0 commit comments

Comments
 (0)