abc9: enable gzipped Liberty files, extend abc_prep

This commit is contained in:
Emil J. Tywoniak 2025-01-13 12:53:47 +01:00
parent 0885780460
commit b7fe85df4d
4 changed files with 23 additions and 7 deletions

View File

@ -2037,9 +2037,7 @@ struct AbcPass : public Pass {
enabled_gates.insert("MUX");
// enabled_gates.insert("NMUX");
}
std::string lib_tempdir_name = AbcPrep::tmp_base(cleanup) + "yosys-abc-lib-XXXXXX";
lib_tempdir_name = make_temp_dir(lib_tempdir_name);
AbcPrep::lib_to_tmp(lib_tempdir_name, liberty_files);
auto lib_tempdir_name = AbcPrep::make_tmp_extract_lib(liberty_files, cleanup);
for (auto mod : design->selected_modules())
{

View File

@ -191,6 +191,7 @@ struct Abc9Pass : public ScriptPass
bool lut_mode;
int maxlut;
std::string box_file;
std::vector<std::string> liberty_files;
void clear_flags() override
{
@ -223,13 +224,17 @@ struct Abc9Pass : public ScriptPass
if ((arg == "-exe" || arg == "-script" || arg == "-D" ||
/*arg == "-S" ||*/ arg == "-lut" || arg == "-luts" ||
/*arg == "-box" ||*/ arg == "-W" || arg == "-genlib" ||
arg == "-constr" || arg == "-dont_use" || arg == "-liberty") &&
arg == "-constr" || arg == "-dont_use") &&
argidx+1 < args.size()) {
if (arg == "-lut" || arg == "-luts")
lut_mode = true;
exe_cmd << " " << arg << " " << args[++argidx];
continue;
}
if (arg == "-liberty") {
liberty_files.push_back(args[++argidx]);
continue;
}
if (arg == "-fast" || /* arg == "-dff" || */
/* arg == "-nocleanup" || */ arg == "-showtmp") {
exe_cmd << " " << arg;
@ -276,7 +281,10 @@ struct Abc9Pass : public ScriptPass
log_header(design, "Executing ABC9 pass.\n");
log_push();
auto lib_tmpdir = AbcPrep::make_tmp_extract_lib(liberty_files, cleanup);
run_script(design, run_from, run_to);
if (cleanup)
remove_directory(lib_tmpdir);
log_pop();
}

View File

@ -115,9 +115,7 @@ struct AbcNewPass : public ScriptPass {
log_header(d, "Executing ABC_NEW pass.\n");
log_push();
std::string lib_tmpdir = AbcPrep::tmp_base(cleanup) + "yosys-abc-lib-XXXXXX";
lib_tmpdir = make_temp_dir(lib_tmpdir);
AbcPrep::lib_to_tmp(lib_tmpdir, liberty_files);
auto lib_tmpdir = AbcPrep::make_tmp_extract_lib(liberty_files, cleanup);
run_script(d, run_from, run_to);
if (cleanup)
remove_directory(lib_tmpdir);

View File

@ -49,6 +49,18 @@ namespace AbcPrep {
}
}
}
inline std::string make_tmp_extract_lib(std::vector<std::string>& liberty_files, bool cleanup)
{
// Compose the path
std::string lib_tmpdir = AbcPrep::tmp_base(cleanup) + "yosys-abc-lib-XXXXXX";
// Create the directory
lib_tmpdir = make_temp_dir(lib_tmpdir);
// Extract compressed liberty files to directory, rewrite liberty_files
AbcPrep::lib_to_tmp(lib_tmpdir, liberty_files);
// Caller responsible for cleanup
return lib_tmpdir;
}
};
#endif /* ABC_PREP_H */