diff --git a/himbaechel/uarch/gowin/globals.cc b/himbaechel/uarch/gowin/globals.cc index 64c230d1..e173e9e3 100644 --- a/himbaechel/uarch/gowin/globals.cc +++ b/himbaechel/uarch/gowin/globals.cc @@ -677,18 +677,17 @@ struct GowinGlobalRouter if (ctx->debug) { log_info(" step 0: %s -> %s\n", ctx->nameOfWire(lbo_wire), ctx->nameOfWire(dst_wire)); } - // The DFF can currently only connect to a neighbouring LUT. Skip such networks. + // The DFF might connect to a neighbouring LUT. Skip such networks. if (ctx->getWireName(dst_wire)[1].in(id_XD0, id_XD1, id_XD2, id_XD3, id_XD4, id_XD5)) { - auto pips = ctx->getPipsUphill(dst_wire); - auto pip_it = pips.begin(); - ++pip_it; - NPNR_ASSERT_MSG(!(pip_it != pips.end()), "DFFs have been given the ability to connect independently of the " - "neighbouring LUT. Segment routing must be corrected.\n"); - // Connect LUT OUT to DFF IN - PipId pip = *pips.begin(); - ctx->bindPip(pip, ni, STRENGTH_LOCKED); - bound_pips.push_back(pip); - return SEG_ROUTED_TO_ANOTHER_SEGMENT; + for (auto pip : ctx->getPipsUphill(dst_wire)) { + WireId src_wire = ctx->getPipSrcWire(pip); + if (src_wire == ctx->getNetinfoSourceWire(ni)) { + // Connect LUT OUT to DFF IN + ctx->bindPip(pip, ni, STRENGTH_LOCKED); + bound_pips.push_back(pip); + return SEG_ROUTED_TO_ANOTHER_SEGMENT; + } + } } routed = backwards_bfs_route( ni, lbo_wire, dst_wire, 1000000, false, [&](PipId pip, WireId src) { return true; }, &bound_pips);