Fix some subtle code generator bugs with wide literals and large r-values.

This commit is contained in:
Stephen Williams 2014-01-07 18:46:35 -08:00
parent ec6009dd8f
commit 6a93b6a7e4
2 changed files with 10 additions and 2 deletions

View File

@ -579,7 +579,7 @@ static void draw_string_vec4(ivl_expr_t expr, int stuff_ok_flag)
fprintf(vvp_out, " %%pushi/vec4 %lu, 0, 32;\n", tmp);
tmp = 0;
tmp_wid = 0;
if (push_flag != 0)
if (push_flag == 0)
push_flag += 1;
else
fprintf(vvp_out, " %%concat/vec4;\n");
@ -589,7 +589,7 @@ static void draw_string_vec4(ivl_expr_t expr, int stuff_ok_flag)
if (tmp_wid > 0) {
fprintf(vvp_out, " %%pushi/vec4 %lu, 0, %u;\n", tmp, tmp_wid);
if (push_flag != 0)
fprintf(vvp_out, " %%oncat/vec4;\n");
fprintf(vvp_out, " %%concat/vec4;\n");
}
free(fp);

View File

@ -640,7 +640,15 @@ static int show_stmt_assign_vector(ivl_statement_t net)
fprintf(vvp_out, " %%cvt/vr %u;\n", wid);
} else {
unsigned wid = ivl_stmt_lwidth(net);
draw_eval_vec4(rval, 0);
if (ivl_expr_width(rval)==wid) {
; /* Normally, the rval expression size is correct. */
} else if (ivl_expr_signed(rval)) {
fprintf(vvp_out, " %%pad/s %u;\n", wid);
} else {
fprintf(vvp_out, " %%pad/u %u;\n", wid);
}
//res.base = 0; // XXXX This is just to suppress the clr_vector below.
//res.wid = 0;
}