From 2a98510f91c0a881f2cff13e45067ec057ad0e9a Mon Sep 17 00:00:00 2001 From: Pepijn de Vos Date: Thu, 3 Dec 2020 15:31:02 +0100 Subject: [PATCH] add constraints --- gowin/arch.cc | 25 +++++++++++++++++++++---- gowin/archdefs.h | 2 ++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/gowin/arch.cc b/gowin/arch.cc index 28b0295e..d7f2f8a8 100644 --- a/gowin/arch.cc +++ b/gowin/arch.cc @@ -965,6 +965,8 @@ void Arch::assignArchInfo() if (ci->type == id("SLICE")) { ci->is_slice = true; ci->slice_clk = get_net_or_empty(ci, id("CLK")); + ci->slice_ce = get_net_or_empty(ci, id("CE")); + ci->slice_lsr = get_net_or_empty(ci, id("LSR")); } else { ci->is_slice = false; } @@ -974,14 +976,29 @@ void Arch::assignArchInfo() bool Arch::cellsCompatible(const CellInfo **cells, int count) const { - const NetInfo *clk = nullptr; + const NetInfo *clk[4] = {nullptr, nullptr, nullptr, nullptr}; + const NetInfo *ce[4] = {nullptr, nullptr, nullptr, nullptr}; + const NetInfo *lsr[4] = {nullptr, nullptr, nullptr, nullptr}; int group = -1; for (int i = 0; i < count; i++) { const CellInfo *ci = cells[i]; if (ci->is_slice && ci->slice_clk != nullptr) { - if (clk == nullptr) - clk = ci->slice_clk; - else if (clk != ci->slice_clk) + Loc loc = getBelLocation(ci->bel); + int cls = loc.z/2; + bool ff_used = ci->params.at(id_FF_USED).as_bool(); + if (loc.z >= 6 && ff_used) // top slice have no ff + return false; + if (clk[cls] == nullptr) + clk[cls] = ci->slice_clk; + else if (clk[cls] != ci->slice_clk) + return false; + if (ce[cls] == nullptr) + ce[cls] = ci->slice_ce; + else if (ce[cls] != ci->slice_ce) + return false; + if (lsr[cls] == nullptr) + lsr[cls] = ci->slice_lsr; + else if (lsr[cls] != ci->slice_lsr) return false; } if (ci->user_group != -1) { diff --git a/gowin/archdefs.h b/gowin/archdefs.h index 76a8bbda..af317c2e 100644 --- a/gowin/archdefs.h +++ b/gowin/archdefs.h @@ -81,6 +81,8 @@ struct ArchCellInfo bool is_slice; // Only packing rule for slice type primitives is a single clock per tile const NetInfo *slice_clk; + const NetInfo *slice_ce; + const NetInfo *slice_lsr; }; NEXTPNR_NAMESPACE_END