diff --git a/himbaechel/arch.h b/himbaechel/arch.h index 0f48063a..06cb92a7 100644 --- a/himbaechel/arch.h +++ b/himbaechel/arch.h @@ -673,8 +673,8 @@ struct Arch : BaseArch { return uarch->predictDelay(src_bel, src_pin, dst_bel, dst_pin); } - delay_t getDelayEpsilon() const override { return 20; } // TODO - delay_t getRipupDelayPenalty() const override { return 120; } // TODO + delay_t getDelayEpsilon() const override { return 20; } // TODO + delay_t getRipupDelayPenalty() const override { return ripup_penalty; } // TODO float getDelayNS(delay_t v) const override { return v * 0.001; } delay_t getDelayFromNS(float ns) const override { return delay_t(ns * 1000); } uint32_t getDelayChecksum(delay_t v) const override { return v; } @@ -909,6 +909,8 @@ struct Arch : BaseArch bool fast_pip_delays = false; dict drive_res; dict load_cap; + + delay_t ripup_penalty = 120; }; NEXTPNR_NAMESPACE_END diff --git a/himbaechel/uarch/gowin/gowin.cc b/himbaechel/uarch/gowin/gowin.cc index 3a48935a..d86bca98 100644 --- a/himbaechel/uarch/gowin/gowin.cc +++ b/himbaechel/uarch/gowin/gowin.cc @@ -39,6 +39,8 @@ struct GowinImpl : HimbaechelAPI bool isBelLocationValid(BelId bel, bool explain_invalid) const override; void notifyBelChange(BelId bel, CellInfo *cell) override; + delay_t estimateDelay(WireId src, WireId dst) const override; + // Bel bucket functions IdString getBelBucketForCellType(IdString cell_type) const override; @@ -118,6 +120,8 @@ struct GowinImpl : HimbaechelAPI bool hclk_valid(BelId bel, IdString bel_type) const; array2d> fast_logic_cell; + + delay_t delay_m, delay_c; }; struct GowinArch : HimbaechelArch @@ -248,6 +252,17 @@ void GowinImpl::init(Context *ctx) if (args.options.count("disable_gp_clock_routing")) { ctx->settings[id_NO_GP_CLOCK_ROUTING] = Property(1); } + + // configure delay estimates for A* + if (args.device.rfind("GW2A", 0) == 0 || args.device.rfind("GW5A", 0) == 0) { + delay_c = 300; + delay_m = 60; + ctx->ripup_penalty = 400; + } else { + delay_c = 600; + delay_m = 120; + ctx->ripup_penalty = 800; + } } // We do not allow the use of global wires that bypass a special router. @@ -1679,6 +1694,16 @@ void GowinImpl::drawBel(std::vector &g, GraphicElement::style_t } } +delay_t GowinImpl::estimateDelay(WireId src, WireId dst) const +{ + int sx, sy, dx, dy; + tile_xy(ctx->chip_info, src.tile, sx, sy); + tile_xy(ctx->chip_info, dst.tile, dx, dy); + int dist_x = std::abs(dx - sx), dist_y = std::abs(dy - sy); + return delay_c + delay_m * (std::max(dist_x - 4, 0) + std::max(dist_y - 4, 0) + + 2 * (std::min(dist_x, 4) + std::min(dist_y, 4))); +} + } // namespace NEXTPNR_NAMESPACE_END