From 5b2930be95effa7086bd8c9f8496532560f2350d Mon Sep 17 00:00:00 2001 From: Adrian Parvin Ouano Date: Mon, 20 May 2024 03:07:52 +0800 Subject: [PATCH] Clock prerouting Gowin fix? --- himbaechel/uarch/gowin/constids.inc | 3 ++- himbaechel/uarch/gowin/globals.cc | 5 +++++ himbaechel/uarch/gowin/gowin.cc | 11 +++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/himbaechel/uarch/gowin/constids.inc b/himbaechel/uarch/gowin/constids.inc index 77de2ee814..b82cd556a6 100644 --- a/himbaechel/uarch/gowin/constids.inc +++ b/himbaechel/uarch/gowin/constids.inc @@ -1192,4 +1192,5 @@ X(HCLK_OUT3) X(BUFG) X(CLOCK) - +// Globally routed +X(GLOBALLY_ROUTED) diff --git a/himbaechel/uarch/gowin/globals.cc b/himbaechel/uarch/gowin/globals.cc index 2504f8ccef..a1e7c62548 100644 --- a/himbaechel/uarch/gowin/globals.cc +++ b/himbaechel/uarch/gowin/globals.cc @@ -196,7 +196,10 @@ struct GowinGlobalRouter } if (routed == NOT_ROUTED) { ctx->unbindWire(src); + } else { + net->attrs[id_GLOBALLY_ROUTED] = Property("YES"); } + return routed; } @@ -233,6 +236,8 @@ struct GowinGlobalRouter } if (routed == NOT_ROUTED) { ctx->unbindWire(src); + } else { + net->attrs[id_GLOBALLY_ROUTED] = Property("YES"); } // b) route net before buf from whatever to the buf input diff --git a/himbaechel/uarch/gowin/gowin.cc b/himbaechel/uarch/gowin/gowin.cc index 751f1865b0..e75cbcce23 100644 --- a/himbaechel/uarch/gowin/gowin.cc +++ b/himbaechel/uarch/gowin/gowin.cc @@ -41,6 +41,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 { return true; } @@ -188,6 +189,16 @@ void GowinImpl::init(Context *ctx) // We do not allow the use of global wires that bypass a special router. bool GowinImpl::checkPipAvail(PipId pip) const { return !gwu.is_global_pip(pip); } +bool GowinImpl::checkPipAvailForNet(PipId pip, const NetInfo *net) const { + if (gwu.is_global_pip(pip)) { + // Available for a globally routed net + auto prop = net->attrs.find(id_GLOBALLY_ROUTED); + return prop != net->attrs.end() && prop->second == Property("YES"); + } + + return true; +} + void GowinImpl::pack() { if (ctx->settings.count(ctx->id("cst.filename"))) {