From 4e4f4ab113d36b0d228fdf7543cc159b78e20f31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miodrag=20Milanovi=C4=87?= Date: Tue, 2 Sep 2025 14:04:28 +0200 Subject: [PATCH] gatemate: update bounding box (#1548) --- himbaechel/uarch/gatemate/gatemate.cc | 27 +++++++++++++++++++++++++++ himbaechel/uarch/gatemate/gatemate.h | 3 +++ 2 files changed, 30 insertions(+) diff --git a/himbaechel/uarch/gatemate/gatemate.cc b/himbaechel/uarch/gatemate/gatemate.cc index a60fc024..9cf39265 100644 --- a/himbaechel/uarch/gatemate/gatemate.cc +++ b/himbaechel/uarch/gatemate/gatemate.cc @@ -295,6 +295,33 @@ void GateMateImpl::postRoute() } } +BoundingBox GateMateImpl::getRouteBoundingBox(WireId src, WireId dst) const +{ + int x0, y0, x1, y1; + auto expand = [&](int x, int y) { + x0 = std::min(x0, x); + x1 = std::max(x1, x); + y0 = std::min(y0, y); + y1 = std::max(y1, y); + }; + tile_xy(ctx->chip_info, src.tile, x0, y0); + x1 = x0; + y1 = y0; + int dx, dy; + tile_xy(ctx->chip_info, dst.tile, dx, dy); + expand(dx, dy); + + return {(x0 & 0xfffe), (y0 & 0xfffe), (x1 & 0xfffe) + 1, (y1 & 0xfffe) + 1}; +} + +void GateMateImpl::expandBoundingBox(BoundingBox &bb) const +{ + bb.x0 = std::max((bb.x0 & 0xfffe) - 4, 0); + bb.y0 = std::max((bb.y0 & 0xfffe) - 4, 0); + bb.x1 = std::min((bb.x1 & 0xfffe) + 5, ctx->getGridDimX()); + bb.y1 = std::min((bb.y1 & 0xfffe) + 5, ctx->getGridDimY()); +} + void GateMateImpl::configurePlacerHeap(PlacerHeapCfg &cfg) { cfg.placeAllAtOnce = true; } int GateMateImpl::get_dff_config(CellInfo *dff) const diff --git a/himbaechel/uarch/gatemate/gatemate.h b/himbaechel/uarch/gatemate/gatemate.h index d8524351..d7b28753 100644 --- a/himbaechel/uarch/gatemate/gatemate.h +++ b/himbaechel/uarch/gatemate/gatemate.h @@ -44,6 +44,9 @@ struct GateMateImpl : HimbaechelAPI void preRoute() override; void postRoute() override; + BoundingBox getRouteBoundingBox(WireId src, WireId dst) const override; + void expandBoundingBox(BoundingBox &bb) const override; + bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override; delay_t estimateDelay(WireId src, WireId dst) const override; bool getCellDelay(const CellInfo *cell, IdString fromPort, IdString toPort, DelayQuad &delay) const override;