mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-13 04:28:18 +00:00
abc_exe: move 'count_outputs' check to abc
This commit is contained in:
parent
7347c13071
commit
5d9050a955
|
@ -219,16 +219,25 @@ struct Abc9Pass : public ScriptPass
|
||||||
tempdir_name = make_temp_dir(tempdir_name);
|
tempdir_name = make_temp_dir(tempdir_name);
|
||||||
|
|
||||||
run(stringf("write_xaiger -map %s/input.sym %s/input.xaig", tempdir_name.c_str(), tempdir_name.c_str()),
|
run(stringf("write_xaiger -map %s/input.sym %s/input.xaig", tempdir_name.c_str(), tempdir_name.c_str()),
|
||||||
"write_xaiger -map <abc-temp-dir>/input.sym <abc-temp-dir>/input.xaig");
|
"write_xaiger -map <abc-temp-dir>/input.sym <abc-temp-dir>/input.xaig");
|
||||||
run(stringf("%s -cwd %s", exe_cmd.str().c_str(), tempdir_name.c_str()),
|
|
||||||
"abc9_exe [options] -cwd <abc-temp-dir>");
|
|
||||||
|
|
||||||
run(stringf("read_aiger -xaiger -wideports -module_name %s$abc9 -map %s/input.sym %s/output.aig", log_id(mod->name), tempdir_name.c_str(), tempdir_name.c_str()),
|
int num_outputs = active_design->scratchpad_get_int("write_xaiger.num_outputs");
|
||||||
"read_aiger -xaiger -wideports -module_name <module-name>$abc9 -map <abc-temp-dir>/input.sym <abc-temp-dir>/output.aig");
|
log("Extracted %d AND gates and %d wires to a netlist network with %d inputs and %d outputs.\n",
|
||||||
run("abc9_ops -reintegrate");
|
active_design->scratchpad_get_int("write_xaiger.num_ands"),
|
||||||
|
active_design->scratchpad_get_int("write_xaiger.num_wires"),
|
||||||
|
active_design->scratchpad_get_int("write_xaiger.num_inputs"),
|
||||||
|
num_outputs);
|
||||||
|
if (num_outputs) {
|
||||||
|
run(stringf("%s -cwd %s", exe_cmd.str().c_str(), tempdir_name.c_str()),
|
||||||
|
"abc9_exe [options] -cwd <abc-temp-dir>");
|
||||||
|
run(stringf("read_aiger -xaiger -wideports -module_name %s$abc9 -map %s/input.sym %s/output.aig", log_id(mod->name), tempdir_name.c_str(), tempdir_name.c_str()),
|
||||||
|
"read_aiger -xaiger -wideports -module_name <module-name>$abc9 -map <abc-temp-dir>/input.sym <abc-temp-dir>/output.aig");
|
||||||
|
run("abc9_ops -reintegrate");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
log("Don't call ABC as there is nothing to map.\n");
|
||||||
|
|
||||||
if (cleanup)
|
if (cleanup) {
|
||||||
{
|
|
||||||
log("Removing temp directory.\n");
|
log("Removing temp directory.\n");
|
||||||
remove_directory(tempdir_name);
|
remove_directory(tempdir_name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,56 +244,43 @@ void abc9_module(RTLIL::Design *design, std::string script_file, std::string exe
|
||||||
fprintf(f, "%s\n", abc9_script.c_str());
|
fprintf(f, "%s\n", abc9_script.c_str());
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
int count_outputs = design->scratchpad_get_int("write_xaiger.num_outputs");
|
std::string buffer;
|
||||||
log("Extracted %d AND gates and %d wires to a netlist network with %d inputs and %d outputs.\n",
|
|
||||||
design->scratchpad_get_int("write_xaiger.num_ands"),
|
|
||||||
design->scratchpad_get_int("write_xaiger.num_wires"),
|
|
||||||
design->scratchpad_get_int("write_xaiger.num_inputs"),
|
|
||||||
count_outputs);
|
|
||||||
|
|
||||||
if (count_outputs > 0) {
|
log_header(design, "Executing ABC9.\n");
|
||||||
std::string buffer;
|
|
||||||
|
|
||||||
log_header(design, "Executing ABC9.\n");
|
if (!lut_costs.empty()) {
|
||||||
|
buffer = stringf("%s/lutdefs.txt", tempdir_name.c_str());
|
||||||
|
f = fopen(buffer.c_str(), "wt");
|
||||||
|
if (f == NULL)
|
||||||
|
log_error("Opening %s for writing failed: %s\n", buffer.c_str(), strerror(errno));
|
||||||
|
for (int i = 0; i < GetSize(lut_costs); i++)
|
||||||
|
fprintf(f, "%d %d.00 1.00\n", i+1, lut_costs.at(i));
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
|
||||||
if (!lut_costs.empty()) {
|
buffer = stringf("%s -s -f %s/abc.script 2>&1", exe_file.c_str(), tempdir_name.c_str());
|
||||||
buffer = stringf("%s/lutdefs.txt", tempdir_name.c_str());
|
log("Running ABC command: %s\n", replace_tempdir(buffer, tempdir_name, show_tempdir).c_str());
|
||||||
f = fopen(buffer.c_str(), "wt");
|
|
||||||
if (f == NULL)
|
|
||||||
log_error("Opening %s for writing failed: %s\n", buffer.c_str(), strerror(errno));
|
|
||||||
for (int i = 0; i < GetSize(lut_costs); i++)
|
|
||||||
fprintf(f, "%d %d.00 1.00\n", i+1, lut_costs.at(i));
|
|
||||||
fclose(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer = stringf("%s -s -f %s/abc.script 2>&1", exe_file.c_str(), tempdir_name.c_str());
|
|
||||||
log("Running ABC command: %s\n", replace_tempdir(buffer, tempdir_name, show_tempdir).c_str());
|
|
||||||
|
|
||||||
#ifndef YOSYS_LINK_ABC
|
#ifndef YOSYS_LINK_ABC
|
||||||
abc9_output_filter filt(tempdir_name, show_tempdir);
|
abc9_output_filter filt(tempdir_name, show_tempdir);
|
||||||
int ret = run_command(buffer, std::bind(&abc9_output_filter::next_line, filt, std::placeholders::_1));
|
int ret = run_command(buffer, std::bind(&abc9_output_filter::next_line, filt, std::placeholders::_1));
|
||||||
#else
|
#else
|
||||||
// These needs to be mutable, supposedly due to getopt
|
// These needs to be mutable, supposedly due to getopt
|
||||||
char *abc9_argv[5];
|
char *abc9_argv[5];
|
||||||
string tmp_script_name = stringf("%s/abc.script", tempdir_name.c_str());
|
string tmp_script_name = stringf("%s/abc.script", tempdir_name.c_str());
|
||||||
abc9_argv[0] = strdup(exe_file.c_str());
|
abc9_argv[0] = strdup(exe_file.c_str());
|
||||||
abc9_argv[1] = strdup("-s");
|
abc9_argv[1] = strdup("-s");
|
||||||
abc9_argv[2] = strdup("-f");
|
abc9_argv[2] = strdup("-f");
|
||||||
abc9_argv[3] = strdup(tmp_script_name.c_str());
|
abc9_argv[3] = strdup(tmp_script_name.c_str());
|
||||||
abc9_argv[4] = 0;
|
abc9_argv[4] = 0;
|
||||||
int ret = Abc_RealMain(4, abc9_argv);
|
int ret = Abc_RealMain(4, abc9_argv);
|
||||||
free(abc9_argv[0]);
|
free(abc9_argv[0]);
|
||||||
free(abc9_argv[1]);
|
free(abc9_argv[1]);
|
||||||
free(abc9_argv[2]);
|
free(abc9_argv[2]);
|
||||||
free(abc9_argv[3]);
|
free(abc9_argv[3]);
|
||||||
#endif
|
#endif
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
log_error("ABC: execution of command \"%s\" failed: return code %d.\n", buffer.c_str(), ret);
|
log_error("ABC: execution of command \"%s\" failed: return code %d.\n", buffer.c_str(), ret);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
log("Don't call ABC as there is nothing to map.\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Abc9ExePass : public Pass {
|
struct Abc9ExePass : public Pass {
|
||||||
|
|
Loading…
Reference in a new issue