From 560800489dcf2f4fc3edc4c3a8dc18a05d1cfa94 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 1 Oct 2023 09:04:07 -0700 Subject: [PATCH 1/3] tests: sv_queue_vec: Change base type to 4-state The sv_queue_vec test uses queues of 2-state vectors, but also checks if certain operations on the queue yield 'X. 2-state queues should never yield 'X and the test only passes because of a bug. In preparation for fixing the bug change the test to use a 4-state base type instead. Signed-off-by: Lars-Peter Clausen --- ivtest/ivltests/sv_queue_vec.v | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ivtest/ivltests/sv_queue_vec.v b/ivtest/ivltests/sv_queue_vec.v index e422ccfba0..ced6113a50 100644 --- a/ivtest/ivltests/sv_queue_vec.v +++ b/ivtest/ivltests/sv_queue_vec.v @@ -1,7 +1,7 @@ module top; - int q_tst [$]; - int q_tmp [$]; - int elem; + integer q_tst [$]; + integer q_tmp [$]; + integer elem; integer idx; bit passed; From 85bf2d11faed80830e0d8797e462f038aa89ae70 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 1 Jan 2022 18:01:48 +0100 Subject: [PATCH 2/3] tgt-vvp: Cast reads from 2-state dynamic arrays/queues vvp does not track whether the values stored in a dynamic array or queue are 2-state or 4-state. Internally the data is always stored as 4-state. To make sure that the read value is actually 2-state do a cast for 2-state reads. E.g. performing an out-of-bounds access on a 2-state dynamic array or queue will yield a undefined value. Signed-off-by: Lars-Peter Clausen --- tgt-vvp/eval_vec4.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tgt-vvp/eval_vec4.c b/tgt-vvp/eval_vec4.c index 4b73b7c2c0..ebad867990 100644 --- a/tgt-vvp/eval_vec4.c +++ b/tgt-vvp/eval_vec4.c @@ -957,6 +957,8 @@ static void draw_select_vec4(ivl_expr_t expr) assert(base); draw_eval_expr_into_integer(base, 3); fprintf(vvp_out, " %%load/dar/vec4 v%p_0;\n", sig); + if (ivl_expr_value(expr) == IVL_VT_BOOL) + fprintf(vvp_out, " %%cast2;\n"); return; } From 3e58507e87d99acbb51c456f72f770ee1b832538 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 1 Oct 2023 08:54:53 -0700 Subject: [PATCH 3/3] Enable regression tests for out-of-bounds on 2-state queues and dynamic arrays Now that out-of-bounds access on 2-state queues and dynamic arrays yields the right value move the tests from the "Not Implemented" list to the list of tests that get run. Signed-off-by: Lars-Peter Clausen --- ivtest/regress-fsv.list | 2 -- ivtest/regress-sv.list | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ivtest/regress-fsv.list b/ivtest/regress-fsv.list index 4bf61e81ca..3d0f9c6178 100644 --- a/ivtest/regress-fsv.list +++ b/ivtest/regress-fsv.list @@ -126,7 +126,6 @@ sv_darray_nest1 NI ivltests sv_darray_nest2 NI ivltests sv_darray_nest3 NI ivltests sv_darray_nest4 NI ivltests -sv_darray_oob_vec2 NI ivltests sv_deferred_assert1 NI ivltests sv_deferred_assert2 NI ivltests sv_deferred_assume1 NI ivltests @@ -135,4 +134,3 @@ sv_queue_nest1 NI ivltests sv_queue_nest2 NI ivltests sv_queue_nest3 NI ivltests sv_queue_nest4 NI ivltests -sv_queue_oob_vec2 NI ivltests diff --git a/ivtest/regress-sv.list b/ivtest/regress-sv.list index 297d7292e1..1433f4b8d9 100644 --- a/ivtest/regress-sv.list +++ b/ivtest/regress-sv.list @@ -664,6 +664,7 @@ sv_darray_decl_assign normal,-g2009 ivltests sv_darray_function normal,-g2009 ivltests sv_darray_oob_real normal,-g2009 ivltests sv_darray_oob_string normal,-g2009 ivltests +sv_darray_oob_vec2 normal,-g2009 ivltests sv_darray_oob_vec4 normal,-g2009 ivltests sv_darray_signed normal,-g2009 ivltests sv_darray_word_size normal,-g2005-sv ivltests @@ -784,6 +785,7 @@ sv_queue_function1 normal,-g2009 ivltests sv_queue_function2 normal,-g2009 ivltests sv_queue_oob_real normal,-g2009 ivltests sv_queue_oob_string normal,-g2009 ivltests +sv_queue_oob_vec2 normal,-g2009 ivltests sv_queue_oob_vec4 normal,-g2009 ivltests sv_queue_parray normal,-g2009,-pfileline=1 ivltests gold=sv_queue_parray.gold sv_queue_parray_bounded normal,-g2009,-pfileline=1 ivltests gold=sv_queue_parray_bounded.gold