From 3d71bf678cfd08f044958082a692f9e0fded1dbd Mon Sep 17 00:00:00 2001 From: gatecat Date: Fri, 14 Aug 2026 16:48:48 +0200 Subject: [PATCH] gatemate: Override router2 cost function to account for low-delay pips Signed-off-by: gatecat --- himbaechel/arch.cc | 4 +++- himbaechel/himbaechel_api.h | 3 +++ himbaechel/uarch/gatemate/gatemate.cc | 10 ++++++++++ himbaechel/uarch/gatemate/gatemate.h | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/himbaechel/arch.cc b/himbaechel/arch.cc index 02904951..dcb9e51b 100644 --- a/himbaechel/arch.cc +++ b/himbaechel/arch.cc @@ -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()); diff --git a/himbaechel/himbaechel_api.h b/himbaechel/himbaechel_api.h index 57f934f1..d82a95bd 100644 --- a/himbaechel/himbaechel_api.h +++ b/himbaechel/himbaechel_api.h @@ -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() {}; diff --git a/himbaechel/uarch/gatemate/gatemate.cc b/himbaechel/uarch/gatemate/gatemate.cc index 6c08e76f..3f85211e 100644 --- a/himbaechel/uarch/gatemate/gatemate.cc +++ b/himbaechel/uarch/gatemate/gatemate.cc @@ -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; diff --git a/himbaechel/uarch/gatemate/gatemate.h b/himbaechel/uarch/gatemate/gatemate.h index 5fc003f0..731377c4 100644 --- a/himbaechel/uarch/gatemate/gatemate.h +++ b/himbaechel/uarch/gatemate/gatemate.h @@ -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;