flatten: only prepend $flatten once per wire.
authorwhitequark <whitequark@whitequark.org>
Mon, 8 Jun 2020 19:18:11 +0000 (19:18 +0000)
committerwhitequark <whitequark@whitequark.org>
Mon, 8 Jun 2020 20:19:41 +0000 (20:19 +0000)
passes/techmap/flatten.cc

index 66915916790029787168aec26941c8f2b1252b36..e913b3059611b8e7a29ddca9d5d0fb091e121843 100644 (file)
@@ -32,8 +32,12 @@ IdString concat_name(RTLIL::Cell *cell, IdString object_name)
 {
        if (object_name[0] == '\\')
                return stringf("%s.%s", cell->name.c_str(), object_name.c_str() + 1);
-       else
-               return stringf("$flatten%s.%s", cell->name.c_str(), object_name.c_str());
+       else {
+               std::string object_name_str = object_name.str();
+               if (object_name_str.substr(0, 8) == "$flatten")
+                       object_name_str.erase(0, 8);
+               return stringf("$flatten%s.%s", cell->name.c_str(), object_name_str.c_str());
+       }
 }
 
 template<class T>