3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-12 20:18:20 +00:00

Improved handling of private names in opt_clean and rename commands

This commit is contained in:
Clifford Wolf 2013-08-07 18:39:49 +02:00
parent 3f5d7df603
commit e729857647
2 changed files with 39 additions and 7 deletions

View file

@ -63,6 +63,12 @@ struct RenamePass : public Pass {
log("Rename the specified object. Note that selection patterns are not supported\n"); log("Rename the specified object. Note that selection patterns are not supported\n");
log("by this command.\n"); log("by this command.\n");
log("\n"); log("\n");
log("\n");
log(" rename -enumerate [selection]\n");
log("\n");
log("Assign short auto-generated names to all selected wires and cells with private\n");
log("names.\n");
log("\n");
} }
virtual void execute(std::vector<std::string> args, RTLIL::Design *design) virtual void execute(std::vector<std::string> args, RTLIL::Design *design)
{ {
@ -72,17 +78,43 @@ struct RenamePass : public Pass {
for (argidx = 1; argidx < args.size(); argidx++) for (argidx = 1; argidx < args.size(); argidx++)
{ {
std::string arg = args[argidx]; std::string arg = args[argidx];
//if (arg == "-enumerate") { if (arg == "-enumerate") {
// flag_enumerate = true; flag_enumerate = true;
// continue; continue;
//} }
break; break;
} }
if (flag_enumerate) if (flag_enumerate)
{ {
extra_args(args, argidx, design); extra_args(args, argidx, design);
log_cmd_error("Sorry: Enumeration mode is not implemented at the moment.\n");
for (auto &mod : design->modules)
{
int counter = 0;
RTLIL::Module *module = mod.second;
if (!design->selected(module))
continue;
std::map<RTLIL::IdString, RTLIL::Wire*> new_wires;
for (auto &it : module->wires) {
if (it.first[0] == '$' && design->selected(module, it.second))
do it.second->name = stringf("\\_%d_", counter++);
while (module->count_id(it.second->name) > 0);
new_wires[it.second->name] = it.second;
}
module->wires.swap(new_wires);
std::map<RTLIL::IdString, RTLIL::Cell*> new_cells;
for (auto &it : module->cells) {
if (it.first[0] == '$' && design->selected(module, it.second))
do it.second->name = stringf("\\_%d_", counter++);
while (module->count_id(it.second->name) > 0);
new_cells[it.second->name] = it.second;
}
module->cells.swap(new_cells);
}
} }
else else
{ {

View file

@ -122,10 +122,10 @@ static bool check_public_name(RTLIL::IdString id)
{ {
if (id[0] == '$') if (id[0] == '$')
return false; return false;
#if 0 if (id.substr(0, 2) == "\\_" && (id[id.size()-1] == '_' || id.find("_[") != std::string::npos))
return false;
if (id.find(".$") != std::string::npos) if (id.find(".$") != std::string::npos)
return false; return false;
#endif
return true; return true;
} }