Skip to content

Commit

Permalink
Merge pull request #5456 from gatecat/ifp_parity
Browse files Browse the repository at this point in the history
ifp: Allow constraining row count to be odd or even
  • Loading branch information
maliberty authored Jul 26, 2024
2 parents 0ee1c77 + 9af9c0b commit f055d1d
Show file tree
Hide file tree
Showing 12 changed files with 1,323 additions and 17 deletions.
2 changes: 2 additions & 0 deletions src/ifp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ initialize_floorplan
[-core_area {llx lly urx ury}]
[-additional_sites site_names]
[-site site_name]
[-row_parity NONE|EVEN|ODD]
```

#### Options
Expand All @@ -72,6 +73,7 @@ initialize_floorplan
| `-site` | Site name. |
| `-die_area` | Die area coordinates in microns (lower left x/y and upper right x/y coordinates). |
| `-core_area` | Core area coordinates in microns (lower left x/y and upper right x/y coordinates). |
| `-row_parity` | Snap to either an odd (`ODD`) or even (`EVEN`) number of rows. Defaults to `NONE` (no constraint on parity). |

### Make Tracks

Expand Down
16 changes: 13 additions & 3 deletions src/ifp/include/ifp/InitFloorplan.hh
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ namespace ifp {
using sta::dbNetwork;
using utl::Logger;

enum class RowParity
{
NONE,
EVEN,
ODD
};

class InitFloorplan
{
public:
Expand All @@ -70,14 +77,16 @@ class InitFloorplan
int core_space_left,
int core_space_right,
odb::dbSite* base_site,
const std::vector<odb::dbSite*>& additional_sites = {});
const std::vector<odb::dbSite*>& additional_sites = {},
RowParity row_parity = RowParity::NONE);

// The base_site determines the single-height rows. For hybrid rows it is
// a site containing a row pattern.
void initFloorplan(const odb::Rect& die,
const odb::Rect& core,
odb::dbSite* base_site,
const std::vector<odb::dbSite*>& additional_sites = {});
const std::vector<odb::dbSite*>& additional_sites = {},
RowParity row_parity = RowParity::NONE);

void insertTiecells(odb::dbMTerm* tie_term,
const std::string& prefix = "TIEOFF_");
Expand Down Expand Up @@ -105,7 +114,8 @@ class InitFloorplan
void makeRows(const odb::dbSite::RowPattern& pattern, const odb::Rect& core);
void makeUniformRows(odb::dbSite* base_site,
const SitesByName& sites_by_name,
const odb::Rect& core);
const odb::Rect& core,
RowParity row_parity);
void makeHybridRows(odb::dbSite* base_hybrid_site,
const SitesByName& sites_by_name,
const odb::Rect& core);
Expand Down
37 changes: 31 additions & 6 deletions src/ifp/src/InitFloorplan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ void InitFloorplan::initFloorplan(
int core_space_left,
int core_space_right,
odb::dbSite* base_site,
const std::vector<odb::dbSite*>& additional_sites)
const std::vector<odb::dbSite*>& additional_sites,
RowParity row_parity)
{
utl::Validator v(logger_, IFP);
v.check_non_negative("utilization", utilization, 12);
Expand All @@ -133,7 +134,8 @@ void InitFloorplan::initFloorplan(
initFloorplan({die_lx, die_ly, die_ux, die_uy},
{core_lx, core_ly, core_ux, core_uy},
base_site,
additional_sites);
additional_sites,
row_parity);
}

double InitFloorplan::designArea()
Expand All @@ -157,7 +159,8 @@ void InitFloorplan::initFloorplan(
const odb::Rect& die,
const odb::Rect& core,
odb::dbSite* base_site,
const std::vector<odb::dbSite*>& additional_sites)
const std::vector<odb::dbSite*>& additional_sites,
RowParity row_parity)
{
Rect die_area(snapToMfgGrid(die.xMin()),
snapToMfgGrid(die.yMin()),
Expand Down Expand Up @@ -216,9 +219,15 @@ void InitFloorplan::initFloorplan(
}

if (base_site->hasRowPattern()) {
if (row_parity != RowParity::NONE) {
logger_->error(
IFP,
41,
"Constraining row parity is not supported for hybrid rows.");
}
makeHybridRows(base_site, sites_by_name, snapped_core);
} else {
makeUniformRows(base_site, sites_by_name, snapped_core);
makeUniformRows(base_site, sites_by_name, snapped_core, row_parity);
}

updateVoltageDomain(clx, cly, cux, cuy);
Expand Down Expand Up @@ -407,7 +416,8 @@ void InitFloorplan::addUsedSites(
// Create the rows for the core area
void InitFloorplan::makeUniformRows(odb::dbSite* base_site,
const SitesByName& sites_by_name,
const odb::Rect& core)
const odb::Rect& core,
RowParity row_parity)
{
const int core_dx = core.dx();
const int core_dy = core.dy();
Expand All @@ -416,7 +426,22 @@ void InitFloorplan::makeUniformRows(odb::dbSite* base_site,

auto make_rows = [&](dbSite* site) {
const uint site_dy = site->getHeight();
const int rows_y = core_dy / site_dy;
int rows_y = core_dy / site_dy;

switch (row_parity) {
case RowParity::NONE:
break;
case RowParity::EVEN:
rows_y = (rows_y / 2) * 2;
break;
case RowParity::ODD:
if (rows_y > 0) {
rows_y = (rows_y % 2 == 0) ? rows_y - 1 : rows_y;
} else {
rows_y = 0;
}
break;
}

int y = core.yMin();
for (int row = 0; row < rows_y; row++) {
Expand Down
23 changes: 19 additions & 4 deletions src/ifp/src/InitFloorplan.i
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ static ifp::InitFloorplan get_floorplan()
%import "dbtypes.i"
%include "../../Exception.i"

%typemap(in) ifp::RowParity {
char *str = Tcl_GetStringFromObj($input, 0);
if (strcasecmp(str, "NONE") == 0) {
$1 = ifp::RowParity::NONE;
} else if (strcasecmp(str, "EVEN") == 0) {
$1 = ifp::RowParity::EVEN;
} else if (strcasecmp(str, "ODD") == 0) {
$1 = ifp::RowParity::ODD;
} else {
$1 = ifp::RowParity::NONE;
}
}

%inline %{

namespace ifp {
Expand All @@ -97,11 +110,12 @@ init_floorplan_core(int die_lx,
int core_ux,
int core_uy,
odb::dbSite* site,
const std::vector<odb::dbSite*>& additional_sites)
const std::vector<odb::dbSite*>& additional_sites,
ifp::RowParity row_parity)
{
get_floorplan().initFloorplan({die_lx, die_ly, die_ux, die_uy},
{core_lx, core_ly, core_ux, core_uy},
site, additional_sites);
site, additional_sites, row_parity);
}

void
Expand All @@ -112,12 +126,13 @@ init_floorplan_util(double util,
int core_space_left,
int core_space_right,
odb::dbSite* site,
const std::vector<odb::dbSite*>& additional_sites)
const std::vector<odb::dbSite*>& additional_sites,
ifp::RowParity row_parity)
{
get_floorplan().initFloorplan(util, aspect_ratio,
core_space_bottom, core_space_top,
core_space_left, core_space_right,
site, additional_sites);
site, additional_sites, row_parity);
}

void
Expand Down
19 changes: 15 additions & 4 deletions src/ifp/src/InitFloorplan.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ sta::define_cmd_args "initialize_floorplan" {[-utilization util]\
[-die_area {lx ly ux uy}]\
[-core_area {lx ly ux uy}]\
[-additional_sites site_names]\
[-site site_name]}
[-site site_name]\
[-row_parity NONE|ODD|EVEN]}

proc initialize_floorplan { args } {
sta::parse_key_args "initialize_floorplan" args \
keys {-utilization -aspect_ratio -core_space \
-die_area -core_area -site -additional_sites} \
-die_area -core_area -site -additional_sites -row_parity} \
flags {}

sta::check_argc_eq0 "initialize_floorplan" $args
Expand All @@ -63,6 +64,14 @@ proc initialize_floorplan { args } {
}
}

set row_parity "NONE"
if {[info exists keys(-row_parity)]} {
set row_parity $keys(-row_parity)
if { $row_parity != "NONE" && $row_parity != "ODD" && $row_parity != "EVEN" } {
utl::error IFP 12 "-row_parity must be NONE, ODD or EVEN"
}
}

sta::check_argc_eq0 "initialize_floorplan" $args
if {[info exists keys(-utilization)]} {
set util $keys(-utilization)
Expand Down Expand Up @@ -101,7 +110,8 @@ proc initialize_floorplan { args } {
[ord::microns_to_dbu $core_sp_left] \
[ord::microns_to_dbu $core_sp_right] \
$site \
$additional_sites
$additional_sites \
$row_parity
} elseif {[info exists keys(-die_area)]} {
set die_area $keys(-die_area)
if { [llength $die_area] != 4 } {
Expand Down Expand Up @@ -132,7 +142,8 @@ proc initialize_floorplan { args } {
[ord::microns_to_dbu $core_lx] [ord::microns_to_dbu $core_ly] \
[ord::microns_to_dbu $core_ux] [ord::microns_to_dbu $core_uy] \
$site \
$additional_sites
$additional_sites \
$row_parity
} else {
utl::error IFP 17 "no -core_area specified."
}
Expand Down
Loading

0 comments on commit f055d1d

Please sign in to comment.