Added $macc eval model
authorClifford Wolf <clifford@clifford.at>
Sat, 6 Sep 2014 17:44:28 +0000 (19:44 +0200)
committerClifford Wolf <clifford@clifford.at>
Sat, 6 Sep 2014 17:44:28 +0000 (19:44 +0200)
kernel/consteval.h

index c73a0b3516eb3512d63c6b7f31b38639cd282ad2..f995c9cc2664e96187fbc53f79afe06a772f4fbc 100644 (file)
@@ -23,6 +23,7 @@
 #include "kernel/rtlil.h"
 #include "kernel/sigtools.h"
 #include "kernel/celltypes.h"
+#include "kernel/macc.h"
 
 struct ConstEval
 {
@@ -210,6 +211,27 @@ struct ConstEval
                                }
                        }
                }
+               else if (cell->type == "$macc")
+               {
+                       Macc macc;
+                       macc.from_cell(cell);
+
+                       if (!eval(macc.bit_ports, undef, cell))
+                               return false;
+
+                       for (auto &port : macc.ports) {
+                               if (!eval(port.in_a, undef, cell))
+                                       return false;
+                               if (!eval(port.in_b, undef, cell))
+                                       return false;
+                       }
+
+                       RTLIL::Const result(0, SIZE(cell->getPort("\\Y")));
+                       if (!macc.eval(result))
+                               log_abort();
+
+                       set(cell->getPort("\\Y"), result);
+               }
                else
                {
                        RTLIL::SigSpec sig_c, sig_d;