Support use of router2 for gowin

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2026-02-10 15:09:10 +01:00
parent d0d2862d1a
commit c9ff60e392
2 changed files with 13 additions and 2 deletions

View File

@ -54,7 +54,7 @@ struct Router2
{
WireId sink_wire;
BoundingBox bb;
bool routed = false;
bool routed = false, pre_routed = false;
};
// As we allow overlap at first; the nextpnr bind functions can't be used
@ -358,6 +358,9 @@ struct Router2
cursor = ctx->getPipSrcWire(pip);
}
ad.routed = false;
// Once we've ripped up the arc, the routing may no longer be the same as before...
// (this should only happen if it was not strongly bound)
ad.pre_routed = false;
}
float score_wire_for_arc(NetInfo *net, store_index<PortRef> user, size_t phys_pin, WireId wire, PipId pip,
@ -419,6 +422,7 @@ struct Router2
auto &nd = nets.at(net->udata);
auto &ad = nd.arcs.at(usr.idx()).at(phys_pin);
ad.routed = true;
ad.pre_routed = true;
WireId src = nets.at(net->udata).src_wire;
WireId cursor = ad.sink_wire;
@ -1141,7 +1145,7 @@ struct Router2
if (bound_net == nullptr) {
to_bind.push_back(p);
}
} else {
} else if (!ad.pre_routed || ctx->getBoundPipNet(p) != net) { // allow pre routing to break normal validity checking rules
if (ctx->verbose) {
log_info("Failed to bind pip %s to net %s\n", ctx->nameOfPip(p), net->name.c_str(ctx));
}

View File

@ -45,6 +45,7 @@ struct GowinImpl : HimbaechelAPI
// wires
bool checkPipAvail(PipId pip) const override;
bool checkPipAvailForNet(PipId pip, const NetInfo *net) const override;
// Cluster
bool isClusterStrict(const CellInfo *cell) const override { return true; }
@ -247,6 +248,12 @@ bool GowinImpl::checkPipAvail(PipId pip) const
(!(gwu.is_global_pip(pip) || gwu.is_segment_pip(pip)));
}
bool GowinImpl::checkPipAvailForNet(PipId pip, const NetInfo *net) const
{
return (net->constant_value == IdString() && ctx->getWireConstantValue(ctx->getPipSrcWire(pip)) != IdString()) ||
(!(gwu.is_global_pip(pip) || gwu.is_segment_pip(pip)));
}
void GowinImpl::pack()
{
if (ctx->settings.count(ctx->id("cst.filename"))) {