From 750d536bbab93acd090bfce8453ae4d739a7e90d Mon Sep 17 00:00:00 2001 From: Tianji Liu Date: Wed, 4 Mar 2026 11:24:24 +0800 Subject: [PATCH] abc: new option to pass ABC read_lib args --- passes/techmap/abc.cc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/passes/techmap/abc.cc b/passes/techmap/abc.cc index 6e5b1fba8..3bc97b770 100644 --- a/passes/techmap/abc.cc +++ b/passes/techmap/abc.cc @@ -125,6 +125,7 @@ struct AbcConfig std::vector liberty_files; std::vector genlib_files; std::string constr_file; + std::string abc_liberty_args; vector lut_costs; std::string delay_target; std::string sop_inputs; @@ -1024,7 +1025,7 @@ void AbcModuleState::prepare_module(RTLIL::Design *design, RTLIL::Module *module } bool first_lib = true; for (std::string liberty_file : config.liberty_files) { - abc_script += stringf("read_lib %s %s -w \"%s\" ; ", dont_use_args, first_lib ? "" : "-m", liberty_file); + abc_script += stringf("read_lib %s %s %s -w \"%s\" ; ", dont_use_args, first_lib ? "" : "-m", config.abc_liberty_args, liberty_file); first_lib = false; } for (std::string liberty_file : config.genlib_files) @@ -2026,6 +2027,10 @@ struct AbcPass : public Pass { log(" preserve naming by an equivalence check between the original and\n"); log(" post-ABC netlists (experimental).\n"); log("\n"); + log(" -liberty_args \n"); + log(" when -liberty is used, also pass the specified arguments to ABC\n"); + log(" command \"read_lib\". Example: -liberty_args \"-G 250\"\n"); + log("\n"); log("When no target cell library is specified the Yosys standard cell library is\n"); log("loaded into ABC before the ABC script is executed.\n"); log("\n"); @@ -2217,6 +2222,14 @@ struct AbcPass : public Pass { config.markgroups = true; continue; } + if (arg == "-liberty_args" && argidx+1 < args.size()) { + config.abc_liberty_args = args[++argidx]; + if (!config.abc_liberty_args.empty()) { + if (config.abc_liberty_args[0] == '\"' && config.abc_liberty_args.back() == '\"') + config.abc_liberty_args = config.abc_liberty_args.substr(1, config.abc_liberty_args.size() - 2); + } + continue; + } break; } extra_args(args, argidx, design);