From da207cdce0ca9eac9a6aebc4f580cf3de3062d01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 22 Nov 2023 15:12:15 +0100 Subject: [PATCH] booth: Make less assumptions when aligning partial products --- passes/techmap/booth.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/passes/techmap/booth.cc b/passes/techmap/booth.cc index c94207a51..1d28f97f6 100644 --- a/passes/techmap/booth.cc +++ b/passes/techmap/booth.cc @@ -307,7 +307,7 @@ struct BoothPassWorker { SigSpec Y, // multiplier SigSpec Z) { // result - int x_sz = X.size(), z_sz = Z.size(); + int z_sz = Z.size(); SigSpec one_int, two_int, s_int, sb_int; int encoder_count = 0; @@ -376,7 +376,7 @@ struct BoothPassWorker { for (int i = 0; i < encoder_count + 1; i++) aligned_pp[i].extend_u0(z_sz); - AlignPP(x_sz, z_sz, ppij_int, aligned_pp); + AlignPP(z_sz, ppij_int, aligned_pp); // Debug: dump out aligned partial products. // Later on yosys will clean up unused constants @@ -609,7 +609,7 @@ struct BoothPassWorker { Pad out rows with zeros and left the opt pass clean them up. */ - void AlignPP(int x_sz, int z_sz, std::vector> &ppij_int, + void AlignPP(int z_sz, std::vector> &ppij_int, std::vector &aligned_pp) { unsigned aligned_pp_ix = aligned_pp.size() - 1; @@ -629,12 +629,10 @@ struct BoothPassWorker { // in first column of the last partial product // which is at index corresponding to size of multiplicand { + int prior_row_idx = get<1>(ppij_int[aligned_pp_ix - 1]); SigBit prior_row_sign = get<2>(ppij_int[aligned_pp_ix - 1]); - //if (prior_row_sign) { - log_assert(aligned_pp_ix < aligned_pp.size()); - log_assert(x_sz - 1 < (int)(aligned_pp[aligned_pp_ix].size())); - aligned_pp[aligned_pp_ix][x_sz - 1] = prior_row_sign; - //} + if (prior_row_idx < z_sz) + aligned_pp[aligned_pp_ix][prior_row_idx] = prior_row_sign; } for (int row_ix = aligned_pp_ix - 1; row_ix >= 0; row_ix--) {