Bugfixes in handling of "keep" attribute on wires
authorClifford Wolf <clifford@clifford.at>
Thu, 15 Oct 2015 12:57:28 +0000 (14:57 +0200)
committerClifford Wolf <clifford@clifford.at>
Thu, 15 Oct 2015 12:57:28 +0000 (14:57 +0200)
passes/opt/opt_muxtree.cc
passes/opt/wreduce.cc

index 15d59202ed48266047c14fda039cc752fadcb17b..905a01627e42e8e35f6aec3ea3225a8f612a4af0 100644 (file)
@@ -136,7 +136,7 @@ struct OptMuxtreeWorker
                        }
                }
                for (auto wire : module->wires()) {
-                       if (wire->port_output)
+                       if (wire->port_output || wire->get_bool_attribute("\\keep"))
                                for (int idx : sig2bits(RTLIL::SigSpec(wire)))
                                        bit2info[idx].seen_non_mux = true;
                }
index e551443ff4be1c3f62f06e375765a5ca2926b709..c194d428dc7acb8cd1fae6d32a9b08561a8b4dff 100644 (file)
@@ -51,6 +51,7 @@ struct WreduceWorker
 
        std::set<Cell*, IdString::compare_ptr_by_name<Cell>> work_queue_cells;
        std::set<SigBit> work_queue_bits;
+       pool<SigBit> keep_bits;
 
        WreduceWorker(WreduceConfig *config, Module *module) :
                        config(config), module(module), mi(module) { }
@@ -68,7 +69,7 @@ struct WreduceWorker
                for (int i = GetSize(sig_y)-1; i >= 0; i--)
                {
                        auto info = mi.query(sig_y[i]);
-                       if (!info->is_output && GetSize(info->ports) <= 1) {
+                       if (!info->is_output && GetSize(info->ports) <= 1 && !keep_bits.count(mi.sigmap(sig_y[i]))) {
                                bits_removed.push_back(Sx);
                                continue;
                        }
@@ -265,6 +266,11 @@ struct WreduceWorker
 
        void run()
        {
+               for (auto w : module->wires())
+                       if (w->get_bool_attribute("\\keep"))
+                               for (auto bit : mi.sigmap(w))
+                                       keep_bits.insert(bit);
+
                for (auto c : module->selected_cells())
                        work_queue_cells.insert(c);