aboutsummaryrefslogtreecommitdiffstats
path: root/ice40/pack.cc
diff options
context:
space:
mode:
authorMiodrag Milanovic <mmicko@gmail.com>2019-06-07 13:58:21 +0200
committerMiodrag Milanovic <mmicko@gmail.com>2019-06-07 13:58:21 +0200
commit07b21c51299d7ec38aca2a7994542e3c50f93aa3 (patch)
treecd6a20aad498e0177c1acc76373e8ccb90db699f /ice40/pack.cc
parent78e6631f766194c078b6cd32d520146e6ab257a4 (diff)
downloadnextpnr-07b21c51299d7ec38aca2a7994542e3c50f93aa3.tar.gz
nextpnr-07b21c51299d7ec38aca2a7994542e3c50f93aa3.tar.bz2
nextpnr-07b21c51299d7ec38aca2a7994542e3c50f93aa3.zip
Add vcc and gnd nets and cells only if needed
Diffstat (limited to 'ice40/pack.cc')
-rw-r--r--ice40/pack.cc25
1 files changed, 20 insertions, 5 deletions
diff --git a/ice40/pack.cc b/ice40/pack.cc
index bc57e7d0..0a62a5ca 100644
--- a/ice40/pack.cc
+++ b/ice40/pack.cc
@@ -340,6 +340,12 @@ static void pack_constants(Context *ctx)
gnd_net->driver.cell = gnd_cell.get();
gnd_net->driver.port = ctx->id("O");
gnd_cell->ports.at(ctx->id("O")).net = gnd_net.get();
+
+ NetInfo* gnd_net_info = gnd_net.get();
+ if (ctx->nets.find(ctx->id("$PACKER_GND_NET"))!=ctx->nets.end())
+ {
+ gnd_net_info = ctx->nets.find(ctx->id("$PACKER_GND_NET"))->second.get();
+ }
std::unique_ptr<CellInfo> vcc_cell = create_ice_cell(ctx, ctx->id("ICESTORM_LC"), "$PACKER_VCC");
vcc_cell->params[ctx->id("LUT_INIT")] = "1";
@@ -348,6 +354,12 @@ static void pack_constants(Context *ctx)
vcc_net->driver.cell = vcc_cell.get();
vcc_net->driver.port = ctx->id("O");
vcc_cell->ports.at(ctx->id("O")).net = vcc_net.get();
+
+ NetInfo* vcc_net_info = vcc_net.get();
+ if (ctx->nets.find(ctx->id("$PACKER_VCC_NET"))!=ctx->nets.end())
+ {
+ vcc_net_info = ctx->nets.find(ctx->id("$PACKER_VCC_NET"))->second.get();
+ }
std::vector<IdString> dead_nets;
@@ -357,26 +369,29 @@ static void pack_constants(Context *ctx)
NetInfo *ni = net.second;
if (ni->driver.cell != nullptr && ni->driver.cell->type == ctx->id("GND")) {
IdString drv_cell = ni->driver.cell->name;
- set_net_constant(ctx, ni, gnd_net.get(), false);
+ set_net_constant(ctx, ni, gnd_net_info, false);
gnd_used = true;
dead_nets.push_back(net.first);
ctx->cells.erase(drv_cell);
} else if (ni->driver.cell != nullptr && ni->driver.cell->type == ctx->id("VCC")) {
IdString drv_cell = ni->driver.cell->name;
- set_net_constant(ctx, ni, vcc_net.get(), true);
+ set_net_constant(ctx, ni, vcc_net_info, true);
dead_nets.push_back(net.first);
ctx->cells.erase(drv_cell);
}
}
- if (gnd_used) {
+ if (gnd_used && (gnd_net_info == gnd_net.get())) {
ctx->cells[gnd_cell->name] = std::move(gnd_cell);
ctx->nets[gnd_net->name] = std::move(gnd_net);
}
// Vcc cell always inserted for now, as it may be needed during carry legalisation (TODO: trim later if actually
// never used?)
- ctx->cells[vcc_cell->name] = std::move(vcc_cell);
- ctx->nets[vcc_net->name] = std::move(vcc_net);
+ if (vcc_net_info == vcc_net.get())
+ {
+ ctx->cells[vcc_cell->name] = std::move(vcc_cell);
+ ctx->nets[vcc_net->name] = std::move(vcc_net);
+ }
for (auto dn : dead_nets) {
ctx->nets.erase(dn);