Reject if not minlen from inside pattern matcher
authorEddie Hung <eddie@fpgeh.com>
Wed, 21 Aug 2019 21:26:24 +0000 (14:26 -0700)
committerEddie Hung <eddie@fpgeh.com>
Wed, 21 Aug 2019 21:26:24 +0000 (14:26 -0700)
passes/pmgen/xilinx_srl.cc
passes/pmgen/xilinx_srl.pmg

index 7240c2fa334325931ebd1fff5f1d6f3caefb482b..a4a8933079032bd419ab87e33a0ee498655461ae 100644 (file)
@@ -30,14 +30,11 @@ bool did_something;
 #include "passes/pmgen/ice40_dsp_pm.h"
 #include "passes/pmgen/peepopt_pm.h"
 
-void reduce_chain(xilinx_srl_pm &pm, int minlen)
+void reduce_chain(xilinx_srl_pm &pm)
 {
        auto &st = pm.st_reduce;
        auto &ud = pm.ud_reduce;
 
-       if (GetSize(ud.longest_chain) < minlen)
-               return;
-
        log("Found chain of length %d (%s):\n", GetSize(ud.longest_chain), log_id(st.first->type));
 
        auto last_cell = ud.longest_chain.back();
@@ -115,9 +112,14 @@ struct XilinxSrlPass : public Pass {
                }
                extra_args(args, argidx, design);
 
-               auto f = std::bind(reduce_chain, std::placeholders::_1, minlen);
-               for (auto module : design->selected_modules())
-                       while (xilinx_srl_pm(module, module->selected_cells()).run_reduce(f)) {}
+               for (auto module : design->selected_modules()) {
+                       bool did_something = false;
+                       do {
+                               auto pm = xilinx_srl_pm(module, module->selected_cells());
+                               pm.ud_reduce.minlen = minlen;
+                               did_something = pm.run_reduce(reduce_chain);
+                       } while (did_something);
+               }
        }
 } XilinxSrlPass;
 
index 69a9c7af2ee791f21cc4ea5fc31233cbbb56ad70..3a20966535887b01012a8d8eeba9310934fc2e1a 100644 (file)
@@ -2,6 +2,7 @@ pattern reduce
 
 udata <vector<Cell*>> chain longest_chain
 udata <pool<Cell*>> non_first_cells
+udata <int> minlen
 
 code
        non_first_cells.clear();
@@ -38,7 +39,7 @@ code
 finally
        chain.pop_back();
        log_assert(chain.empty());
-       if (GetSize(longest_chain) > 1)
+       if (GetSize(longest_chain) >= minlen)
                accept;
 endcode