From f34485d415089d091f6cd91e28c628bd3ec00882 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 2 Sep 2009 19:44:41 -0700 Subject: [PATCH] Support negative index for %assign/av opcodes. If the array index is negative these opcodes need to just return. (cherry picked from commit 9d765820bff39fd411fd49d4ad398450d32374ef) --- vvp/vthread.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 4f1392171..03e4124a1 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -824,10 +824,12 @@ bool of_ASSIGN_AV(vthread_t thr, vvp_code_t cp) { unsigned wid = thr->words[0].w_int; long off = thr->words[1].w_int; - unsigned adr = thr->words[3].w_int; + long adr = thr->words[3].w_int; unsigned delay = cp->bit_idx[0]; unsigned bit = cp->bit_idx[1]; + if (adr < 0) return true; + long vwidth = get_array_word_size(cp->array); // We fell off the MSB end. if (off >= vwidth) return true; @@ -861,10 +863,12 @@ bool of_ASSIGN_AVD(vthread_t thr, vvp_code_t cp) { unsigned wid = thr->words[0].w_int; long off = thr->words[1].w_int; - unsigned adr = thr->words[3].w_int; + long adr = thr->words[3].w_int; vvp_time64_t delay = thr->words[cp->bit_idx[0]].w_int; unsigned bit = cp->bit_idx[1]; + if (adr < 0) return true; + long vwidth = get_array_word_size(cp->array); // We fell off the MSB end. if (off >= vwidth) return true; @@ -892,9 +896,11 @@ bool of_ASSIGN_AVE(vthread_t thr, vvp_code_t cp) { unsigned wid = thr->words[0].w_int; long off = thr->words[1].w_int; - unsigned adr = thr->words[3].w_int; + long adr = thr->words[3].w_int; unsigned bit = cp->bit_idx[0]; + if (adr < 0) return true; + long vwidth = get_array_word_size(cp->array); // We fell off the MSB end. if (off >= vwidth) return true;