From b277a672f14c6bd9bb90153946f68fb05b4792f0 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Tue, 22 Sep 2009 21:42:59 -0700 Subject: [PATCH] Fix the calculation of top pad in overlapped part select If the part select is too wide in both the top and bottom ends, this patch fixes the calculation of the top pad. The compiler was generating too much pad if the select also extended below the expression. (cherry picked from commit 2c0b105de74c206ecae79f8711047921a86d50da) --- expr_synth.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/expr_synth.cc b/expr_synth.cc index 005617959..8360ae47e 100644 --- a/expr_synth.cc +++ b/expr_synth.cc @@ -1006,11 +1006,12 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root) } long base_val = base_tmp.as_long(); + unsigned below_width = 0; // Any below X bits? NetNet*below = 0; if (base_val < 0) { - unsigned below_width = abs(base_val); + below_width = abs(base_val); base_val = 0; if (below_width > select_width) { below_width = select_width; @@ -1033,7 +1034,8 @@ NetNet* NetESelect::synthesize(Design *des, NetScope*scope, NetExpr*root) } else { select_width = sub->vector_width() - base_val; } - unsigned above_width = expr_width() - select_width; + ivl_assert(*this, expr_width() > (select_width+below_width)); + unsigned above_width = expr_width() - select_width - below_width; above = make_const_x(des, scope, above_width); above->set_line(*this);