From ab95d1d9035b5488ca89ce9320bbb0aad9958c5c Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sat, 4 Jun 2022 12:41:21 +0200 Subject: [PATCH] tgt-vvp: Handle dynamic part select on array element non-blocking event control VVP array assignment operations expect the array element index to be in index register 3. For array element assignments with a dynamic part select the array index gets moved into a temporary index register and has to be moved into register 3 after evaluating the dynamic part select. This is currently not done non-blocking event control assignments. This causes the write to go to the wrong array element. It will go to whatever value is in the register 3 from previous operations. ``` reg [3:0] a[1:0]; integer i = 0; event e; a[1][i+:2] <= @e 2'b10; // Will write to the wrong array element ->e; ``` Make sure to move the temporary register to register 3. Signed-off-by: Lars-Peter Clausen --- tgt-vvp/vvp_process.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tgt-vvp/vvp_process.c b/tgt-vvp/vvp_process.c index 9c42bcae6..c93de0d44 100644 --- a/tgt-vvp/vvp_process.c +++ b/tgt-vvp/vvp_process.c @@ -179,6 +179,8 @@ static void assign_to_array_word(ivl_signal_t lsig, ivl_expr_t word_ix, /* If needed use the global error state. */ if (part_off_ex) { fprintf(vvp_out, " %%flag_mov 4, %d;\n", error_flag); + fprintf(vvp_out, " %%ix/mov 3, %d;\n", word_ix_reg); + clr_word(word_ix_reg); } fprintf(vvp_out, " %%assign/vec4/a/e v%p, %d;\n", lsig, part_off_reg);