From eab37efb561259df7e27aa26f080a7b0f2ca48a1 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 28 May 2022 10:16:13 +0200 Subject: [PATCH] vvp: Handle fully out-of-bounds write for `%assign/vec4/a/{d,e}` The `%assign/vec4/a/{d,e}` instructions, when checking for a full out-of-bounds write on the low side, uses the target signal width, while it should use the assigned value width. This can lead to a fully out-of-bounds write to be assumed to be a partial out-of-bounds access, which will trigger an assert later on. E.g. ``` integer a[1:0]; integer i = -4; a[0][i+:4] <= 4'h0; // Triggers assert ``` Signed-off-by: Lars-Peter Clausen --- vvp/vthread.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 439e7529b..eeaff8588 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -1159,7 +1159,7 @@ bool of_ASSIGN_VEC4_A_D(vthread_t thr, vvp_code_t cp) if (off >= (long)array_wid) return true; if (off < 0) { - if ((unsigned)-off >= array_wid) + if ((unsigned)-off >= wid) return true; int use_off = -off; @@ -1201,7 +1201,7 @@ bool of_ASSIGN_VEC4_A_E(vthread_t thr, vvp_code_t cp) if (off >= (long)array_wid) return true; if (off < 0) { - if ((unsigned)-off >= array_wid) + if ((unsigned)-off >= wid) return true; int use_off = -off;