From 5ce9113eda2e82034fd47106d6f75b8f30fd79ab Mon Sep 17 00:00:00 2001 From: David Shah Date: Sat, 4 May 2019 16:53:25 +0100 Subject: [PATCH 1/2] abc: Improve name recovery Signed-off-by: David Shah --- passes/techmap/abc.cc | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/passes/techmap/abc.cc b/passes/techmap/abc.cc index 547115459..d7500f3c3 100644 --- a/passes/techmap/abc.cc +++ b/passes/techmap/abc.cc @@ -330,18 +330,31 @@ void extract_cell(RTLIL::Cell *cell, bool keepff) std::string remap_name(RTLIL::IdString abc_name, RTLIL::Wire **orig_wire = nullptr) { std::string abc_sname = abc_name.substr(1); - if (abc_sname.substr(0, 5) == "ys__n") { + bool isnew = false; + if (abc_sname.substr(0, 4) == "new_") + { + abc_sname.erase(0, 4); + isnew = true; + } + if (abc_sname.substr(0, 5) == "ys__n") + { bool inv = abc_sname.back() == 'v'; if (inv) abc_sname.pop_back(); abc_sname.erase(0, 5); - if (abc_sname.find_last_not_of("012345689") == std::string::npos) { + if (std::isdigit(abc_sname.at(0))) + { int sid = std::stoi(abc_sname); - for (auto sig : signal_list) { - if (sig.id == sid && sig.bit.wire != nullptr) { + if (sid < GetSize(signal_list)) + { + auto sig = signal_list.at(sid); + if (sig.bit.wire != nullptr) + { std::stringstream sstr; sstr << "$abc$" << map_autoidx << "$" << sig.bit.wire->name.substr(1); if (sig.bit.wire->width != 1) sstr << "[" << sig.bit.offset << "]"; + if (isnew) + sstr << "_new"; if (inv) sstr << "_inv"; if (orig_wire != nullptr) From a84256aa366cd1e74de48444c136052564fdd0fe Mon Sep 17 00:00:00 2001 From: David Shah Date: Sat, 4 May 2019 17:17:30 +0100 Subject: [PATCH 2/2] abc: Fix handling of postfixed names (e.g. for retiming) Signed-off-by: David Shah --- passes/techmap/abc.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/passes/techmap/abc.cc b/passes/techmap/abc.cc index d7500f3c3..5b19d84fb 100644 --- a/passes/techmap/abc.cc +++ b/passes/techmap/abc.cc @@ -338,12 +338,13 @@ std::string remap_name(RTLIL::IdString abc_name, RTLIL::Wire **orig_wire = nullp } if (abc_sname.substr(0, 5) == "ys__n") { - bool inv = abc_sname.back() == 'v'; - if (inv) abc_sname.pop_back(); abc_sname.erase(0, 5); if (std::isdigit(abc_sname.at(0))) { int sid = std::stoi(abc_sname); + size_t postfix_start = abc_sname.find_first_not_of("0123456789"); + std::string postfix = postfix_start != std::string::npos ? abc_sname.substr(postfix_start) : ""; + if (sid < GetSize(signal_list)) { auto sig = signal_list.at(sid); @@ -355,8 +356,7 @@ std::string remap_name(RTLIL::IdString abc_name, RTLIL::Wire **orig_wire = nullp sstr << "[" << sig.bit.offset << "]"; if (isnew) sstr << "_new"; - if (inv) - sstr << "_inv"; + sstr << postfix; if (orig_wire != nullptr) *orig_wire = sig.bit.wire; return sstr.str();