From ebbb0e94797896579c618c1de62cf13b3776c48e Mon Sep 17 00:00:00 2001 From: Clifford Wolf Date: Mon, 28 Aug 2017 19:43:26 +0200 Subject: [PATCH] Further improve extract_fa pass --- passes/techmap/extract_fa.cc | 43 +++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/passes/techmap/extract_fa.cc b/passes/techmap/extract_fa.cc index 162a90306..b95ec26c3 100644 --- a/passes/techmap/extract_fa.cc +++ b/passes/techmap/extract_fa.cc @@ -28,6 +28,9 @@ struct ExtractFaConfig { bool enable_fa = false; bool enable_ha = false; + bool verbose = false; + int maxdepth = 20; + int maxbreadth = 6; }; // http://svn.clifford.at/handicraft/2016/bindec/bindec.c @@ -63,6 +66,9 @@ struct ExtractFaWorker dict, dict>> func2; dict, dict>> func3; + int count_func2; + int count_func3; + struct func2_and_info_t { bool inv_a, inv_b, inv_y; }; @@ -182,6 +188,7 @@ struct ExtractFaWorker if (func == xor2_func || func == xnor2_func) xorxnor2.insert(tuple(A, B)); + count_func2++; func2[tuple(A, B)][func].insert(root); } @@ -221,6 +228,7 @@ struct ExtractFaWorker if (func == xor3_func || func == xnor3_func) xorxnor3.insert(tuple(A, B, C)); + count_func3++; func3[tuple(A, B, C)][func].insert(root); } } @@ -284,7 +292,19 @@ struct ExtractFaWorker pool leaves = { root }; pool> cache; - find_partitions(root, leaves, cache, 20, 10); + if (config.verbose) + log(" checking %s\n", log_signal(it.first)); + + count_func2 = 0; + count_func3 = 0; + + find_partitions(root, leaves, cache, config.maxdepth, config.maxbreadth); + + if (config.verbose && count_func2 > 0) + log(" extracted %d two-input functions\n", count_func2); + + if (config.verbose && count_func3 > 0) + log(" extracted %d three-input functions\n", count_func3); } for (auto &key : xorxnor3) @@ -460,6 +480,15 @@ struct ExtractFaPass : public Pass { log(" Enable cell types (fa=full adder, ha=half adder)\n"); log(" All types are enabled if none of this options is used\n"); log("\n"); + log(" -d \n"); + log(" Set maximum depth for extracted logic cones (default=20)\n"); + log("\n"); + log(" -b \n"); + log(" Set maximum breadth for extracted logic cones (default=6)\n"); + log("\n"); + log(" -v\n"); + log(" Verbose output\n"); + log("\n"); } virtual void execute(std::vector args, RTLIL::Design *design) { @@ -479,6 +508,18 @@ struct ExtractFaPass : public Pass { config.enable_ha = true; continue; } + if (args[argidx] == "-v") { + config.verbose = true; + continue; + } + if (args[argidx] == "-d" && argidx+2 < args.size()) { + config.maxdepth = atoi(args[++argidx].c_str()); + continue; + } + if (args[argidx] == "-b" && argidx+2 < args.size()) { + config.maxbreadth = atoi(args[++argidx].c_str()); + continue; + } break; } extra_args(args, argidx, design); -- 2.30.2