diff options
Diffstat (limited to 'machxo2/pack.cc')
-rw-r--r-- | machxo2/pack.cc | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/machxo2/pack.cc b/machxo2/pack.cc index c53229ba..5051a981 100644 --- a/machxo2/pack.cc +++ b/machxo2/pack.cc @@ -51,20 +51,20 @@ static void pack_lut_lutffs(Context *ctx) // LUT4 drives more than one FF. NetInfo *o = ci->ports.at(id_Z).net; CellInfo *dff = net_only_drives(ctx, o, is_ff, id_DI, false); - auto lut_bel = ci->attrs.find(ctx->id("BEL")); + auto lut_bel = ci->attrs.find(id_BEL); bool packed_dff = false; if (dff) { if (ctx->verbose) log_info("found attached dff %s\n", dff->name.c_str(ctx)); - auto dff_bel = dff->attrs.find(ctx->id("BEL")); + auto dff_bel = dff->attrs.find(id_BEL); if (lut_bel != ci->attrs.end() && dff_bel != dff->attrs.end() && lut_bel->second != dff_bel->second) { // Locations don't match, can't pack } else { lut_to_lc(ctx, ci, packed.get(), false); dff_to_lc(ctx, dff, packed.get(), LutType::Normal); if (dff_bel != dff->attrs.end()) - packed->attrs[ctx->id("BEL")] = dff_bel->second; + packed->attrs[id_BEL] = dff_bel->second; packed_cells.insert(dff->name); if (ctx->verbose) log_info("packed cell %s into %s\n", dff->name.c_str(ctx), packed->name.c_str(ctx)); @@ -104,12 +104,12 @@ static void pack_remaining_ffs(Context *ctx) for (auto &attr : ci->attrs) packed->attrs[attr.first] = attr.second; - auto dff_bel = ci->attrs.find(ctx->id("BEL")); + auto dff_bel = ci->attrs.find(id_BEL); dff_to_lc(ctx, ci, packed.get(), LutType::None); if (dff_bel != ci->attrs.end()) - packed->attrs[ctx->id("BEL")] = dff_bel->second; + packed->attrs[id_BEL] = dff_bel->second; packed_cells.insert(ci->name); if (ctx->verbose) log_info("packed cell %s into %s\n", ci->name.c_str(ctx), packed->name.c_str(ctx)); @@ -183,38 +183,35 @@ static void pack_constants(Context *ctx) const_cell->params[id_LUT0_INITVAL] = Property(0, 16); const_cell->params[id_LUT1_INITVAL] = Property(0xFFFF, 16); - std::unique_ptr<NetInfo> gnd_net = std::unique_ptr<NetInfo>(new NetInfo); - gnd_net->name = ctx->id("$PACKER_GND_NET"); + NetInfo *gnd_net = ctx->createNet(ctx->id("$PACKER_GND_NET")); gnd_net->driver.cell = const_cell.get(); gnd_net->driver.port = id_F0; - const_cell->ports.at(id_F0).net = gnd_net.get(); + const_cell->ports.at(id_F0).net = gnd_net; - std::unique_ptr<NetInfo> vcc_net = std::unique_ptr<NetInfo>(new NetInfo); + NetInfo *vcc_net = ctx->createNet(ctx->id("$PACKER_VCC_NET")); vcc_net->name = ctx->id("$PACKER_VCC_NET"); vcc_net->driver.cell = const_cell.get(); vcc_net->driver.port = id_F1; - const_cell->ports.at(id_F1).net = vcc_net.get(); + const_cell->ports.at(id_F1).net = vcc_net; std::vector<IdString> dead_nets; for (auto &net : ctx->nets) { NetInfo *ni = net.second.get(); - if (ni->driver.cell != nullptr && ni->driver.cell->type == ctx->id("GND")) { + if (ni->driver.cell != nullptr && ni->driver.cell->type == 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, false); dead_nets.push_back(net.first); 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 == 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, true); dead_nets.push_back(net.first); ctx->cells.erase(drv_cell); } } ctx->cells[const_cell->name] = std::move(const_cell); - ctx->nets[gnd_net->name] = std::move(gnd_net); - ctx->nets[vcc_net->name] = std::move(vcc_net); for (auto dn : dead_nets) { ctx->nets.erase(dn); @@ -289,7 +286,7 @@ static void pack_io(Context *ctx) log_info("Removing top-level IOBUF '%s' of type '%s'\n", ci->name.c_str(ctx), ci->type.c_str(ctx)); for (auto &p : ci->ports) - disconnect_port(ctx, ci, p.first); + ci->disconnectPort(p.first); packed_cells.insert(ci->name); } else if (is_facade_iob(ctx, ci)) { // If FACADE_IO has LOC attribute, convert the LOC (pin) to a BEL @@ -297,8 +294,8 @@ static void pack_io(Context *ctx) // attribute already on a FACADE_IO is an error. Attributes on // the pin attached to the PAD of FACADE_IO are ignored by this // packing phase. - auto loc_attr_cell = ci->attrs.find(ctx->id("LOC")); - auto bel_attr_cell = ci->attrs.find(ctx->id("BEL")); + auto loc_attr_cell = ci->attrs.find(id_LOC); + auto bel_attr_cell = ci->attrs.find(id_BEL); if (loc_attr_cell != ci->attrs.end()) { if (bel_attr_cell != ci->attrs.end()) { @@ -315,7 +312,7 @@ static void pack_io(Context *ctx) } else { log_info("pin '%s' constrained to Bel '%s'.\n", ci->name.c_str(ctx), ctx->nameOfBel(pinBel)); } - ci->attrs[ctx->id("BEL")] = ctx->getBelName(pinBel).str(ctx); + ci->attrs[id_BEL] = ctx->getBelName(pinBel).str(ctx); } } } @@ -335,7 +332,7 @@ bool Arch::pack() pack_io(ctx); pack_lut_lutffs(ctx); pack_remaining_ffs(ctx); - ctx->settings[ctx->id("pack")] = 1; + ctx->settings[id_pack] = 1; ctx->assignArchInfo(); log_info("Checksum: 0x%08x\n", ctx->checksum()); return true; |