diff --git a/techlibs/ice40/ice40_dsp.pmg b/techlibs/ice40/ice40_dsp.pmg index 9099dd3c4..285e3ceee 100644 --- a/techlibs/ice40/ice40_dsp.pmg +++ b/techlibs/ice40/ice40_dsp.pmg @@ -46,17 +46,19 @@ code sigA sigB sigH // Only care about those bits that are used int i; - for (i = 0; i < GetSize(O); i++) { - if (nusers(O[i]) <= 1) - break; - sigH.append(O[i]); - } + for (i = GetSize(O) - 1; i > 0 && nusers(O[i]) <= 1; i--) + ; // This sigM could have no users if downstream sinks (e.g. $add) is // narrower than $mul result, for example if (i == 0) reject; - log_assert(nusers(O.extract_end(i)) <= 1); + for (int j = 0; j <= i; j++) + if (nusers(O[j]) == 0) + sigH.append(module->addWire(NEW_ID)); + else + sigH.append(O[j]); + endcode code argQ ffA sigA clock clock_pol