gatemate: Override router2 cost function to account for low-delay pips

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2026-08-14 16:48:48 +02:00
parent 4d23515026
commit 3d71bf678c
4 changed files with 17 additions and 1 deletions

View File

@ -300,7 +300,9 @@ bool Arch::route()
if (router == "router1") {
result = router1(getCtx(), Router1Cfg(getCtx()));
} else if (router == "router2") {
router2(getCtx(), Router2Cfg(getCtx()));
Router2Cfg cfg(getCtx());
uarch->configureRouter2(cfg);
router2(getCtx(), cfg);
result = true;
} else {
log_error("Himbächel architecture does not support router '%s'\n", router.c_str());

View File

@ -56,6 +56,7 @@ struct Context;
struct PlacerHeapCfg;
struct PlacerStaticCfg;
struct Router2Cfg;
namespace po = boost::program_options;
@ -149,6 +150,8 @@ struct HimbaechelAPI
virtual void configurePlacerHeap(PlacerHeapCfg &cfg) {};
virtual void configurePlacerStatic(PlacerStaticCfg &cfg);
virtual void configureRouter2(Router2Cfg &cfg) {};
virtual std::string getDefaultRouter() const { return "router1"; };
virtual ~HimbaechelAPI() {};

View File

@ -24,6 +24,7 @@
#include "nextpnr_assertions.h"
#include "placer_heap.h"
#include "placer_static.h"
#include "router2.h"
#define GEN_INIT_CONSTIDS
#define HIMBAECHEL_CONSTIDS "uarch/gatemate/constids.inc"
@ -1079,6 +1080,15 @@ void GateMateImpl::configurePlacerStatic(PlacerStaticCfg &cfg)
}
}
void GateMateImpl::configureRouter2(Router2Cfg &cfg) {
cfg.get_base_cost = [](Context *ctx, WireId wire, PipId pip, float crit_weight) {
float delay_cost = ctx->getDelayNS(ctx->getPipDelay(pip).maxDelay() + ctx->getWireDelay(wire).maxDelay() + ctx->getDelayEpsilon());
const float rr_cost = 0.5f; // fundamental cost of using a routing resource
return delay_cost + rr_cost * (1.0f - crit_weight);
// return delay_cost;
};
}
int GateMateImpl::get_dff_config(CellInfo *dff) const
{
int val = 0;

View File

@ -79,6 +79,7 @@ struct GateMateImpl : HimbaechelAPI
void configurePlacerHeap(PlacerHeapCfg &cfg) override;
void configurePlacerStatic(PlacerStaticCfg &cfg) override;
void configureRouter2(Router2Cfg &cfg) override;
bool isPipInverting(PipId pip) const override;