From 0434f9d3d1decc563877f73a3b963bc3d0cdef6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 4 Oct 2023 23:21:40 +0200 Subject: [PATCH 1/2] booth: Fix vacancy check when summing down result In commit fedd12261 ("booth: Move away from explicit `Wire` pointers") a bug was introduced when checking for vacant slots in arrays holding some intermediate results. Non-wire SigBit values were taken to imply a vacant slot, but actually a constant one can make its way into those results, if the multiplier cell configuration is just right. Fix the vacancy check to address the bug. --- passes/techmap/booth.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/passes/techmap/booth.cc b/passes/techmap/booth.cc index 000dcff14ec..e1e6b360ab6 100644 --- a/passes/techmap/booth.cc +++ b/passes/techmap/booth.cc @@ -533,7 +533,7 @@ struct BoothPassWorker { // get the bits in this column. SigSpec column_bits; for (int row_ix = 0; row_ix < row_size; row_ix++) { - if (bits_to_reduce[row_ix][column_ix].wire) + if (bits_to_reduce[row_ix][column_ix] != State::S0) column_bits.append(bits_to_reduce[row_ix][column_ix]); } for (auto c : carry_bits_to_add_to_next_column) { @@ -750,7 +750,7 @@ struct BoothPassWorker { SigSpec first_csa_ips; // get the first 3 inputs, if possible for (var_ix = 0; var_ix < column_bits.size() && first_csa_ips.size() != 3; var_ix++) { - if (column_bits[var_ix].is_wire()) + if (column_bits[var_ix] != State::S0) first_csa_ips.append(column_bits[var_ix]); } @@ -782,7 +782,7 @@ struct BoothPassWorker { // get the next two variables to sum for (; var_ix <= column_bits.size() - 1 && csa_ips.size() < 2;) { // skip any empty bits - if (column_bits[var_ix].is_wire()) + if (column_bits[var_ix] != State::S0) csa_ips.append(column_bits[var_ix]); var_ix++; } From 4506e11d0fd1cd05a795203dc95a39f921c492b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Wed, 4 Oct 2023 23:29:40 +0200 Subject: [PATCH 2/2] booth: Extend test to catch bug from previous commit --- tests/techmap/booth.ys | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/techmap/booth.ys b/tests/techmap/booth.ys index ab7efc7b7fd..55dfdb8e9cd 100644 --- a/tests/techmap/booth.ys +++ b/tests/techmap/booth.ys @@ -1 +1,15 @@ -test_cell -s 1694091355 -n 100 -script booth_map_script.ys_ $mul +read_verilog <