diff --git a/common/kernel/arch_api.h b/common/kernel/arch_api.h index 88582adde7..4eb6f4dde5 100644 --- a/common/kernel/arch_api.h +++ b/common/kernel/arch_api.h @@ -147,6 +147,9 @@ template struct ArchAPI : BaseCtx virtual bool isClusterStrict(const CellInfo *cell) const = 0; virtual bool getClusterPlacement(ClusterId cluster, BelId root_bel, std::vector> &placement) const = 0; + // Routing methods + virtual void expandBoundingBox(BoundingBox &bb) const = 0; + // Flow methods virtual bool pack() = 0; virtual bool place() = 0; diff --git a/common/kernel/base_arch.h b/common/kernel/base_arch.h index 708636a0d1..2929bcba98 100644 --- a/common/kernel/base_arch.h +++ b/common/kernel/base_arch.h @@ -442,6 +442,14 @@ template struct BaseArch : ArchAPI }); } + // Routing methods + virtual void expandBoundingBox(BoundingBox &bb) const override { + bb.x0 = std::max(bb.x0 - 1, 0); + bb.y0 = std::max(bb.y0 - 1, 0); + bb.x1 = std::min(bb.x1 + 1, this->getGridDimX()); + bb.y1 = std::min(bb.y1 + 1, this->getGridDimY()); + } + // Flow methods virtual void assignArchInfo() override {}; diff --git a/common/route/router2.cc b/common/route/router2.cc index 5ae091eea4..148c405117 100644 --- a/common/route/router2.cc +++ b/common/route/router2.cc @@ -1013,14 +1013,7 @@ struct Router2 ++net_data.fail_count; if ((net_data.fail_count % 3) == 0) { // Every three times a net fails to route, expand the bounding box to increase the search space -#ifndef ARCH_MISTRAL - // This patch seems to make thing worse for CycloneV, as it slows down the resolution of TD congestion, - // disable it - net_data.bb.x0 = std::max(net_data.bb.x0 - 1, 0); - net_data.bb.y0 = std::max(net_data.bb.y0 - 1, 0); - net_data.bb.x1 = std::min(net_data.bb.x1 + 1, ctx->getGridDimX()); - net_data.bb.y1 = std::min(net_data.bb.y1 + 1, ctx->getGridDimY()); -#endif + ctx->expandBoundingBox(net_data.bb); } } } diff --git a/docs/archapi.md b/docs/archapi.md index 043f937b34..9918a895e7 100644 --- a/docs/archapi.md +++ b/docs/archapi.md @@ -765,3 +765,12 @@ Returns `true` if the cell **must** be placed according to the cluster; for exam Gets an exact placement of the cluster, with the root cell placed on or near `root_bel` (and always within the same tile). Returns false if no placement is viable, otherwise returns `true` and populates `placement` with a list of cells inside the cluster and bels they should be placed at. This approach of allowing architectures to define cluster placements enables easier handling of irregular fabrics than requiring strict and constant x, y and z offsets. + +Router Methods +--------------- + +### void expandBoundingBox(BoundingBox &bb) const + +As part of `router2` implementation, during congestion update, every third time a net fails to route, this method is executed to expand the bounding box to increase the search space. + +Default implementation expands by one tile in each direction. diff --git a/himbaechel/arch.h b/himbaechel/arch.h index c1076d5a56..ca965c8625 100644 --- a/himbaechel/arch.h +++ b/himbaechel/arch.h @@ -707,6 +707,10 @@ struct Arch : BaseArch DecalXY getPipDecal(PipId pip) const override; DecalXY getGroupDecal(GroupId group) const override; + // ------------------------------------------------ + // Routing methods + void expandBoundingBox(BoundingBox &bb) const override { uarch->expandBoundingBox(bb); }; + // ------------------------------------------------ bool pack() override; diff --git a/himbaechel/himbaechel_api.cc b/himbaechel/himbaechel_api.cc index 0efe5c6f14..23b2476987 100644 --- a/himbaechel/himbaechel_api.cc +++ b/himbaechel/himbaechel_api.cc @@ -85,6 +85,11 @@ bool HimbaechelAPI::getClusterPlacement(ClusterId cluster, BelId root_bel, return ctx->BaseArch::getClusterPlacement(cluster, root_bel, placement); } +void HimbaechelAPI::expandBoundingBox(BoundingBox &bb) const +{ + ctx->BaseArch::expandBoundingBox(bb); +} + HimbaechelArch *HimbaechelArch::list_head; HimbaechelArch::HimbaechelArch(const std::string &name) : name(name) { diff --git a/himbaechel/himbaechel_api.h b/himbaechel/himbaechel_api.h index f432921738..fa75740139 100644 --- a/himbaechel/himbaechel_api.h +++ b/himbaechel/himbaechel_api.h @@ -114,6 +114,8 @@ struct HimbaechelAPI virtual void drawPip(std::vector &g,GraphicElement::style_t style, Loc loc, WireId src, IdString src_type, int32_t src_id, WireId dst, IdString dst_type, int32_t dst_id) {}; + // Routing methods + virtual void expandBoundingBox(BoundingBox &bb) const; // --- Flow hooks --- virtual void pack() {}; // replaces the pack function // Called before and after main placement and routing diff --git a/mistral/arch.h b/mistral/arch.h index f2de793d4e..10309bf019 100644 --- a/mistral/arch.h +++ b/mistral/arch.h @@ -450,6 +450,10 @@ struct Arch : BaseArch BelBucketId getBelBucketForCellType(IdString cell_type) const override; BelBucketId getBelBucketForBel(BelId bel) const override; + // ------------------------------------------------- + // Expanding bounding box seems to make thing worse for CycloneV + // as it slows down the resolution of TD congestion, disabling it + void expandBoundingBox(BoundingBox &bb) const override {}; // ------------------------------------------------- void assignArchInfo() override;