@@ -57,6 +57,7 @@ synth -top my_design -booth
5757
5858#include " kernel/sigtools.h"
5959#include " kernel/yosys.h"
60+ #include " kernel/macc.h"
6061
6162USING_YOSYS_NAMESPACE
6263PRIVATE_NAMESPACE_BEGIN
@@ -207,12 +208,33 @@ struct BoothPassWorker {
207208 void run ()
208209 {
209210 for (auto cell : module ->selected_cells ()) {
210- if (cell->type != ID ($mul))
211+ SigSpec A, B, Y;
212+ bool is_signed;
213+
214+ if (cell->type == ID ($mul)) {
215+ A = cell->getPort (ID::A);
216+ B = cell->getPort (ID::B);
217+ Y = cell->getPort (ID::Y);
218+
219+ log_assert (cell->getParam (ID::A_SIGNED).as_bool () == cell->getParam (ID::B_SIGNED).as_bool ());
220+ is_signed = cell->getParam (ID::A_SIGNED).as_bool ();
221+ } else if (cell->type == ID ($macc)) {
222+ Macc macc;
223+ macc.from_cell (cell);
224+
225+ if (!macc.is_simple_product ()) {
226+ log_debug (" Not mapping cell %s: not a simple macc cell\n " , log_id (cell));
227+ continue ;
228+ }
229+
230+ A = macc.ports [0 ].in_a ;
231+ B = macc.ports [0 ].in_b ;
232+ is_signed = macc.ports [0 ].is_signed ;
233+ Y = cell->getPort (ID::Y);
234+ } else {
211235 continue ;
236+ }
212237
213- SigSpec A = cell->getPort (ID::A);
214- SigSpec B = cell->getPort (ID::B);
215- SigSpec Y = cell->getPort (ID::Y);
216238 int x_sz = GetSize (A), y_sz = GetSize (B), z_sz = GetSize (Y);
217239
218240 if (x_sz < 4 || y_sz < 4 || z_sz < 8 ) {
@@ -221,9 +243,6 @@ struct BoothPassWorker {
221243 continue ;
222244 }
223245
224- log_assert (cell->getParam (ID::A_SIGNED).as_bool () == cell->getParam (ID::B_SIGNED).as_bool ());
225- bool is_signed = cell->getParam (ID::A_SIGNED).as_bool ();
226-
227246 log (" Mapping cell %s to %s Booth multiplier\n " , log_id (cell), is_signed ? " signed" : " unsigned" );
228247
229248 // To simplify the generator size the arguments
0 commit comments