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 <rabbit@yrabbit.cyou>
This commit is contained in:
YRabbit 2024-10-02 10:23:32 +10:00
parent b3b2392893
commit 4c3cc5f5bd
5 changed files with 27 additions and 9 deletions

View File

@ -20,7 +20,7 @@ struct GowinCstReader
Context *ctx;
std::istream &in;
GowinCstReader(Context *ctx, std::istream &in) : ctx(ctx), in(in) {};
GowinCstReader(Context *ctx, std::istream &in) : ctx(ctx), in(in){};
const PadInfoPOD *pinLookup(const PadInfoPOD *list, const size_t len, const IdString idx)
{

View File

@ -340,7 +340,8 @@ struct GowinGlobalRouter
src = ctx->getBelPinWire(driver.cell->bel, driver.port);
}
RouteResult route_result = route_direct_net(net, [&](PipId pip) { return global_DQCE_pip_filter(pip); }, src);
RouteResult route_result = route_direct_net(
net, [&](PipId pip) { return global_DQCE_pip_filter(pip); }, src);
if (route_result == NOT_ROUTED) {
log_error("Can't route the %s network.\n", ctx->nameOf(net));
}
@ -417,7 +418,8 @@ struct GowinGlobalRouter
src = ctx->getBelPinWire(driver.cell->bel, driver.port);
}
RouteResult route_result = route_direct_net(net, [&](PipId pip) { return global_DCS_pip_filter(pip); }, src);
RouteResult route_result = route_direct_net(
net, [&](PipId pip) { return global_DCS_pip_filter(pip); }, src);
if (route_result == NOT_ROUTED) {
log_error("Can't route the %s network.\n", ctx->nameOf(net));
}
@ -504,7 +506,8 @@ struct GowinGlobalRouter
WireId src = ctx->getBelPinWire(driver.cell->bel, port);
std::vector<PipId> path;
RouteResult route_result = route_direct_net(net, [&](PipId pip) { return global_pip_filter(pip); }, src, &path);
RouteResult route_result = route_direct_net(
net, [&](PipId pip) { return global_pip_filter(pip); }, src, &path);
if (route_result == NOT_ROUTED) {
log_error("Can't route the %s network.\n", ctx->nameOf(net));
}
@ -568,7 +571,8 @@ struct GowinGlobalRouter
NetInfo *net_before_buf = buf_ci->getPort(id_I);
NPNR_ASSERT(net_before_buf != nullptr);
RouteResult route_result = route_direct_net(net, [&](PipId pip) { return global_pip_filter(pip); }, src);
RouteResult route_result = route_direct_net(
net, [&](PipId pip) { return global_pip_filter(pip); }, src);
if (route_result == NOT_ROUTED || route_result == ROUTED_PARTIALLY) {
log_error("Can't route the %s net. It might be worth removing the BUFG buffer flag.\n", ctx->nameOf(net));
}

View File

@ -21,7 +21,7 @@ namespace {
struct GowinImpl : HimbaechelAPI
{
~GowinImpl() {};
~GowinImpl(){};
void init_database(Arch *arch) override;
void init(Context *ctx) override;
@ -102,7 +102,7 @@ struct GowinImpl : HimbaechelAPI
struct GowinArch : HimbaechelArch
{
GowinArch() : HimbaechelArch("gowin") {};
GowinArch() : HimbaechelArch("gowin"){};
bool match_device(const std::string &device) override { return device.size() > 2 && device.substr(0, 2) == "GW"; }

View File

@ -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);

View File

@ -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;
}