Skip to content

Commit b7399ed

Browse files
authored
Merge pull request #8673 from titan73/gap_check
ifp: Check -gap value is positive.
2 parents c8a6603 + ccacee9 commit b7399ed

6 files changed

Lines changed: 90 additions & 10 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
}

src/ifp/test/init_floorplan_gap.ok

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
[INFO ODB-0227] LEF file: Nangate45/Nangate45.lef, created 22 layers, 27 vias, 135 library cells
22
[INFO ODB-0227] LEF file: init_floorplan_gap.lef
3+
[ERROR IFP-0036] Gap must be positive (-2000)
4+
[ERROR IFP-0036] Gap must be positive (0)
5+
[ERROR IFP-0036] Gap must be positive (-2000)
6+
[ERROR IFP-0036] Gap must be positive (0)
37
[INFO IFP-0001] Added 71 rows of 526 site FreePDK45_38x28_10R_NP_162NW_34O.
48
[INFO IFP-0001] Added 35 rows of 526 site FreePDK45_38x28_10R_NP_162NW_34O_DoubleHeight.
59
No differences found.

src/ifp/test/init_floorplan_gap.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,33 @@
2323
floorplan = design.getFloorplan()
2424
site = floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O")
2525
additional_site = floorplan.findSite("FreePDK45_38x28_10R_NP_162NW_34O_DoubleHeight")
26+
27+
# Test non positive gap
28+
try:
29+
floorplan.initFloorplan(
30+
die, core, site, [additional_site], "NONE", [], design.micronToDBU(-1)
31+
)
32+
except Exception:
33+
pass
34+
try:
35+
floorplan.initFloorplan(
36+
die, core, site, [additional_site], "NONE", [], design.micronToDBU(0)
37+
)
38+
except Exception:
39+
pass
40+
try:
41+
floorplan.makeRows(core, site, [], "NONE", [], design.micronToDBU(-1))
42+
except Exception:
43+
pass
44+
try:
45+
floorplan.makeRows(core, site, [], "NONE", [], design.micronToDBU(0))
46+
except Exception:
47+
pass
48+
2649
floorplan.initFloorplan(
2750
die, core, site, [additional_site], "NONE", [], design.micronToDBU(2)
2851
)
52+
2953
def_file = helpers.make_result_file("init_floorplan_gap.def")
3054
design.writeDef(def_file)
3155
helpers.diff_files("init_floorplan_gap.defok", def_file)

src/ifp/test/init_floorplan_gap.tcl

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,37 @@ read_lef init_floorplan_gap.lef
55
read_liberty Nangate45/Nangate45_typ.lib
66
read_verilog reg1.v
77
link_design top
8+
9+
set area {0 0 100 100}
10+
811
create_voltage_domain TEMP_ANALOG -area {34 34 66 66}
9-
initialize_floorplan -die_area {0 0 100 100} \
10-
-core_area {0 0 100 100} \
12+
13+
# Test non positive gap
14+
catch {
15+
initialize_floorplan -die_area $area \
16+
-core_area $area \
17+
-site FreePDK45_38x28_10R_NP_162NW_34O \
18+
-gap -1
19+
}
20+
catch {
21+
initialize_floorplan -die_area $area \
22+
-core_area $area \
23+
-site FreePDK45_38x28_10R_NP_162NW_34O \
24+
-gap 0
25+
}
26+
catch {
27+
make_rows -core_area $area \
28+
-site FreePDK45_38x28_10R_NP_162NW_34O \
29+
-gap -1
30+
}
31+
catch {
32+
make_rows -core_area $area \
33+
-site FreePDK45_38x28_10R_NP_162NW_34O \
34+
-gap 0
35+
}
36+
37+
initialize_floorplan -die_area $area \
38+
-core_area $area \
1139
-site FreePDK45_38x28_10R_NP_162NW_34O \
1240
-additional_sites FreePDK45_38x28_10R_NP_162NW_34O_DoubleHeight \
1341
-gap 2

0 commit comments

Comments
 (0)