mirror of
https://github.com/YosysHQ/yosys
synced 2026-05-22 18:09:41 +00:00
Add dont_use_cells to scl cache.
This commit is contained in:
parent
edd3ad525e
commit
94a215b4f7
3 changed files with 20 additions and 9 deletions
|
|
@ -1027,7 +1027,7 @@ void AbcModuleState::prepare_module(RTLIL::Design *design, RTLIL::Module *module
|
|||
run_abc.dont_use_args += stringf("-X \"%s\" ", dont_use_cell);
|
||||
}
|
||||
|
||||
std::string merged_scl = convert_liberty_files_to_merged_scl(config.liberty_files, config.exe_file);
|
||||
std::string merged_scl = convert_liberty_files_to_merged_scl(config.liberty_files, run_abc.dont_use_args, config.exe_file);
|
||||
if (!merged_scl.empty()) {
|
||||
run_abc.abc_script += stringf("read_scl \"%s\" ; ", merged_scl.c_str());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ void abc9_module(RTLIL::Design *design, std::string script_file, std::string exe
|
|||
dont_use_args += stringf("-X \"%s\" ", dont_use_cell);
|
||||
}
|
||||
|
||||
std::string merged_scl = convert_liberty_files_to_merged_scl(liberty_files, exe_file);
|
||||
std::string merged_scl = convert_liberty_files_to_merged_scl(liberty_files, dont_use_args, exe_file);
|
||||
if (!merged_scl.empty()) {
|
||||
abc9_script += stringf("read_scl \"%s\" ; ", merged_scl.c_str());
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -11,17 +11,18 @@ YOSYS_NAMESPACE_BEGIN
|
|||
|
||||
/*
|
||||
* convert_liberty_files_to_merged_scl() - Convert multiple Liberty files to a single merged SCL cache file.
|
||||
* @liberty_files - Vector of liberty file paths to merge
|
||||
* @abc_exe - Path to ABC executable for conversion
|
||||
* @liberty_files: Vector of liberty file paths to merge
|
||||
* @dont_use_args: Pre-built ABC -X flags string
|
||||
* @abc_exe: Path to ABC executable for conversion
|
||||
*
|
||||
* Return: Path to merged SCL cache file, or empty string if conversion fails
|
||||
*/
|
||||
inline std::string convert_liberty_files_to_merged_scl(const std::vector<std::string> &liberty_files, const std::string &abc_exe)
|
||||
inline std::string convert_liberty_files_to_merged_scl(const std::vector<std::string> &liberty_files, const std::string &dont_use_args, const std::string &abc_exe)
|
||||
{
|
||||
if (liberty_files.empty())
|
||||
return "";
|
||||
|
||||
// Sort filenames to ensure consistent hash regardless of order
|
||||
// Sort to ensure consistent hash regardless of order
|
||||
std::vector<std::string> sorted_files = liberty_files;
|
||||
std::sort(sorted_files.begin(), sorted_files.end());
|
||||
std::string hash_input;
|
||||
|
|
@ -38,6 +39,8 @@ inline std::string convert_liberty_files_to_merged_scl(const std::vector<std::st
|
|||
newest_mtime = liberty_stat.st_mtime;
|
||||
}
|
||||
|
||||
hash_input += dont_use_args;
|
||||
|
||||
// SCL filename
|
||||
std::string first_dir;
|
||||
size_t last_slash = liberty_files[0].find_last_of("/\\");
|
||||
|
|
@ -65,16 +68,17 @@ inline std::string convert_liberty_files_to_merged_scl(const std::vector<std::st
|
|||
}
|
||||
|
||||
if (need_convert) {
|
||||
// read_lib file1 ; read_lib -m file2 ; ... ; write_scl merged.scl
|
||||
// read_lib -X cell1 -X cell2 file1 ; read_lib -X cell1 -X cell2 -m file2 ; ... ; write_scl merged.scl
|
||||
std::string abc_script;
|
||||
bool first = true;
|
||||
|
||||
for (const std::string &liberty_file : liberty_files) {
|
||||
abc_script += stringf("read_lib %s-w \\\"%s\\\" ; ", first ? "" : "-m ", liberty_file.c_str());
|
||||
abc_script += stringf("read_lib %s%s-w \\\"%s\\\" ; ", dont_use_args.c_str(), first ? "" : "-m ", liberty_file.c_str());
|
||||
first = false;
|
||||
}
|
||||
|
||||
abc_script += stringf("write_scl \\\"%s\\\"", merged_scl.c_str());
|
||||
std::string temp_scl = merged_scl + ".tmp";
|
||||
abc_script += stringf("write_scl \\\"%s\\\"", temp_scl.c_str());
|
||||
std::string cmd = stringf("\"%s\" -c \"%s\" 2>&1", abc_exe.c_str(), abc_script.c_str());
|
||||
std::string abc_output;
|
||||
int ret = run_command(cmd, [&abc_output](const std::string &line) { abc_output += line + "\n"; });
|
||||
|
|
@ -84,6 +88,13 @@ inline std::string convert_liberty_files_to_merged_scl(const std::vector<std::st
|
|||
if (!abc_output.empty()) {
|
||||
log("ABC conversion output:\n%s", abc_output.c_str());
|
||||
}
|
||||
unlink(temp_scl.c_str());
|
||||
return "";
|
||||
}
|
||||
|
||||
if (rename(temp_scl.c_str(), merged_scl.c_str()) != 0) {
|
||||
log_warning("ABC: Failed to rename %s to %s, falling back to liberty format\n", temp_scl.c_str(), merged_scl.c_str());
|
||||
unlink(temp_scl.c_str());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue