Fixed a bug in opt_clean and some RTLIL API usage cleanups

This commit is contained in:
Clifford Wolf 2014-07-27 13:19:05 +02:00
parent d878fcbdc7
commit dbb3556e3f
2 changed files with 14 additions and 13 deletions

View File

@ -219,8 +219,8 @@ static void rmunused_module_signals(RTLIL::Module *module, bool purge_mode, bool
} }
std::vector<RTLIL::Wire*> maybe_del_wires; std::vector<RTLIL::Wire*> maybe_del_wires;
for (auto &it : module->wires_) { for (auto wire : module->wires())
RTLIL::Wire *wire = it.second; {
if ((!purge_mode && check_public_name(wire->name)) || wire->port_id != 0 || wire->get_bool_attribute("\\keep")) { if ((!purge_mode && check_public_name(wire->name)) || wire->port_id != 0 || wire->get_bool_attribute("\\keep")) {
RTLIL::SigSpec s1 = RTLIL::SigSpec(wire), s2 = s1; RTLIL::SigSpec s1 = RTLIL::SigSpec(wire), s2 = s1;
assign_map.apply(s2); assign_map.apply(s2);
@ -244,6 +244,7 @@ static void rmunused_module_signals(RTLIL::Module *module, bool purge_mode, bool
if (!used_signals.check_any(RTLIL::SigSpec(wire))) if (!used_signals.check_any(RTLIL::SigSpec(wire)))
maybe_del_wires.push_back(wire); maybe_del_wires.push_back(wire);
} }
RTLIL::SigSpec sig = assign_map(RTLIL::SigSpec(wire)); RTLIL::SigSpec sig = assign_map(RTLIL::SigSpec(wire));
if (!used_signals_nodrivers.check_any(sig)) { if (!used_signals_nodrivers.check_any(sig)) {
std::string unused_bits; std::string unused_bits;
@ -269,7 +270,7 @@ static void rmunused_module_signals(RTLIL::Module *module, bool purge_mode, bool
std::set<RTLIL::Wire*> del_wires; std::set<RTLIL::Wire*> del_wires;
int del_wires_count = 0; int del_wires_count = 0;
for (auto wire : del_wires) for (auto wire : maybe_del_wires)
if (!used_signals.check_any(RTLIL::SigSpec(wire))) { if (!used_signals.check_any(RTLIL::SigSpec(wire))) {
if (check_public_name(wire->name) && verbose) { if (check_public_name(wire->name) && verbose) {
log(" removing unused non-port wire %s.\n", wire->name.c_str()); log(" removing unused non-port wire %s.\n", wire->name.c_str());

View File

@ -37,20 +37,20 @@ static void replace_undriven(RTLIL::Design *design, RTLIL::Module *module)
SigPool used_signals; SigPool used_signals;
SigPool all_signals; SigPool all_signals;
for (auto &it : module->cells_) for (auto cell : module->cells())
for (auto &conn : it.second->connections()) { for (auto &conn : cell->connections()) {
if (!ct.cell_known(it.second->type) || ct.cell_output(it.second->type, conn.first)) if (!ct.cell_known(cell->type) || ct.cell_output(cell->type, conn.first))
driven_signals.add(sigmap(conn.second)); driven_signals.add(sigmap(conn.second));
if (!ct.cell_known(it.second->type) || ct.cell_input(it.second->type, conn.first)) if (!ct.cell_known(cell->type) || ct.cell_input(cell->type, conn.first))
used_signals.add(sigmap(conn.second)); used_signals.add(sigmap(conn.second));
} }
for (auto &it : module->wires_) { for (auto wire : module->wires()) {
if (it.second->port_input) if (wire->port_input)
driven_signals.add(sigmap(it.second)); driven_signals.add(sigmap(wire));
if (it.second->port_output) if (wire->port_output)
used_signals.add(sigmap(it.second)); used_signals.add(sigmap(wire));
all_signals.add(sigmap(it.second)); all_signals.add(sigmap(wire));
} }
all_signals.del(driven_signals); all_signals.del(driven_signals);