Fixed handling of "keep" attribute on wires in opt_clean
authorClifford Wolf <clifford@clifford.at>
Sun, 16 Feb 2014 20:58:27 +0000 (21:58 +0100)
committerClifford Wolf <clifford@clifford.at>
Sun, 16 Feb 2014 20:58:27 +0000 (21:58 +0100)
passes/opt/opt_clean.cc

index 733a1cbf1789fc36c46b4901ca3f867b99064cea..d330fb7bd51782669200b261f3ce9a3e4d0762ae 100644 (file)
@@ -227,10 +227,10 @@ static void rmunused_module_signals(RTLIL::Module *module, bool purge_mode, bool
        std::vector<RTLIL::Wire*> del_wires;
        for (auto &it : module->wires) {
                RTLIL::Wire *wire = it.second;
-               if ((!purge_mode && check_public_name(wire->name)) || wire->port_id != 0) {
+               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;
                        assign_map.apply(s2);
-                       if (!used_signals.check_any(s2) && wire->port_id == 0) {
+                       if (!used_signals.check_any(s2) && wire->port_id == 0 && !wire->get_bool_attribute("\\keep")) {
                                del_wires.push_back(wire);
                        } else {
                                s1.expand();