From 85bf2d11faed80830e0d8797e462f038aa89ae70 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 1 Jan 2022 18:01:48 +0100 Subject: [PATCH] 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 4b73b7c2c..ebad86799 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; }