From 65cf6d8da78851a9a7939ce12a7ca996f2d3fe6e Mon Sep 17 00:00:00 2001 From: YRabbit Date: Thu, 3 Oct 2024 06:36:36 +1000 Subject: [PATCH] Gowin. Fix the port check for connectivity. (#1376) * Gowin. Fix the port check for connectivity. What happens is that it's not enough to check for a network, we also need to make sure that the network is functional: has src and sinks. And the style edits - they get automatically when I make sure to run clang-format10. Signed-off-by: YRabbit * Gowin. Fix the port check for connectivity. What happens is that it's not enough to check for a network, we also need to make sure that the network is functional: has src and sinks Signed-off-by: YRabbit --------- Signed-off-by: YRabbit --- himbaechel/uarch/gowin/gowin_utils.h | 14 ++++++++++++++ himbaechel/uarch/gowin/pack.cc | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/himbaechel/uarch/gowin/gowin_utils.h b/himbaechel/uarch/gowin/gowin_utils.h index f9276c10..71f60f8c 100644 --- a/himbaechel/uarch/gowin/gowin_utils.h +++ b/himbaechel/uarch/gowin/gowin_utils.h @@ -1,6 +1,7 @@ #ifndef GOWIN_UTILS_H #define GOWIN_UTILS_H +#include "design_utils.h" #include "idstringlist.h" #include "nextpnr_namespaces.h" #include "nextpnr_types.h" @@ -37,6 +38,19 @@ struct GowinUtils BelId get_dcs_bel(IdString spine_name); BelId get_dhcen_bel(WireId hclkin_wire, IdString &side); + // ports + inline bool port_used(CellInfo *cell, IdString port_name) + { + if (!nextpnr_himbaechel::port_used(cell, port_name)) { + return false; + } + NetInfo *ni = cell->ports.at(port_name).net; + if (ni->driver.cell == nullptr) { + return false; + } + return ni->users.entries() != 0; + } + // BSRAM bool has_SP32(void); bool need_SP_fix(void); diff --git a/himbaechel/uarch/gowin/pack.cc b/himbaechel/uarch/gowin/pack.cc index 78389d7f..f774bbc3 100644 --- a/himbaechel/uarch/gowin/pack.cc +++ b/himbaechel/uarch/gowin/pack.cc @@ -454,7 +454,7 @@ struct GowinPacker } // if Q1 is connected then disconnect it too - if (port_used(&ci, tx_port)) { + if (gwu.port_used(&ci, tx_port)) { NPNR_ASSERT(out_iob == net_only_drives(ctx, ci.ports.at(tx_port).net, is_iob, id_OEN, true)); nets_to_remove.push_back(ci.getPort(tx_port)->name); out_iob->disconnectPort(id_OEN); @@ -3160,7 +3160,7 @@ struct GowinPacker // add invertor int lut_idx = 0; auto add_inv = [&](IdString port, PortType port_type) { - if (!port_used(&ci, port)) { + if (!gwu.port_used(&ci, port)) { return; }