From 63074ccb895c504d7a766b199ed7fad42a54e114 Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Sat, 18 Jan 2025 10:27:10 -0700 Subject: [PATCH 1/3] add support for passing flatten -separator to flatten in synth --- techlibs/common/synth.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/techlibs/common/synth.cc b/techlibs/common/synth.cc index 74a484d59ae..a1ce1ae1b11 100644 --- a/techlibs/common/synth.cc +++ b/techlibs/common/synth.cc @@ -98,7 +98,7 @@ struct SynthPass : public ScriptPass { log("\n"); } - string top_module, fsm_opts, memory_opts, abc; + string top_module, fsm_opts, memory_opts, abc, flatten_separator; bool autotop, flatten, noalumacc, nofsm, noabc, noshare, flowmap, booth; int lut; std::vector techmap_maps; @@ -120,6 +120,7 @@ struct SynthPass : public ScriptPass { booth = false; abc = "abc"; techmap_maps.clear(); + flatten_separator = ""; } void execute(std::vector args, RTLIL::Design *design) override @@ -154,6 +155,8 @@ struct SynthPass : public ScriptPass { } if (args[argidx] == "-flatten") { flatten = true; + if (design->scratchpad.count("flatten.separator")) + flatten_separator = design->scratchpad_get_string("flatten.separator"); continue; } if (args[argidx] == "-lut" && argidx + 1 < args.size()) { @@ -239,8 +242,12 @@ struct SynthPass : public ScriptPass { if (check_label("coarse")) { run("proc"); - if (flatten || help_mode) - run("flatten", " (if -flatten)"); + if (flatten || help_mode) { + if (!flatten_separator.empty()) + run(stringf("flatten -separator %s", flatten_separator.c_str()), " (if -flatten)"); + else + run("flatten", " (if -flatten)"); + } run("opt_expr"); run("opt_clean"); run("check"); From c4f90693aa1efe1e416dc385c0ee5e68840a5c31 Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Sat, 18 Jan 2025 10:37:56 -0700 Subject: [PATCH 2/3] Revert "add support for passing flatten -separator to flatten in synth" This reverts commit 63074ccb895c504d7a766b199ed7fad42a54e114. --- techlibs/common/synth.cc | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/techlibs/common/synth.cc b/techlibs/common/synth.cc index a1ce1ae1b11..74a484d59ae 100644 --- a/techlibs/common/synth.cc +++ b/techlibs/common/synth.cc @@ -98,7 +98,7 @@ struct SynthPass : public ScriptPass { log("\n"); } - string top_module, fsm_opts, memory_opts, abc, flatten_separator; + string top_module, fsm_opts, memory_opts, abc; bool autotop, flatten, noalumacc, nofsm, noabc, noshare, flowmap, booth; int lut; std::vector techmap_maps; @@ -120,7 +120,6 @@ struct SynthPass : public ScriptPass { booth = false; abc = "abc"; techmap_maps.clear(); - flatten_separator = ""; } void execute(std::vector args, RTLIL::Design *design) override @@ -155,8 +154,6 @@ struct SynthPass : public ScriptPass { } if (args[argidx] == "-flatten") { flatten = true; - if (design->scratchpad.count("flatten.separator")) - flatten_separator = design->scratchpad_get_string("flatten.separator"); continue; } if (args[argidx] == "-lut" && argidx + 1 < args.size()) { @@ -242,12 +239,8 @@ struct SynthPass : public ScriptPass { if (check_label("coarse")) { run("proc"); - if (flatten || help_mode) { - if (!flatten_separator.empty()) - run(stringf("flatten -separator %s", flatten_separator.c_str()), " (if -flatten)"); - else - run("flatten", " (if -flatten)"); - } + if (flatten || help_mode) + run("flatten", " (if -flatten)"); run("opt_expr"); run("opt_clean"); run("check"); From f0860459ac668a420915bca1628da5e634797f3a Mon Sep 17 00:00:00 2001 From: Peter Gadfort Date: Sat, 18 Jan 2025 10:45:19 -0700 Subject: [PATCH 3/3] add support for using scratchpad value for flatten.separator in flatten command --- passes/techmap/flatten.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/passes/techmap/flatten.cc b/passes/techmap/flatten.cc index 619fa4a689d..3425509b15f 100644 --- a/passes/techmap/flatten.cc +++ b/passes/techmap/flatten.cc @@ -357,6 +357,9 @@ struct FlattenPass : public Pass { FlattenWorker worker; + if (design->scratchpad.count("flatten.separator")) + worker.separator = design->scratchpad_get_string("flatten.separator"); + size_t argidx; for (argidx = 1; argidx < args.size(); argidx++) { if (args[argidx] == "-wb") {