From a998a4155d0e8a109bae80c3be24ed8465378b46 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Mon, 20 Apr 2020 10:30:10 -0700 Subject: xilinx/ecp5: disable abc9's "&mfs" optimisation Can sometimes fire an assertion, e.g. #1962 --- passes/techmap/abc9_exe.cc | 4 ++++ techlibs/ecp5/synth_ecp5.cc | 2 ++ techlibs/xilinx/synth_xilinx.cc | 2 ++ 3 files changed, 8 insertions(+) diff --git a/passes/techmap/abc9_exe.cc b/passes/techmap/abc9_exe.cc index 18618ff91..1aabbd396 100644 --- a/passes/techmap/abc9_exe.cc +++ b/passes/techmap/abc9_exe.cc @@ -219,6 +219,10 @@ void abc9_module(RTLIL::Design *design, std::string script_file, std::string exe for (size_t pos = abc9_script.find("{R}"); pos != std::string::npos; pos = abc9_script.find("{R}", pos)) abc9_script = abc9_script.substr(0, pos) + R + abc9_script.substr(pos+3); + if (design->scratchpad_get_bool("abc9.nomfs")) + for (size_t pos = abc9_script.find("&mfs"); pos != std::string::npos; pos = abc9_script.find("&mfs", pos)) + abc9_script = abc9_script.erase(pos, strlen("&mfs")); + abc9_script += stringf("; &ps -l; &write -n %s/output.aig", tempdir_name.c_str()); if (design->scratchpad_get_bool("abc9.verify")) { if (dff_mode) diff --git a/techlibs/ecp5/synth_ecp5.cc b/techlibs/ecp5/synth_ecp5.cc index ab740ea0d..317947978 100644 --- a/techlibs/ecp5/synth_ecp5.cc +++ b/techlibs/ecp5/synth_ecp5.cc @@ -324,6 +324,8 @@ struct SynthEcp5Pass : public ScriptPass if (abc9) { run("read_verilog -icells -lib -specify +/abc9_model.v +/ecp5/abc9_model.v"); + if (!help_mode && !active_design->scratchpad.count("abc9.nomfs")) + active_design->scratchpad_set_bool("abc9.nomfs", true); if (nowidelut) run("abc9 -maxlut 4 -W 200"); else diff --git a/techlibs/xilinx/synth_xilinx.cc b/techlibs/xilinx/synth_xilinx.cc index 1c190d37e..eb9fa1e82 100644 --- a/techlibs/xilinx/synth_xilinx.cc +++ b/techlibs/xilinx/synth_xilinx.cc @@ -613,6 +613,8 @@ struct SynthXilinxPass : public ScriptPass if (family != "xc7") log_warning("'synth_xilinx -abc9' not currently supported for the '%s' family, " "will use timing for 'xc7' instead.\n", family.c_str()); + if (!help_mode && !active_design->scratchpad.count("abc9.nomfs")) + active_design->scratchpad_set_bool("abc9.nomfs", true); std::string techmap_args = "-map +/xilinx/abc9_map.v -max_iter 1"; if (dff_mode) techmap_args += " -D DFF_MODE"; -- cgit v1.2.3 From 3d7b98335150bc5ffe58e312ea4433311af8b111 Mon Sep 17 00:00:00 2001 From: Eddie Hung Date: Mon, 20 Apr 2020 11:26:11 -0700 Subject: abc9: tolerate ABC nonzero exit code if output.aig; write before &mfs Re-enable mfs for xilinx/ecp5 speculatively -- if it fails, use pre-mfs result --- passes/techmap/abc9_exe.cc | 15 +++++++++++++-- techlibs/ecp5/synth_ecp5.cc | 2 -- techlibs/xilinx/synth_xilinx.cc | 2 -- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/passes/techmap/abc9_exe.cc b/passes/techmap/abc9_exe.cc index 1aabbd396..bad91a224 100644 --- a/passes/techmap/abc9_exe.cc +++ b/passes/techmap/abc9_exe.cc @@ -222,6 +222,13 @@ void abc9_module(RTLIL::Design *design, std::string script_file, std::string exe if (design->scratchpad_get_bool("abc9.nomfs")) for (size_t pos = abc9_script.find("&mfs"); pos != std::string::npos; pos = abc9_script.find("&mfs", pos)) abc9_script = abc9_script.erase(pos, strlen("&mfs")); + else { + auto s = stringf("&write -n %s/output.aig; ", tempdir_name.c_str()); + for (size_t pos = abc9_script.find("&mfs"); pos != std::string::npos; pos = abc9_script.find("&mfs", pos)) { + abc9_script = abc9_script.insert(pos, s); + pos += GetSize(s) + strlen("&mfs"); + } + } abc9_script += stringf("; &ps -l; &write -n %s/output.aig", tempdir_name.c_str()); if (design->scratchpad_get_bool("abc9.verify")) { @@ -276,8 +283,12 @@ void abc9_module(RTLIL::Design *design, std::string script_file, std::string exe free(abc9_argv[2]); free(abc9_argv[3]); #endif - if (ret != 0) - log_error("ABC: execution of command \"%s\" failed: return code %d.\n", buffer.c_str(), ret); + if (ret != 0) { + if (check_file_exists(stringf("%s/output.aig", tempdir_name.c_str()))) + log_warning("ABC: execution of command \"%s\" failed: return code %d.\n", buffer.c_str(), ret); + else + log_error("ABC: execution of command \"%s\" failed: return code %d.\n", buffer.c_str(), ret); + } } struct Abc9ExePass : public Pass { diff --git a/techlibs/ecp5/synth_ecp5.cc b/techlibs/ecp5/synth_ecp5.cc index 317947978..ab740ea0d 100644 --- a/techlibs/ecp5/synth_ecp5.cc +++ b/techlibs/ecp5/synth_ecp5.cc @@ -324,8 +324,6 @@ struct SynthEcp5Pass : public ScriptPass if (abc9) { run("read_verilog -icells -lib -specify +/abc9_model.v +/ecp5/abc9_model.v"); - if (!help_mode && !active_design->scratchpad.count("abc9.nomfs")) - active_design->scratchpad_set_bool("abc9.nomfs", true); if (nowidelut) run("abc9 -maxlut 4 -W 200"); else diff --git a/techlibs/xilinx/synth_xilinx.cc b/techlibs/xilinx/synth_xilinx.cc index eb9fa1e82..1c190d37e 100644 --- a/techlibs/xilinx/synth_xilinx.cc +++ b/techlibs/xilinx/synth_xilinx.cc @@ -613,8 +613,6 @@ struct SynthXilinxPass : public ScriptPass if (family != "xc7") log_warning("'synth_xilinx -abc9' not currently supported for the '%s' family, " "will use timing for 'xc7' instead.\n", family.c_str()); - if (!help_mode && !active_design->scratchpad.count("abc9.nomfs")) - active_design->scratchpad_set_bool("abc9.nomfs", true); std::string techmap_args = "-map +/xilinx/abc9_map.v -max_iter 1"; if (dff_mode) techmap_args += " -D DFF_MODE"; -- cgit v1.2.3