Support use of router2 for gowin (#1636)

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
myrtle 2026-02-17 09:26:25 +01:00 committed by GitHub
parent 06ae973aa8
commit 49ba0b277f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 13 additions and 2 deletions

View File

@ -54,7 +54,7 @@ struct Router2
{ {
WireId sink_wire; WireId sink_wire;
BoundingBox bb; 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 // As we allow overlap at first; the nextpnr bind functions can't be used
@ -358,6 +358,9 @@ struct Router2
cursor = ctx->getPipSrcWire(pip); cursor = ctx->getPipSrcWire(pip);
} }
ad.routed = false; 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, 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 &nd = nets.at(net->udata);
auto &ad = nd.arcs.at(usr.idx()).at(phys_pin); auto &ad = nd.arcs.at(usr.idx()).at(phys_pin);
ad.routed = true; ad.routed = true;
ad.pre_routed = true;
WireId src = nets.at(net->udata).src_wire; WireId src = nets.at(net->udata).src_wire;
WireId cursor = ad.sink_wire; WireId cursor = ad.sink_wire;
@ -1141,7 +1145,7 @@ struct Router2
if (bound_net == nullptr) { if (bound_net == nullptr) {
to_bind.push_back(p); 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) { if (ctx->verbose) {
log_info("Failed to bind pip %s to net %s\n", ctx->nameOfPip(p), net->name.c_str(ctx)); 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 // wires
bool checkPipAvail(PipId pip) const override; bool checkPipAvail(PipId pip) const override;
bool checkPipAvailForNet(PipId pip, const NetInfo *net) const override;
// Cluster // Cluster
bool isClusterStrict(const CellInfo *cell) const override { return true; } bool isClusterStrict(const CellInfo *cell) const override { return true; }
@ -249,6 +250,12 @@ bool GowinImpl::checkPipAvail(PipId pip) const
(!(gwu.is_global_pip(pip) || gwu.is_segment_pip(pip))); (!(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() void GowinImpl::pack()
{ {
if (ctx->settings.count(ctx->id("cst.filename"))) { if (ctx->settings.count(ctx->id("cst.filename"))) {