ice40: Fix constant packer
Signed-off-by: David Shah <davey1576@gmail.com>
This commit is contained in:
parent
7abfd36773
commit
ecc2c486d9
@ -202,22 +202,32 @@ static void pack_constants(Context *ctx)
|
|||||||
|
|
||||||
std::vector<IdString> dead_nets;
|
std::vector<IdString> dead_nets;
|
||||||
|
|
||||||
|
bool gnd_used = false, vcc_used = false;
|
||||||
|
|
||||||
for (auto net : ctx->nets) {
|
for (auto net : ctx->nets) {
|
||||||
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")) {
|
||||||
set_net_constant(ctx, ni, gnd_net, false);
|
set_net_constant(ctx, ni, gnd_net, false);
|
||||||
ctx->cells[gnd_cell->name] = gnd_cell;
|
gnd_used = true;
|
||||||
ctx->nets[gnd_net->name] = gnd_net;
|
|
||||||
dead_nets.push_back(net.first);
|
dead_nets.push_back(net.first);
|
||||||
} else if (ni->driver.cell != nullptr &&
|
} else if (ni->driver.cell != nullptr &&
|
||||||
ni->driver.cell->type == ctx->id("VCC")) {
|
ni->driver.cell->type == ctx->id("VCC")) {
|
||||||
set_net_constant(ctx, ni, vcc_net, true);
|
set_net_constant(ctx, ni, vcc_net, true);
|
||||||
ctx->cells[vcc_cell->name] = vcc_cell;
|
vcc_used = true;
|
||||||
ctx->nets[vcc_net->name] = vcc_net;
|
|
||||||
dead_nets.push_back(net.first);
|
dead_nets.push_back(net.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gnd_used) {
|
||||||
|
ctx->cells[gnd_cell->name] = gnd_cell;
|
||||||
|
ctx->nets[gnd_net->name] = gnd_net;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vcc_used) {
|
||||||
|
ctx->cells[vcc_cell->name] = vcc_cell;
|
||||||
|
ctx->nets[vcc_net->name] = 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