From 27966f101f52415b671cc794b3926a0fc9e667d7 Mon Sep 17 00:00:00 2001 From: gatecat Date: Sun, 8 May 2022 12:44:03 +0100 Subject: ice40: Fix propagation of constraints through SB_GB Signed-off-by: gatecat --- ice40/pack.cc | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/ice40/pack.cc b/ice40/pack.cc index 92297e8e..9eff053e 100644 --- a/ice40/pack.cc +++ b/ice40/pack.cc @@ -671,13 +671,6 @@ static void insert_global(Context *ctx, NetInfo *net, bool is_reset, bool is_cen for (auto &user : keep_users) user.cell->ports[user.port].user_idx = net->users.add(user); - if (net->clkconstr) { - glbnet->clkconstr = std::unique_ptr(new ClockConstraint()); - glbnet->clkconstr->low = net->clkconstr->low; - glbnet->clkconstr->high = net->clkconstr->high; - glbnet->clkconstr->period = net->clkconstr->period; - } - ctx->cells[gb->name] = std::move(gb); } @@ -803,6 +796,29 @@ static void promote_globals(Context *ctx) } } +static void copy_gb_constraints(Context *ctx) +{ + // Copy constraints through GBs and PLLs + bool did_something = false; + do { + did_something = false; + for (auto &cell : ctx->cells) { + CellInfo *ci = cell.second.get(); + if (!is_gbuf(ctx, ci)) + continue; + NetInfo *in = ci->getPort(id_USER_SIGNAL_TO_GLOBAL_BUFFER); + NetInfo *out = ci->getPort(id_GLOBAL_BUFFER_OUTPUT); + if (in && out && in->clkconstr && !out->clkconstr) { + out->clkconstr = std::unique_ptr(new ClockConstraint()); + out->clkconstr->low = in->clkconstr->low; + out->clkconstr->high = in->clkconstr->high; + out->clkconstr->period = in->clkconstr->period; + did_something = true; + } + } + } while (did_something); +} + // Figure out where to place PLLs static void place_plls(Context *ctx) { @@ -1711,6 +1727,7 @@ bool Arch::pack() pack_plls(ctx); if (!bool_or_default(ctx->settings, id_no_promote_globals, false)) promote_globals(ctx); + copy_gb_constraints(ctx); ctx->assignArchInfo(); constrain_chains(ctx); ctx->fixupHierarchy(); -- cgit v1.2.3