From 579b98c5963c2b86d191d481a2147a663a8196dd Mon Sep 17 00:00:00 2001 From: gatecat Date: Tue, 1 Jun 2021 16:51:18 +0100 Subject: Use hashlib for core netlist structures Signed-off-by: gatecat --- machxo2/arch_pybindings.cc | 8 ++++---- machxo2/bitstream.cc | 3 +-- machxo2/pack.cc | 25 ++++++++++++++----------- 3 files changed, 19 insertions(+), 17 deletions(-) (limited to 'machxo2') diff --git a/machxo2/arch_pybindings.cc b/machxo2/arch_pybindings.cc index 07e25437..aaca813a 100644 --- a/machxo2/arch_pybindings.cc +++ b/machxo2/arch_pybindings.cc @@ -45,10 +45,10 @@ void arch_wrap_python(py::module &m) .def("place", &Context::place) .def("route", &Context::route); - typedef std::unordered_map> CellMap; - typedef std::unordered_map> NetMap; - typedef std::unordered_map AliasMap; - typedef std::unordered_map HierarchyMap; + typedef dict> CellMap; + typedef dict> NetMap; + typedef dict AliasMap; + typedef dict HierarchyMap; auto belpin_cls = py::class_>(m, "BelPin"); readonly_wrapper>::def_wrap(belpin_cls, "bel"); diff --git a/machxo2/bitstream.cc b/machxo2/bitstream.cc index d695b094..8c538bae 100644 --- a/machxo2/bitstream.cc +++ b/machxo2/bitstream.cc @@ -114,8 +114,7 @@ static std::vector int_to_bitvector(int val, int size) return bv; } -std::string intstr_or_default(const std::unordered_map &ct, const IdString &key, - std::string def = "0") +std::string intstr_or_default(const dict &ct, const IdString &key, std::string def = "0") { auto found = ct.find(key); if (found == ct.end()) diff --git a/machxo2/pack.cc b/machxo2/pack.cc index 5a6cd97b..26bda946 100644 --- a/machxo2/pack.cc +++ b/machxo2/pack.cc @@ -35,13 +35,14 @@ static void pack_lut_lutffs(Context *ctx) std::unordered_set packed_cells; std::vector> new_cells; - for (auto cell : sorted(ctx->cells)) { - CellInfo *ci = cell.second; + for (auto &cell : ctx->cells) { + CellInfo *ci = cell.second.get(); if (ctx->verbose) log_info("cell '%s' is of type '%s'\n", ci->name.c_str(ctx), ci->type.c_str(ctx)); if (is_lut(ctx, ci)) { std::unique_ptr packed = create_machxo2_cell(ctx, id_FACADE_SLICE, ci->name.str(ctx) + "_LC"); - std::copy(ci->attrs.begin(), ci->attrs.end(), std::inserter(packed->attrs, packed->attrs.begin())); + for (auto &attr : ci->attrs) + packed->attrs[attr.first] = attr.second; packed_cells.insert(ci->name); if (ctx->verbose) @@ -93,15 +94,16 @@ static void pack_remaining_ffs(Context *ctx) std::unordered_set packed_cells; std::vector> new_cells; - for (auto cell : sorted(ctx->cells)) { - CellInfo *ci = cell.second; + for (auto &cell : ctx->cells) { + CellInfo *ci = cell.second.get(); if (is_ff(ctx, ci)) { if (ctx->verbose) log_info("cell '%s' of type '%s remains unpacked'\n", ci->name.c_str(ctx), ci->type.c_str(ctx)); std::unique_ptr packed = create_machxo2_cell(ctx, id_FACADE_SLICE, ci->name.str(ctx) + "_LC"); - std::copy(ci->attrs.begin(), ci->attrs.end(), std::inserter(packed->attrs, packed->attrs.begin())); + for (auto &attr : ci->attrs) + packed->attrs[attr.first] = attr.second; auto dff_bel = ci->attrs.find(ctx->id("BEL")); dff_to_lc(ctx, ci, packed.get(), false); @@ -142,7 +144,8 @@ static void set_net_constant(Context *ctx, NetInfo *orig, NetInfo *constnet, boo log_info("FACADE_FF %s is driven by a constant\n", uc->name.c_str(ctx)); std::unique_ptr lc = create_machxo2_cell(ctx, id_FACADE_SLICE, uc->name.str(ctx) + "_CONST"); - std::copy(uc->attrs.begin(), uc->attrs.end(), std::inserter(lc->attrs, lc->attrs.begin())); + for (auto &attr : uc->attrs) + lc->attrs[attr.first] = attr.second; dff_to_lc(ctx, uc, lc.get(), true); packed_cells.insert(uc->name); @@ -193,8 +196,8 @@ static void pack_constants(Context *ctx) std::vector dead_nets; - for (auto net : sorted(ctx->nets)) { - NetInfo *ni = net.second; + for (auto &net : ctx->nets) { + NetInfo *ni = net.second.get(); 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); @@ -234,8 +237,8 @@ static void pack_io(Context *ctx) log_info("Packing IOs..\n"); - for (auto cell : sorted(ctx->cells)) { - CellInfo *ci = cell.second; + for (auto &cell : ctx->cells) { + CellInfo *ci = cell.second.get(); if (is_nextpnr_iob(ctx, ci)) { for (auto &p : ci->ports) disconnect_port(ctx, ci, p.first); -- cgit v1.2.3