generic: Don't generate Vcc if not needed

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2021-02-17 10:24:06 +00:00
parent da1ecf0813
commit 6b4bd0993f
2 changed files with 8 additions and 6 deletions

View File

@ -156,7 +156,7 @@ static void pack_constants(Context *ctx)
std::vector<IdString> dead_nets; std::vector<IdString> dead_nets;
bool gnd_used = false; bool gnd_used = false, vcc_used = false;
for (auto net : sorted(ctx->nets)) { for (auto net : sorted(ctx->nets)) {
NetInfo *ni = net.second; NetInfo *ni = net.second;
@ -169,6 +169,7 @@ static void pack_constants(Context *ctx)
} else if (ni->driver.cell != nullptr && ni->driver.cell->type == ctx->id("VCC")) { } else if (ni->driver.cell != nullptr && ni->driver.cell->type == ctx->id("VCC")) {
IdString drv_cell = ni->driver.cell->name; IdString drv_cell = ni->driver.cell->name;
set_net_constant(ctx, ni, vcc_net.get(), true); set_net_constant(ctx, ni, vcc_net.get(), true);
vcc_used = true;
dead_nets.push_back(net.first); dead_nets.push_back(net.first);
ctx->cells.erase(drv_cell); ctx->cells.erase(drv_cell);
} }
@ -178,10 +179,11 @@ static void pack_constants(Context *ctx)
ctx->cells[gnd_cell->name] = std::move(gnd_cell); ctx->cells[gnd_cell->name] = std::move(gnd_cell);
ctx->nets[gnd_net->name] = std::move(gnd_net); 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?) if (vcc_used) {
ctx->cells[vcc_cell->name] = std::move(vcc_cell); ctx->cells[vcc_cell->name] = std::move(vcc_cell);
ctx->nets[vcc_net->name] = std::move(vcc_net); ctx->nets[vcc_net->name] = std::move(vcc_net);
}
for (auto dn : dead_nets) { for (auto dn : dead_nets) {
ctx->nets.erase(dn); ctx->nets.erase(dn);

2
tests

@ -1 +1 @@
Subproject commit 6d010ef07edb383f9caba9498cdec8b13fff03a6 Subproject commit 2aa02a28d4078c616d96400973d3b5e4cf1e454c