From 01316a38b6220fb59bfbe5b54e0976b1f2319422 Mon Sep 17 00:00:00 2001 From: George Rennie Date: Wed, 20 Nov 2024 14:00:43 +0100 Subject: [PATCH] flatten: add -insertbarriers flag * This uses $barrier optimization barriers to connect wires into the flattened module instead of connections --- passes/techmap/flatten.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/passes/techmap/flatten.cc b/passes/techmap/flatten.cc index ea5855a09a2..6a1cbf36e7b 100644 --- a/passes/techmap/flatten.cc +++ b/passes/techmap/flatten.cc @@ -60,6 +60,7 @@ struct FlattenWorker bool ignore_wb = false; bool create_scopeinfo = true; bool create_scopename = false; + bool insert_barriers = false; template void map_attributes(RTLIL::Cell *cell, T *object, IdString orig_object_name) @@ -246,7 +247,11 @@ struct FlattenWorker log_error("Cell port %s.%s.%s is driving constant bits: %s <= %s\n", log_id(module), log_id(cell), log_id(port_it.first), log_signal(new_conn.first), log_signal(new_conn.second)); - module->connect(new_conn); + if (insert_barriers) + module->addBarrier(NEW_ID, new_conn.second, new_conn.first); + else + module->connect(new_conn); + sigmap.add(new_conn.first, new_conn.second); } @@ -345,6 +350,11 @@ struct FlattenPass : public Pass { log(" with a public name the enclosing scope can be found via their\n"); log(" 'hdlname' attribute.\n"); log("\n"); + log(" -insertbarriers\n"); + log(" Use $barrier cells to connect flattened modules to their surrounding\n"); + log(" scope instead of connections. This prevents optimization passes\n"); + log(" optimizing through the connection.\n"); + log("\n"); } void execute(std::vector args, RTLIL::Design *design) override { @@ -367,6 +377,10 @@ struct FlattenPass : public Pass { worker.create_scopename = true; continue; } + if (args[argidx] == "-insertbarriers") { + worker.insert_barriers = true; + continue; + } break; } extra_args(args, argidx, design);