Skip to content

Commit 255633c

Browse files
committed
static: First pass at timing-driven placement
Signed-off-by: gatecat <[email protected]>
1 parent cc273c1 commit 255633c

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

common/place/placer_static.cc

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,19 @@ class StaticPlacer
795795
wl_coeff.at(axis) * pd.max_exp.at(axis) * x_max_sum) /
796796
(max_sum * max_sum);
797797
}
798-
gradient += (d_min - d_max);
798+
float crit = 0.0;
799+
if (cfg.timing_driven) {
800+
if (port.second.type == PORT_IN) {
801+
crit = tmg.get_criticality(CellPortKey(cell->name, port.first));
802+
} else if (port.second.type == PORT_OUT) {
803+
if (ni && ni->users.entries() < 5) {
804+
for (auto usr : ni->users)
805+
crit = std::max(crit, tmg.get_criticality(CellPortKey(usr)));
806+
}
807+
}
808+
}
809+
float weight = 1.0 + 5 * std::pow(crit, 2);
810+
gradient += weight * (d_min - d_max);
799811
}
800812

801813
return gradient;
@@ -975,6 +987,7 @@ class StaticPlacer
975987
initial_steplength *= 10;
976988
}
977989
}
990+
update_timing();
978991
}
979992

980993
RealPair clamp_loc(RealPair loc)
@@ -1034,6 +1047,26 @@ class StaticPlacer
10341047
update_gradients(true);
10351048
log_info(" system potential: %f hpwl: %f\n", system_potential(), system_hpwl());
10361049
compute_overlap();
1050+
if ((iter % 5) == 0)
1051+
update_timing();
1052+
}
1053+
1054+
void update_timing()
1055+
{
1056+
if (!cfg.timing_driven)
1057+
return;
1058+
for (auto &net : nets) {
1059+
NetInfo *ni = net.ni;
1060+
if (ni->driver.cell == nullptr)
1061+
continue;
1062+
RealPair drv_loc = cell_loc(ni->driver.cell, false);
1063+
for (auto usr : ni->users.enumerate()) {
1064+
RealPair usr_loc = cell_loc(usr.value.cell, false);
1065+
delay_t est_delay = cfg.timing_c + cfg.timing_mx * std::abs(drv_loc.x - usr_loc.x) + cfg.timing_my * std::abs(drv_loc.y - usr_loc.y);
1066+
tmg.set_route_delay(CellPortKey(usr.value), DelayPair(est_delay));
1067+
}
1068+
}
1069+
tmg.run(false);
10371070
}
10381071

10391072
void legalise_step(bool dsp_bram)
@@ -1342,6 +1375,8 @@ class StaticPlacer
13421375
: ctx(ctx), cfg(cfg), fast_bels(ctx, true, 8), tmg(ctx), pool(ctx->setting<int>("threads", 8))
13431376
{
13441377
groups.resize(cfg.cell_groups.size());
1378+
tmg.setup_only = true;
1379+
tmg.setup();
13451380
};
13461381
void place()
13471382
{

ecp5/arch.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,9 @@ void configure_static(Arch *arch, PlacerStaticCfg &cfg)
627627
comb.bel_area[id_MULT18X18D] = StaticRect(2.0f, 1.0f);
628628
comb.spacer_rect = StaticRect(2.0f, 1.0f);
629629
}
630+
cfg.timing_c = (120 - 22 * arch->args.speed) * 6;
631+
cfg.timing_mx = (120 - 22 * arch->args.speed);
632+
cfg.timing_my = (120 - 22 * arch->args.speed);
630633
}
631634
} // namespace
632635

0 commit comments

Comments
 (0)