Undo flatten -scopeinfo to -noscopeinfo

This commit is contained in:
Akash Levy 2025-04-22 16:32:22 -07:00
parent 4fad708795
commit e9bf25f333
3 changed files with 15 additions and 24 deletions

View File

@ -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<class T>
@ -61,15 +51,16 @@ void map_sigspec(const dict<RTLIL::Wire*, RTLIL::Wire*> &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<class T>
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") {

View File

@ -22,7 +22,7 @@ endmodule
EOT
hierarchy -top top
flatten -scopeinfo -scopename
flatten -scopename
prep
write_json json_scopeinfo.out

View File

@ -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