From e7580a2f4fc66b87cb24c69456326bcc5a584558 Mon Sep 17 00:00:00 2001 From: Cassie Jones Date: Sat, 7 Mar 2020 00:04:33 +0100 Subject: [PATCH] Add -nosynth flag to skip internal synthesis This is useful if you want to have control the initial coarse-grained synthesis, you can disable the synthesis that synth_nan does and provide your own. --- nangate.cc | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/nangate.cc b/nangate.cc index 673e294..de0111a 100644 --- a/nangate.cc +++ b/nangate.cc @@ -7,10 +7,6 @@ USING_YOSYS_NAMESPACE PRIVATE_NAMESPACE_BEGIN -static bool is_width(const string &arg) { - return arg == "-w" or arg == "-width" or arg == "--width"; -} - struct NandToNaNWorker { int nand_count = 0, not_count = 0, b2f_count = 0, f2b_count = 0; @@ -84,7 +80,7 @@ struct NandToNaNPass : public Pass { int width = 3; size_t argidx = 1; for (; argidx < args.size(); ++argidx) { - if (is_width(args[argidx]) and argidx + 1 < args.size()) { + if (args[argidx] == "-width" and argidx + 1 < args.size()) { try { width = std::stoi(args[++argidx]); } catch (...) { @@ -115,7 +111,7 @@ struct DffToFpPass : public Pass { int width = 3; size_t argidx = 1; for (; argidx < args.size(); ++argidx) { - if (is_width(args[argidx]) and argidx + 1 < args.size()) { + if (args[argidx] == "-width" and argidx + 1 < args.size()) { try { width = std::stoi(args[++argidx]); } catch (...) { @@ -223,9 +219,13 @@ struct SynthNaN : public Pass { log(" -width "); log(" synthesize with a given floating-point with (default=3)"); log(""); + log(" -nosynth "); + log(" skip the pre-run synthesis step. Requires that the circuit"); + log(" has already been synthesized down to NAND and NOT gates."); + log(""); log("Runs the equivalent of the following script:\n\n"); - log(" synth [-top ]\n"); - log(" abc -g NAND\n"); + log(" synth [-top ] (unless -nosynth)\n"); + log(" abc -g NAND (unless -nosynth)\n"); log(" nand_to_nan [-width ]\n"); log(" share_nan\n"); log(" dff_nan [-width ]\n"); @@ -240,23 +240,30 @@ struct SynthNaN : public Pass { log_push(); size_t argidx = 1; + bool synth = true; for (; argidx < args.size(); ++argidx) { if (args[argidx] == "-top" and argidx + 1 < args.size()) { synth_args += " -top "; synth_args += args[++argidx]; continue; } - if (is_width(args[argidx]) and argidx + 1 < args.size()) { - width_args += " --width "; + if (args[argidx] == "-width" and argidx + 1 < args.size()) { + width_args += " -width "; width_args += args[++argidx]; continue; } + if (args[argidx] == "-nosynth") { + synth = false; + continue; + } break; } extra_args(args, argidx, design, false); - Pass::call(design, "synth" + synth_args); - Pass::call(design, "abc -g NAND"); + if (synth) { + Pass::call(design, "synth" + synth_args); + Pass::call(design, "abc -g NAND"); + } Pass::call(design, "nand_to_nan" + width_args); Pass::call(design, "share_nan"); Pass::call(design, "dff_nan" + width_args); -- 2.47.0