From 80fd301fc1732df634e04c86c82b1e5831aa2265 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Mon, 2 Sep 2024 09:10:10 +0200 Subject: [PATCH] tgt-vvp: Fix vector assignment with undefined delay Assignments with an undefined intra-assignment delay should be treated like assignments with zero delay. For the most part this is implemented correctly, except for assignments to a part of a vector where the offset inside the vector is an immediate value. E.g. ``` reg [1:0] x; integer d = 'x; ... x[0] <= #d 1'b1 ``` Here when loading the delay into the index register flag 4 is updated, but never cleared afterwards. As a result, if the delay is undefined, the vector assignment will be skipped. Fix this by making sure flag 4 is always cleared before the vector assignment instruction. Signed-off-by: Lars-Peter Clausen --- tgt-vvp/vvp_process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tgt-vvp/vvp_process.c b/tgt-vvp/vvp_process.c index d4389aab7..c94c1d048 100644 --- a/tgt-vvp/vvp_process.c +++ b/tgt-vvp/vvp_process.c @@ -317,14 +317,14 @@ static void assign_to_lvector(ivl_lval_t lval, // instruction to handle this case. int offset_index = allocate_word(); int delay_index = allocate_word(); - fprintf(vvp_out, " %%ix/load %d, %lu, 0;\n", offset_index, part_off); if (dexp) { draw_eval_expr_into_integer(dexp,delay_index); } else { fprintf(vvp_out, " %%ix/load %d, %lu, %lu;\n", delay_index, low_d, hig_d); - fprintf(vvp_out, " %%flag_set/imm 4, 0;\n"); } + fprintf(vvp_out, " %%ix/load %d, %lu, 0;\n", offset_index, part_off); + fprintf(vvp_out, " %%flag_set/imm 4, 0;\n"); fprintf(vvp_out, " %s/vec4/off/d v%p_%lu, %d, %d;\n", assign_op, sig, use_word, offset_index, delay_index); clr_word(offset_index);