router2: Allow overriding resource costs

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2021-09-24 19:11:37 +01:00
parent 502fcff765
commit ab6990f908
2 changed files with 9 additions and 2 deletions

View File

@ -355,8 +355,7 @@ struct Router2
{
auto &wd = wire_data(wire);
auto &nd = nets.at(net->udata);
float base_cost = ctx->getDelayNS(ctx->getPipDelay(pip).maxDelay() + ctx->getWireDelay(wire).maxDelay() +
ctx->getDelayEpsilon());
float base_cost = cfg.get_base_cost(ctx, wire, pip, crit_weight);
int overuse = wd.curr_cong;
float hist_cost = 1.0f + crit_weight * (wd.hist_cong_cost - 1.0f);
float bias_cost = 0;

View File

@ -21,6 +21,13 @@
NEXTPNR_NAMESPACE_BEGIN
inline float default_base_cost(Context *ctx, WireId wire, PipId pip, float crit_weight)
{
(void)crit_weight; // unused
return ctx->getDelayNS(ctx->getPipDelay(pip).maxDelay() + ctx->getWireDelay(wire).maxDelay() +
ctx->getDelayEpsilon());
}
struct Router2Cfg
{
Router2Cfg(Context *ctx);
@ -51,6 +58,7 @@ struct Router2Cfg
bool perf_profile = false;
std::string heatmap;
std::function<float(Context *ctx, WireId wire, PipId pip, float crit_weight)> get_base_cost = default_base_cost;
};
void router2(Context *ctx, const Router2Cfg &cfg);