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 <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-01-01 18:01:48 +01:00
parent 560800489d
commit 85bf2d11fa
1 changed files with 2 additions and 0 deletions

View File

@ -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;
}