From 5f85167f8c29fde5d0189e503858ccf0c78f7b35 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Wed, 25 Dec 2024 15:48:09 +0100 Subject: [PATCH] Fix DFF pack --- himbaechel/uarch/gatemate/constids.inc | 1 + himbaechel/uarch/gatemate/gatemate.cc | 19 +++++++++++++++++++ himbaechel/uarch/gatemate/gatemate.h | 1 + himbaechel/uarch/gatemate/pack.cc | 13 ++++++++----- 4 files changed, 29 insertions(+), 5 deletions(-) diff --git a/himbaechel/uarch/gatemate/constids.inc b/himbaechel/uarch/gatemate/constids.inc index 733f06c0..226fa34f 100644 --- a/himbaechel/uarch/gatemate/constids.inc +++ b/himbaechel/uarch/gatemate/constids.inc @@ -115,6 +115,7 @@ X(D) X(R) X(S) X(FF_INIT) +X(2D_IN) X(CC_BUFG) X(BUFG) diff --git a/himbaechel/uarch/gatemate/gatemate.cc b/himbaechel/uarch/gatemate/gatemate.cc index eec3be40..9da95729 100644 --- a/himbaechel/uarch/gatemate/gatemate.cc +++ b/himbaechel/uarch/gatemate/gatemate.cc @@ -49,6 +49,25 @@ delay_t GateMateImpl::estimateDelay(WireId src, WireId dst) const return 100 * (std::abs(dx - sx) / 4 + std::abs(dy - sy) / 4 + 2); } +bool GateMateImpl::isBelLocationValid(BelId bel, bool explain_invalid) const +{ + CellInfo *cell = ctx->getBoundBelCell(bel); + if (cell == nullptr) { + return true; + } + if (ctx->getBelType(bel) == id_CPE) { + Loc loc = ctx->getBelLocation(bel); + int x = loc.x - 2; + int y = loc.y - 2; + if (x<2 || x>167) + return false; + if (y<2 || y>127) + return false; + return true; + } + return true; +} + void GateMateImpl::postRoute() { ctx->assignArchInfo(); diff --git a/himbaechel/uarch/gatemate/gatemate.h b/himbaechel/uarch/gatemate/gatemate.h index 99c0cb88..3895536e 100644 --- a/himbaechel/uarch/gatemate/gatemate.h +++ b/himbaechel/uarch/gatemate/gatemate.h @@ -42,6 +42,7 @@ struct GateMateImpl : HimbaechelAPI void postRoute() override; + bool isBelLocationValid(BelId bel, bool explain_invalid = false) const override; delay_t estimateDelay(WireId src, WireId dst) const override; void drawBel(std::vector &g, GraphicElement::style_t style, IdString bel_type, Loc loc) override; diff --git a/himbaechel/uarch/gatemate/pack.cc b/himbaechel/uarch/gatemate/pack.cc index 1ca5c03b..b8987184 100644 --- a/himbaechel/uarch/gatemate/pack.cc +++ b/himbaechel/uarch/gatemate/pack.cc @@ -321,14 +321,17 @@ void GateMatePacker::pack_cpe() if (!ci.type.in(id_CC_DFF)) continue; ci.renamePort(id_D, id_IN1); - ci.renamePort(id_Q, id_OUT1); + ci.renamePort(id_Q, id_OUT2); ci.disconnectPort(id_EN); ci.disconnectPort(id_SR); - ci.params[id_O1] = Property(0b00, 2); - ci.params[id_INIT_L20] = Property(0b1010, 4); + ci.params[id_O2] = Property(0b00, 2); + ci.params[id_2D_IN] = Property(1, 1); ci.params[id_INIT_L00] = Property(0b1010, 4); - ci.params[id_INIT_L10] = Property(0b1010, 4); - + ci.params[id_INIT_L01] = Property(0b1111, 4); + ci.params[id_INIT_L02] = Property(0b1111, 4); + ci.params[id_INIT_L03] = Property(0b1111, 4); + ci.params[id_INIT_L10] = Property(0b1000, 4); + ci.params[id_INIT_L20] = Property(0b1100, 4); ci.params[id_EN] = Property(0b11, 2); ci.params[id_R] = Property(0b11, 2); ci.params[id_S] = Property(0b11, 2);