From 9235ec665be76e91c0818d4caa1f26c020a0df31 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Wed, 26 Dec 2007 11:22:33 -0500 Subject: [PATCH] Correct bit widths and pad of certain part selects Zero-based part selects are a special case that is handled with optimized code. Properly handle the part select width to get the desired padding. Signed-off-by: Stephen Williams --- tgt-vvp/eval_expr.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index b803de488..7b345e1dc 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -1866,15 +1866,18 @@ static struct vector_info draw_select_signal(ivl_expr_t sube, in one go. */ if (number_is_immediate(bit_idx, 32) && get_number_immediate(bit_idx) == 0 - && (ivl_expr_width(sube) >= wid)) { + && (ivl_expr_width(sube) >= bit_wid)) { res.base = allocate_vector(wid); res.wid = wid; fprintf(vvp_out, " %%load/v %u, v%p_%u, %u; Only need %u of %u bits\n", - res.base, sig, use_word, wid, wid, ivl_expr_width(sube)); + res.base, sig, use_word, bit_wid, bit_wid, ivl_expr_width(sube)); - save_signal_lookaside(res.base, sig, use_word, res.wid); - + save_signal_lookaside(res.base, sig, use_word, bit_wid); + /* Pad the part select to the desired width. Note that + this *should* always turn into an unsigned pad + because part selects are always unsigned. */ + pad_expr_in_place(sube, res, bit_wid); return res; }