place_sa: Add option to disable timing-driven placement

Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
David Shah 2018-06-23 12:18:44 +02:00
parent 289fca0976
commit d72fe0c230
3 changed files with 29 additions and 17 deletions

View File

@ -46,7 +46,7 @@ typedef int64_t wirelen_t;
class SAPlacer
{
public:
SAPlacer(Context *ctx) : ctx(ctx)
SAPlacer(Context *ctx, bool timing_driven) : ctx(ctx), timing_driven(timing_driven)
{
checker = new PlaceValidityChecker(ctx);
int num_bel_types = 0;
@ -334,7 +334,7 @@ class SAPlacer
CellInfo *load_cell = load.cell;
if (load_cell->bel == BelId())
continue;
if (timing_driven) {
WireId user_wire = ctx->getWireBelPin(
load_cell->bel, ctx->portPinFromId(load.port));
delay_t raw_wl = ctx->estimateDelay(drv_wire, user_wire);
@ -343,6 +343,8 @@ class SAPlacer
if (slack < 0)
tns += slack;
worst_slack = std::min(slack, worst_slack);
}
int load_x, load_y;
bool load_gb;
ctx->estimatePosition(load_cell->bel, load_x, load_y, load_gb);
@ -353,9 +355,15 @@ class SAPlacer
xmax = std::max(xmax, load_x);
ymax = std::max(ymax, load_y);
}
if (timing_driven) {
wirelength =
wirelen_t((((ymax - ymin) + (xmax - xmin)) *
std::min(5.0, (1.0 + std::exp(-worst_slack / 5)))));
} else {
wirelength =
wirelen_t((ymax - ymin) + (xmax - xmin));
}
return wirelength;
}
@ -475,6 +483,7 @@ class SAPlacer
float curr_tns = 0;
float temp = 1000;
bool improved = false;
bool timing_driven = true;
int n_move, n_accept;
int diameter = 35, max_x = 1, max_y = 1;
std::unordered_map<BelType, int> bel_types;
@ -483,10 +492,10 @@ class SAPlacer
PlaceValidityChecker *checker;
};
bool place_design_sa(Context *ctx)
bool place_design_sa(Context *ctx, bool timing_driven)
{
try {
SAPlacer placer(ctx);
SAPlacer placer(ctx, timing_driven);
placer.place();
log_info("Checksum: 0x%08x\n", ctx->checksum());
return true;

View File

@ -23,7 +23,7 @@
NEXTPNR_NAMESPACE_BEGIN
extern bool place_design_sa(Context *ctx);
extern bool place_design_sa(Context *ctx, bool timing_driven = true);
NEXTPNR_NAMESPACE_END

View File

@ -101,6 +101,7 @@ int main(int argc, char *argv[])
options.add_options()("up5k", "set device type to iCE40UP5K");
options.add_options()("freq", po::value<double>(),
"set target frequency for design in MHz");
options.add_options()("no-tmdriv", "disable timing-driven placement");
options.add_options()("package", po::value<std::string>(),
"set device package");
po::positional_options_description pos;
@ -308,9 +309,11 @@ int main(int argc, char *argv[])
freq = vm["freq"].as<double>() * 1e6;
assign_budget(&ctx, freq);
print_utilisation(&ctx);
bool timing_driven = true;
if (vm.count("no-tmdriv"))
timing_driven = false;
if (!vm.count("pack-only")) {
if (!place_design_sa(&ctx) && !ctx.force)
if (!place_design_sa(&ctx, timing_driven) && !ctx.force)
log_error("Placing design failed.\n");
if (!route_design(&ctx) && !ctx.force)
log_error("Routing design failed.\n");