From d72cca29457c0a52aeb060751735566a2b3b9840 Mon Sep 17 00:00:00 2001 From: Leo Moser Date: Wed, 24 Jun 2026 14:29:14 +0200 Subject: [PATCH] fabulous: add `-clkbuf-map` option, map to `$__FABULOUS_GBUF` Signed-off-by: Leo Moser --- techlibs/fabulous/synth_fabulous.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/techlibs/fabulous/synth_fabulous.cc b/techlibs/fabulous/synth_fabulous.cc index 401607424..11fcefbb2 100644 --- a/techlibs/fabulous/synth_fabulous.cc +++ b/techlibs/fabulous/synth_fabulous.cc @@ -58,6 +58,9 @@ struct SynthPass : public ScriptPass log(" -ff \n"); log(" convert FFs to cell types via dfflegalize (can be specified multiple times).\n"); log("\n"); + log(" -clkbuf-map \n"); + log(" insert clock buffers using clkbufmap and map to the specified Verilog file.\n"); + log("\n"); log(" -extra-plib \n"); log(" use the specified Verilog file for extra primitives (can be specified multiple\n"); log(" times).\n"); @@ -109,7 +112,7 @@ struct SynthPass : public ScriptPass log("\n"); } - string top_module, json_file, blif_file, fsm_opts, memory_opts, carry_mode; + string top_module, json_file, blif_file, fsm_opts, memory_opts, carry_mode, clkbuf_map; std::vector extra_plib, extra_map, extra_mlibmap; std::vector> extra_ffs; @@ -176,6 +179,10 @@ struct SynthPass : public ScriptPass extra_ffs.push_back({cell, init}); continue; } + if (args[argidx] == "-clkbuf-map" && argidx+1 < args.size()) { + clkbuf_map = args[++argidx]; + continue; + } if (args[argidx] == "-extra-plib" && argidx+1 < args.size()) { extra_plib.push_back(args[++argidx]); continue; @@ -361,6 +368,18 @@ struct SynthPass : public ScriptPass run(stringf("techmap -D LUT_K=%d -map +/fabulous/cells_map.v", lut)); run("clean"); } + + if (check_label("map_clkbufs")) { + if (help_mode) { + run("clkbufmap -buf $__FABULOUS_GBUF OUT:IN", "(if -clkbuf-map )"); + run("techmap -map ", "(if -clkbuf-map )"); + } else if (clkbuf_map != "") { + run("clkbufmap -buf $__FABULOUS_GBUF OUT:IN"); + run(stringf("techmap -map %s", clkbuf_map)); + run("clean"); + } + } + if (check_label("check")) { run("hierarchy -check"); run("stat");