From 86699b42f619960bfefd4d0b479dd44a90527ea4 Mon Sep 17 00:00:00 2001 From: gatecat Date: Sat, 26 Feb 2022 15:17:46 +0000 Subject: Switch to potentially-sparse net users array This uses a new data structure for net.users that allows gaps, so removing a port from a net is no longer an O(n) operation on the number of users the net has. Signed-off-by: gatecat --- gowin/pack.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'gowin/pack.cc') diff --git a/gowin/pack.cc b/gowin/pack.cc index cc715864..c17a20c7 100644 --- a/gowin/pack.cc +++ b/gowin/pack.cc @@ -68,7 +68,7 @@ static void pack_alus(Context *ctx) continue; } - if (!is_alu(ctx, cin_ci) || cin->users.size() > 1) { + if (!is_alu(ctx, cin_ci) || cin->users.entries() > 1) { if (ctx->verbose) { log_info("ALU head found %s. CIN net is %s\n", ctx->nameOf(ci), ctx->nameOf(cin)); } @@ -177,9 +177,9 @@ static void pack_alus(Context *ctx) new_cells.push_back(std::move(packed)); - if (cout != nullptr && cout->users.size() > 0) { + if (cout != nullptr && cout->users.entries() > 0) { // if COUT used by logic - if ((cout->users.size() > 1) || (!is_alu(ctx, cout->users.at(0).cell))) { + if ((cout->users.entries() > 1) || (!is_alu(ctx, (*cout->users.begin()).cell))) { if (ctx->verbose) { log_info("COUT is used by logic\n"); } @@ -204,7 +204,7 @@ static void pack_alus(Context *ctx) break; } // next ALU - ci = cout->users.at(0).cell; + ci = (*cout->users.begin()).cell; // if ALU is too big if (alu_idx == (ctx->gridDimX - 2) * 6 - 1) { log_error("ALU %s is the %dth in the chain. Such long chains are not supported.\n", ctx->nameOf(ci), @@ -596,9 +596,10 @@ static void set_net_constant(const Context *ctx, NetInfo *orig, NetInfo *constne log_info("%s user %s\n", ctx->nameOf(orig), ctx->nameOf(uc)); if ((is_lut(ctx, uc) || is_lc(ctx, uc)) && (user.port.str(ctx).at(0) == 'I') && !constval) { uc->ports[user.port].net = nullptr; + uc->ports[user.port].user_idx = {}; } else { uc->ports[user.port].net = constnet; - constnet->users.push_back(user); + uc->ports[user.port].user_idx = constnet->users.add(user); } } } -- cgit v1.2.3