From d77b792156b439ce7ae6a8900d0166fb1c849ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Thu, 22 Feb 2024 17:22:56 +0100 Subject: [PATCH 1/5] synth: Put in missing bounds check for `-lut` --- techlibs/common/synth.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/techlibs/common/synth.cc b/techlibs/common/synth.cc index e5013678aa4..f604b67c97d 100644 --- a/techlibs/common/synth.cc +++ b/techlibs/common/synth.cc @@ -151,7 +151,7 @@ struct SynthPass : public ScriptPass { flatten = true; continue; } - if (args[argidx] == "-lut") { + if (args[argidx] == "-lut" && argidx + 1 < args.size()) { lut = atoi(args[++argidx].c_str()); continue; } From ba07cba6ce73a979e4ce25a027fbf9cb8723a8c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Thu, 22 Feb 2024 17:23:28 +0100 Subject: [PATCH 2/5] synth: Introduce `-inject` for amending techmap --- techlibs/common/synth.cc | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/techlibs/common/synth.cc b/techlibs/common/synth.cc index f604b67c97d..7da9ba666da 100644 --- a/techlibs/common/synth.cc +++ b/techlibs/common/synth.cc @@ -88,6 +88,10 @@ struct SynthPass : public ScriptPass { log(" read/write collision\" (same result as setting the no_rw_check\n"); log(" attribute on all memories).\n"); log("\n"); + log(" -inject filename\n"); + log(" inject rules from the given file to complement the default\n"); + log(" mapping library in the `techmap` step. this option can be\n"); + log(" repeated.\n"); log("\n"); log("The following commands are executed by this synthesis command:\n"); help_script(); @@ -96,8 +100,8 @@ struct SynthPass : public ScriptPass { string top_module, fsm_opts, memory_opts, abc; bool autotop, flatten, noalumacc, nofsm, noabc, noshare, flowmap, booth; - int lut; + std::vector techmap_inject; void clear_flags() override { @@ -115,6 +119,7 @@ struct SynthPass : public ScriptPass { flowmap = false; booth = false; abc = "abc"; + techmap_inject.clear(); } void execute(std::vector args, RTLIL::Design *design) override @@ -192,6 +197,10 @@ struct SynthPass : public ScriptPass { memory_opts += " -no-rw-check"; continue; } + if (args[argidx] == "-inject" && argidx + 1 < args.size()) { + techmap_inject.push_back(args[++argidx]); + continue; + } break; } extra_args(args, argidx, design); @@ -261,7 +270,17 @@ struct SynthPass : public ScriptPass { run("opt -fast -full"); run("memory_map"); run("opt -full"); - run("techmap"); + if (help_mode) { + run("techmap", " (unless -inject)"); + run("techmap -map +/techmap.v -map ", " (if -inject)"); + } else { + std::string techmap_opts; + if (!techmap_inject.empty()) + techmap_opts += " -map +/techmap.v"; + for (auto fn : techmap_inject) + techmap_opts += stringf(" -map %s", fn.c_str()); + run("techmap" + techmap_opts); + } if (help_mode) { run("techmap -map +/gate2lut.v", "(if -noabc and -lut)"); run("clean; opt_lut", " (if -noabc and -lut)"); From 53ca7b48f86fd3d5bc9ed0f319e24d0086dc12bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Thu, 22 Feb 2024 22:00:56 +0100 Subject: [PATCH 3/5] techmap: Fix help message wording --- passes/techmap/techmap.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/passes/techmap/techmap.cc b/passes/techmap/techmap.cc index 144f596c88c..db395315ce6 100644 --- a/passes/techmap/techmap.cc +++ b/passes/techmap/techmap.cc @@ -1041,8 +1041,8 @@ struct TechmapPass : public Pass { log("\n"); log("When a port on a module in the map file has the 'techmap_autopurge' attribute\n"); log("set, and that port is not connected in the instantiation that is mapped, then\n"); - log("then a cell port connected only to such wires will be omitted in the mapped\n"); - log("version of the circuit.\n"); + log("a cell port connected only to such wires will be omitted in the mapped version\n"); + log("of the circuit.\n"); log("\n"); log("All wires in the modules from the map file matching the pattern _TECHMAP_*\n"); log("or *._TECHMAP_* are special wires that are used to pass instructions from\n"); From d2a7ce04ea5a5bd6d3324e3ec81c3ede0ceab5d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Fri, 1 Mar 2024 10:54:51 +0100 Subject: [PATCH 4/5] synth: Rename `-inject` to `-extra-map` --- techlibs/common/synth.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/techlibs/common/synth.cc b/techlibs/common/synth.cc index 7da9ba666da..68be34f2024 100644 --- a/techlibs/common/synth.cc +++ b/techlibs/common/synth.cc @@ -88,8 +88,8 @@ struct SynthPass : public ScriptPass { log(" read/write collision\" (same result as setting the no_rw_check\n"); log(" attribute on all memories).\n"); log("\n"); - log(" -inject filename\n"); - log(" inject rules from the given file to complement the default\n"); + log(" -extra-map filename\n"); + log(" source extra rules from the given file to complement the default\n"); log(" mapping library in the `techmap` step. this option can be\n"); log(" repeated.\n"); log("\n"); @@ -101,7 +101,7 @@ struct SynthPass : public ScriptPass { string top_module, fsm_opts, memory_opts, abc; bool autotop, flatten, noalumacc, nofsm, noabc, noshare, flowmap, booth; int lut; - std::vector techmap_inject; + std::vector techmap_maps; void clear_flags() override { @@ -119,7 +119,7 @@ struct SynthPass : public ScriptPass { flowmap = false; booth = false; abc = "abc"; - techmap_inject.clear(); + techmap_maps.clear(); } void execute(std::vector args, RTLIL::Design *design) override @@ -197,8 +197,8 @@ struct SynthPass : public ScriptPass { memory_opts += " -no-rw-check"; continue; } - if (args[argidx] == "-inject" && argidx + 1 < args.size()) { - techmap_inject.push_back(args[++argidx]); + if (args[argidx] == "-extra-map" && argidx + 1 < args.size()) { + techmap_maps.push_back(args[++argidx]); continue; } break; @@ -275,9 +275,9 @@ struct SynthPass : public ScriptPass { run("techmap -map +/techmap.v -map ", " (if -inject)"); } else { std::string techmap_opts; - if (!techmap_inject.empty()) + if (!techmap_maps.empty()) techmap_opts += " -map +/techmap.v"; - for (auto fn : techmap_inject) + for (auto fn : techmap_maps) techmap_opts += stringf(" -map %s", fn.c_str()); run("techmap" + techmap_opts); } From 570a8f12b58e4cfbd10deb042b217165c2103bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 6 Mar 2024 14:55:43 +0100 Subject: [PATCH 5/5] synth: Fix out-of-sync help message Co-authored-by: N. Engelhardt --- techlibs/common/synth.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/techlibs/common/synth.cc b/techlibs/common/synth.cc index 68be34f2024..74a484d59ae 100644 --- a/techlibs/common/synth.cc +++ b/techlibs/common/synth.cc @@ -271,8 +271,8 @@ struct SynthPass : public ScriptPass { run("memory_map"); run("opt -full"); if (help_mode) { - run("techmap", " (unless -inject)"); - run("techmap -map +/techmap.v -map ", " (if -inject)"); + run("techmap", " (unless -extra-map)"); + run("techmap -map +/techmap.v -map ", " (if -extra-map)"); } else { std::string techmap_opts; if (!techmap_maps.empty())