Clean up pseudo-private member usage in `backends/edif/edif.cc`.

This commit is contained in:
Alberto Gonzalez 2020-04-01 04:37:07 +00:00
parent 68fef4ca7f
commit 057976c323
No known key found for this signature in database
GPG Key ID: 8395A8BA109708B2
1 changed files with 18 additions and 23 deletions

View File

@ -171,13 +171,12 @@ struct EdifBackend : public Backend {
extra_args(f, filename, args, argidx); extra_args(f, filename, args, argidx);
if (top_module_name.empty()) if (top_module_name.empty())
for (auto & mod_it:design->modules_) for (auto module : design->modules())
if (mod_it.second->get_bool_attribute("\\top")) if (module->get_bool_attribute("\\top"))
top_module_name = mod_it.first.str(); top_module_name = module->name.str();
for (auto module_it : design->modules_) for (auto module : design->modules())
{ {
RTLIL::Module *module = module_it.second;
if (module->get_blackbox_attribute()) if (module->get_blackbox_attribute())
continue; continue;
@ -185,14 +184,13 @@ struct EdifBackend : public Backend {
top_module_name = module->name.str(); top_module_name = module->name.str();
if (module->processes.size() != 0) if (module->processes.size() != 0)
log_error("Found unmapped processes in module %s: unmapped processes are not supported in EDIF backend!\n", RTLIL::id2cstr(module->name)); log_error("Found unmapped processes in module %s: unmapped processes are not supported in EDIF backend!\n", log_id(module->name));
if (module->memories.size() != 0) if (module->memories.size() != 0)
log_error("Found unmapped memories in module %s: unmapped memories are not supported in EDIF backend!\n", RTLIL::id2cstr(module->name)); log_error("Found unmapped memories in module %s: unmapped memories are not supported in EDIF backend!\n", log_id(module->name));
for (auto cell_it : module->cells_) for (auto cell : module->cells())
{ {
RTLIL::Cell *cell = cell_it.second; if (design->module(cell->type) == nullptr || design->module(cell->type)->get_blackbox_attribute()) {
if (!design->modules_.count(cell->type) || design->modules_.at(cell->type)->get_blackbox_attribute()) {
lib_cell_ports[cell->type]; lib_cell_ports[cell->type];
for (auto p : cell->connections()) for (auto p : cell->connections())
lib_cell_ports[cell->type][p.first] = GetSize(p.second); lib_cell_ports[cell->type][p.first] = GetSize(p.second);
@ -277,11 +275,11 @@ struct EdifBackend : public Backend {
// extract module dependencies // extract module dependencies
std::map<RTLIL::Module*, std::set<RTLIL::Module*>> module_deps; std::map<RTLIL::Module*, std::set<RTLIL::Module*>> module_deps;
for (auto &mod_it : design->modules_) { for (auto module : design->modules()) {
module_deps[mod_it.second] = std::set<RTLIL::Module*>(); module_deps[module] = std::set<RTLIL::Module*>();
for (auto &cell_it : mod_it.second->cells_) for (auto cell : module->cells())
if (design->modules_.count(cell_it.second->type) > 0) if (design->module(cell->type) != nullptr)
module_deps[mod_it.second].insert(design->modules_.at(cell_it.second->type)); module_deps[module].insert(design->module(cell->type));
} }
// simple good-enough topological sort // simple good-enough topological sort
@ -292,12 +290,12 @@ struct EdifBackend : public Backend {
for (auto &dep : it.second) for (auto &dep : it.second)
if (module_deps.count(dep) > 0) if (module_deps.count(dep) > 0)
goto not_ready_yet; goto not_ready_yet;
// log("Next in topological sort: %s\n", RTLIL::id2cstr(it.first->name)); // log("Next in topological sort: %s\n", log_id(it.first->name));
sorted_modules.push_back(it.first); sorted_modules.push_back(it.first);
not_ready_yet:; not_ready_yet:;
} }
if (sorted_modules_idx == sorted_modules.size()) if (sorted_modules_idx == sorted_modules.size())
log_error("Cyclic dependency between modules found! Cycle includes module %s.\n", RTLIL::id2cstr(module_deps.begin()->first->name)); log_error("Cyclic dependency between modules found! Cycle includes module %s.\n", log_id(module_deps.begin()->first->name));
while (sorted_modules_idx < sorted_modules.size()) while (sorted_modules_idx < sorted_modules.size())
module_deps.erase(sorted_modules.at(sorted_modules_idx++)); module_deps.erase(sorted_modules.at(sorted_modules_idx++));
} }
@ -339,8 +337,7 @@ struct EdifBackend : public Backend {
*f << stringf(" (view VIEW_NETLIST\n"); *f << stringf(" (view VIEW_NETLIST\n");
*f << stringf(" (viewType NETLIST)\n"); *f << stringf(" (viewType NETLIST)\n");
*f << stringf(" (interface\n"); *f << stringf(" (interface\n");
for (auto &wire_it : module->wires_) { for (auto wire : module->wires()) {
RTLIL::Wire *wire = wire_it.second;
if (wire->port_id == 0) if (wire->port_id == 0)
continue; continue;
const char *dir = "INOUT"; const char *dir = "INOUT";
@ -378,8 +375,7 @@ struct EdifBackend : public Backend {
*f << stringf(" (instance GND (viewRef VIEW_NETLIST (cellRef GND (libraryRef LIB))))\n"); *f << stringf(" (instance GND (viewRef VIEW_NETLIST (cellRef GND (libraryRef LIB))))\n");
*f << stringf(" (instance VCC (viewRef VIEW_NETLIST (cellRef VCC (libraryRef LIB))))\n"); *f << stringf(" (instance VCC (viewRef VIEW_NETLIST (cellRef VCC (libraryRef LIB))))\n");
} }
for (auto &cell_it : module->cells_) { for (auto cell : module->cells()) {
RTLIL::Cell *cell = cell_it.second;
*f << stringf(" (instance %s\n", EDIF_DEF(cell->name)); *f << stringf(" (instance %s\n", EDIF_DEF(cell->name));
*f << stringf(" (viewRef VIEW_NETLIST (cellRef %s%s))", EDIF_REF(cell->type), *f << stringf(" (viewRef VIEW_NETLIST (cellRef %s%s))", EDIF_REF(cell->type),
lib_cell_ports.count(cell->type) > 0 ? " (libraryRef LIB)" : ""); lib_cell_ports.count(cell->type) > 0 ? " (libraryRef LIB)" : "");
@ -459,8 +455,7 @@ struct EdifBackend : public Backend {
add_prop(p.first, p.second); add_prop(p.first, p.second);
*f << stringf("\n )\n"); *f << stringf("\n )\n");
} }
for (auto &wire_it : module->wires_) { for (auto wire : module->wires()) {
RTLIL::Wire *wire = wire_it.second;
if (!wire->get_bool_attribute(ID::keep)) if (!wire->get_bool_attribute(ID::keep))
continue; continue;
for(int i = 0; i < wire->width; i++) { for(int i = 0; i < wire->width; i++) {