From e9bf25f333791025f3706536e2b9e1e2efc46014 Mon Sep 17 00:00:00 2001 From: Akash Levy Date: Tue, 22 Apr 2025 16:32:22 -0700 Subject: [PATCH] Undo flatten -scopeinfo to -noscopeinfo --- passes/techmap/flatten.cc | 29 ++++++++++------------------- tests/various/json_scopeinfo.ys | 2 +- tests/various/scopeinfo.ys | 8 ++++---- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/passes/techmap/flatten.cc b/passes/techmap/flatten.cc index 8412acc76..2e9beb227 100644 --- a/passes/techmap/flatten.cc +++ b/passes/techmap/flatten.cc @@ -30,17 +30,7 @@ PRIVATE_NAMESPACE_BEGIN IdString concat_name(RTLIL::Cell *cell, IdString object_name, const std::string &separator = ".") { - if (object_name[0] == '\\') - return stringf("%s%s%s", cell->name.c_str(), separator.c_str(), object_name.c_str() + 1); - else { - return stringf("%s.%s", cell->name.c_str(), object_name.c_str()); - /* - 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%s", cell->name.c_str(), separator.c_str(), object_name_str.c_str()); - */ - } + return stringf("%s%s%s", cell->name.c_str(), separator.c_str(), object_name.c_str() + 1); } template @@ -61,15 +51,16 @@ void map_sigspec(const dict &map, RTLIL::SigSpec &si struct FlattenWorker { bool ignore_wb = false; - bool create_scopeinfo = false; // SILIMATE: default false + bool create_scopeinfo = true; bool create_scopename = false; std::string separator = "."; template void map_attributes(RTLIL::Cell *cell, T *object, IdString orig_object_name) { - if (!create_scopeinfo && object->has_attribute(ID::src)) - object->add_strpool_attribute(ID::src, cell->get_strpool_attribute(ID::src)); + // SILIMATE: DISABLE SRC ATTRIBUTE ACCUMULATION + // if (!create_scopeinfo && object->has_attribute(ID::src)) + // object->add_strpool_attribute(ID::src, cell->get_strpool_attribute(ID::src)); // Preserve original names via the hdlname attribute, but only for objects with a fully public name. // If the '-scopename' option is used, also preserve the containing scope of private objects if their scope is fully public. @@ -335,9 +326,9 @@ struct FlattenPass : public Pass { log(" -wb\n"); log(" Ignore the 'whitebox' attribute on cell implementations.\n"); log("\n"); - log(" -scopeinfo\n"); - log(" Create '$scopeinfo' cells that preserve attributes of cells and\n"); - log(" modules that were removed during flattening. Without this option, the\n"); + log(" -noscopeinfo\n"); + log(" Do not create '$scopeinfo' cells that preserve attributes of cells and\n"); + log(" modules that were removed during flattening. With this option, the\n"); log(" 'src' attribute of a given cell is merged into all objects replacing\n"); log(" that cell, with multiple distinct 'src' locations separated by '|'.\n"); log(" With this option these 'src' locations can be found via the\n"); @@ -375,8 +366,8 @@ struct FlattenPass : public Pass { worker.ignore_wb = true; continue; } - if (args[argidx] == "-scopeinfo") { - worker.create_scopeinfo = true; + if (args[argidx] == "-noscopeinfo") { + worker.create_scopeinfo = false; continue; } if (args[argidx] == "-scopename") { diff --git a/tests/various/json_scopeinfo.ys b/tests/various/json_scopeinfo.ys index cbe383247..a5adbde10 100644 --- a/tests/various/json_scopeinfo.ys +++ b/tests/various/json_scopeinfo.ys @@ -22,7 +22,7 @@ endmodule EOT hierarchy -top top -flatten -scopeinfo -scopename +flatten -scopename prep write_json json_scopeinfo.out diff --git a/tests/various/scopeinfo.ys b/tests/various/scopeinfo.ys index bf90c1be0..f8d4ca31b 100644 --- a/tests/various/scopeinfo.ys +++ b/tests/various/scopeinfo.ys @@ -11,7 +11,7 @@ endmodule EOT hierarchy -top top -flatten -scopeinfo +flatten select -assert-count 1 top/n:some_inst top/t:$scopeinfo %i select -assert-count 1 top/n:some_inst top/r:TYPE=module %i @@ -46,7 +46,7 @@ endmodule EOT hierarchy -top top -flatten -scopeinfo +flatten select -assert-count 2 top/t:$scopeinfo select -assert-count 1 top/n:some_inst top/t:$scopeinfo %i @@ -87,11 +87,11 @@ endmodule EOT hierarchy -top top -flatten -scopeinfo top +flatten top select -assert-count 1 top/t:$scopeinfo setattr -mod -unset keep_hierarchy * -flatten -scopeinfo +flatten select -assert-count 2 top/t:$scopeinfo select -assert-count 1 top/n:some_inst top/t:$scopeinfo %i