Add vcc and gnd nets and cells only if needed
This commit is contained in:
parent
78e6631f76
commit
07b21c5129
@ -340,6 +340,12 @@ static void pack_constants(Context *ctx)
|
|||||||
gnd_net->driver.cell = gnd_cell.get();
|
gnd_net->driver.cell = gnd_cell.get();
|
||||||
gnd_net->driver.port = ctx->id("O");
|
gnd_net->driver.port = ctx->id("O");
|
||||||
gnd_cell->ports.at(ctx->id("O")).net = gnd_net.get();
|
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");
|
std::unique_ptr<CellInfo> vcc_cell = create_ice_cell(ctx, ctx->id("ICESTORM_LC"), "$PACKER_VCC");
|
||||||
vcc_cell->params[ctx->id("LUT_INIT")] = "1";
|
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.cell = vcc_cell.get();
|
||||||
vcc_net->driver.port = ctx->id("O");
|
vcc_net->driver.port = ctx->id("O");
|
||||||
vcc_cell->ports.at(ctx->id("O")).net = vcc_net.get();
|
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;
|
std::vector<IdString> dead_nets;
|
||||||
|
|
||||||
@ -357,26 +369,29 @@ static void pack_constants(Context *ctx)
|
|||||||
NetInfo *ni = net.second;
|
NetInfo *ni = net.second;
|
||||||
if (ni->driver.cell != nullptr && ni->driver.cell->type == ctx->id("GND")) {
|
if (ni->driver.cell != nullptr && ni->driver.cell->type == ctx->id("GND")) {
|
||||||
IdString drv_cell = ni->driver.cell->name;
|
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;
|
gnd_used = true;
|
||||||
dead_nets.push_back(net.first);
|
dead_nets.push_back(net.first);
|
||||||
ctx->cells.erase(drv_cell);
|
ctx->cells.erase(drv_cell);
|
||||||
} 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_info, true);
|
||||||
dead_nets.push_back(net.first);
|
dead_nets.push_back(net.first);
|
||||||
ctx->cells.erase(drv_cell);
|
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->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
|
// Vcc cell always inserted for now, as it may be needed during carry legalisation (TODO: trim later if actually
|
||||||
// never used?)
|
// never used?)
|
||||||
ctx->cells[vcc_cell->name] = std::move(vcc_cell);
|
if (vcc_net_info == vcc_net.get())
|
||||||
ctx->nets[vcc_net->name] = std::move(vcc_net);
|
{
|
||||||
|
ctx->cells[vcc_cell->name] = std::move(vcc_cell);
|
||||||
|
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user