preserve used $-wires with init attribute in opt_clean
authorClifford Wolf <clifford@clifford.at>
Fri, 22 May 2015 06:20:29 +0000 (08:20 +0200)
committerClifford Wolf <clifford@clifford.at>
Fri, 22 May 2015 06:20:29 +0000 (08:20 +0200)
passes/opt/opt_clean.cc

index 9d2a262a11224ab62917994d98e3efb0377e8b9e..a34da781a33adfb436a5b2d09c23c8620f039f43 100644 (file)
@@ -216,7 +216,7 @@ void rmunused_module_signals(RTLIL::Module *module, bool purge_mode, bool verbos
        std::vector<RTLIL::Wire*> maybe_del_wires;
        for (auto wire : module->wires())
        {
-               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") || wire->attributes.count("\\init")) {
                        RTLIL::SigSpec s1 = RTLIL::SigSpec(wire), s2 = s1;
                        assign_map.apply(s2);
                        if (!used_signals.check_any(s2) && wire->port_id == 0 && !wire->get_bool_attribute("\\keep")) {