From 79d1075345010c025c014786d184ad648777f61c Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Mon, 18 Jun 2018 17:08:35 +0200 Subject: Getting rid of old IdString API users, Add ctx to many internal APIs Signed-off-by: Clifford Wolf --- common/design_utils.h | 13 ++++++++----- common/place_sa.cc | 19 ++++++++++--------- common/rulecheck.cc | 23 ++++++++++++----------- 3 files changed, 30 insertions(+), 25 deletions(-) (limited to 'common') diff --git a/common/design_utils.h b/common/design_utils.h index 2177c0e5..d7f0b733 100644 --- a/common/design_utils.h +++ b/common/design_utils.h @@ -41,8 +41,9 @@ void replace_port(CellInfo *old_cell, IdString old_name, CellInfo *rep_cell, // true, then this cell must be the only load. If ignore_cell is set, that cell // is not considered template -CellInfo *net_only_drives(NetInfo *net, F1 cell_pred, IdString port, - bool exclusive = false, CellInfo *exclude = nullptr) +CellInfo *net_only_drives(const Context *ctx, NetInfo *net, F1 cell_pred, + IdString port, bool exclusive = false, + CellInfo *exclude = nullptr) { if (net == nullptr) return nullptr; @@ -63,7 +64,8 @@ CellInfo *net_only_drives(NetInfo *net, F1 cell_pred, IdString port, } } for (const auto &load : net->users) { - if (load.cell != exclude && cell_pred(load.cell) && load.port == port) { + if (load.cell != exclude && cell_pred(ctx, load.cell) && + load.port == port) { return load.cell; } } @@ -73,11 +75,12 @@ CellInfo *net_only_drives(NetInfo *net, F1 cell_pred, IdString port, // If a net is driven by a given port of a cell matching a predicate, return // that cell, otherwise nullptr template -CellInfo *net_driven_by(const NetInfo *net, F1 cell_pred, IdString port) +CellInfo *net_driven_by(const Context *ctx, const NetInfo *net, F1 cell_pred, + IdString port) { if (net == nullptr) return nullptr; - if (cell_pred(net->driver.cell) && net->driver.port == port) { + if (cell_pred(ctx, net->driver.cell) && net->driver.port == port) { return net->driver.cell; } else { return nullptr; diff --git a/common/place_sa.cc b/common/place_sa.cc index e49cff7a..a5e7c55d 100644 --- a/common/place_sa.cc +++ b/common/place_sa.cc @@ -108,7 +108,7 @@ static void place_initial(Context *ctx, CellInfo *cell, rnd_state &rnd) if (best_bel == BelId()) { if (iters == 0 || ripup_bel == BelId()) log_error("failed to place cell '%s' of type '%s'\n", - cell->name.c_str(), cell->type.c_str()); + cell->name.c_str(ctx), cell->type.c_str(ctx)); --iters; ctx->unbindBel(ripup_target->bel); ripup_target->bel = BelId(); @@ -120,7 +120,7 @@ static void place_initial(Context *ctx, CellInfo *cell, rnd_state &rnd) ctx->bindBel(cell->bel, cell->name); // Back annotate location - cell->attrs["BEL"] = ctx->getBelName(cell->bel).str(); + cell->attrs[ctx->id("BEL")] = ctx->getBelName(cell->bel).str(ctx); cell = ripup_target; } } @@ -294,22 +294,23 @@ void place_design_sa(Context *ctx, int seed) // Initial constraints placer for (auto cell_entry : ctx->cells) { CellInfo *cell = cell_entry.second; - auto loc = cell->attrs.find("BEL"); + auto loc = cell->attrs.find(ctx->id("BEL")); if (loc != cell->attrs.end()) { std::string loc_name = loc->second; - BelId bel = ctx->getBelByName(IdString(loc_name)); + BelId bel = ctx->getBelByName(ctx->id(loc_name)); if (bel == BelId()) { log_error("No Bel named \'%s\' located for " "this chip (processing BEL attribute on \'%s\')\n", - loc_name.c_str(), cell->name.c_str()); + loc_name.c_str(), cell->name.c_str(ctx)); } BelType bel_type = ctx->getBelType(bel); if (bel_type != ctx->belTypeFromId(cell->type)) { log_error("Bel \'%s\' of type \'%s\' does not match cell " "\'%s\' of type \'%s\'", - loc_name.c_str(), ctx->belTypeToId(bel_type).c_str(), - cell->name.c_str(), cell->type.c_str()); + loc_name.c_str(), + ctx->belTypeToId(bel_type).c_str(ctx), + cell->name.c_str(ctx), cell->type.c_str(ctx)); } cell->bel = bel; @@ -436,9 +437,9 @@ void place_design_sa(Context *ctx, int seed) std::string cell_text = "no cell"; IdString cell = ctx->getBelCell(bel, false); if (cell != IdString()) - cell_text = std::string("cell '") + cell.str() + "'"; + cell_text = std::string("cell '") + cell.str(ctx) + "'"; log_error("post-placement validity check failed for Bel '%s' (%s)", - ctx->getBelName(bel).c_str(), cell_text.c_str()); + ctx->getBelName(bel).c_str(ctx), cell_text.c_str()); } } } diff --git a/common/rulecheck.cc b/common/rulecheck.cc index 2f70498f..9b1ee7fe 100644 --- a/common/rulecheck.cc +++ b/common/rulecheck.cc @@ -16,27 +16,27 @@ bool check_all_nets_driven(Context *ctx) if (debug) log_info(" Examining cell \'%s\', of type \'%s\'\n", - cell->name.c_str(), cell->type.c_str()); + cell->name.c_str(ctx), cell->type.c_str(ctx)); for (auto port_entry : cell->ports) { PortInfo &port = port_entry.second; if (debug) log_info(" Checking name of port \'%s\' " "against \'%s\'\n", - port_entry.first.c_str(), port.name.c_str()); + port_entry.first.c_str(ctx), port.name.c_str(ctx)); assert(port.name == port_entry.first); - assert(port.name.size() > 0); + assert(!port.name.empty()); if (port.net == NULL) { if (debug) log_warning( " Port \'%s\' in cell \'%s\' is unconnected\n", - port.name.c_str(), cell->name.c_str()); + port.name.c_str(ctx), cell->name.c_str(ctx)); } else { assert(port.net); if (debug) log_info(" Checking for a net named \'%s\'\n", - port.net->name.c_str()); + port.net->name.c_str(ctx)); assert(ctx->nets.count(port.net->name) > 0); } } @@ -46,22 +46,23 @@ bool check_all_nets_driven(Context *ctx) NetInfo *net = net_entry.second; assert(net->name == net_entry.first); - if ((net->driver.cell != NULL) && (net->driver.cell->type != "GND") && - (net->driver.cell->type != "VCC")) { + if ((net->driver.cell != NULL) && + (net->driver.cell->type != ctx->id("GND")) && + (net->driver.cell->type != ctx->id("VCC"))) { if (debug) log_info(" Checking for a driver cell named \'%s\'\n", - net->driver.cell->name.c_str()); + net->driver.cell->name.c_str(ctx)); assert(ctx->cells.count(net->driver.cell->name) > 0); } for (auto user : net->users) { - if ((user.cell != NULL) && (user.cell->type != "GND") && - (user.cell->type != "VCC")) { + if ((user.cell != NULL) && (user.cell->type != ctx->id("GND")) && + (user.cell->type != ctx->id("VCC"))) { if (debug) log_info(" Checking for a user cell named \'%s\'\n", - user.cell->name.c_str()); + user.cell->name.c_str(ctx)); assert(ctx->cells.count(user.cell->name) > 0); } } -- cgit v1.2.3