Fix LPM binop with different signedness
Need to explicitly cast between signed/unsigned to make sure both arguments have the same type or the VHDL won't compile.
This commit is contained in:
parent
646a6056a2
commit
f62a00bedb
|
|
@ -90,8 +90,9 @@ static vhdl_expr *concat_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm)
|
||||||
|
|
||||||
static vhdl_expr *binop_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm, vhdl_binop_t op)
|
static vhdl_expr *binop_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm, vhdl_binop_t op)
|
||||||
{
|
{
|
||||||
|
unsigned out_width = ivl_lpm_width(lpm);
|
||||||
vhdl_type *result_type =
|
vhdl_type *result_type =
|
||||||
vhdl_type::type_for(ivl_lpm_width(lpm), ivl_lpm_signed(lpm) != 0);
|
vhdl_type::type_for(out_width, ivl_lpm_signed(lpm) != 0);
|
||||||
vhdl_binop_expr *expr = new vhdl_binop_expr(op, result_type);
|
vhdl_binop_expr *expr = new vhdl_binop_expr(op, result_type);
|
||||||
|
|
||||||
for (int i = 0; i < 2; i++) {
|
for (int i = 0; i < 2; i++) {
|
||||||
|
|
@ -99,14 +100,13 @@ static vhdl_expr *binop_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm, vhdl_binop
|
||||||
if (NULL == e)
|
if (NULL == e)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
expr->add_expr(e);
|
expr->add_expr(e->cast(result_type));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (op == VHDL_BINOP_MULT) {
|
if (op == VHDL_BINOP_MULT) {
|
||||||
// Need to resize the output to the desired size,
|
// Need to resize the output to the desired size,
|
||||||
// as this does not happen automatically in VHDL
|
// as this does not happen automatically in VHDL
|
||||||
|
|
||||||
unsigned out_width = ivl_lpm_width(lpm);
|
|
||||||
vhdl_fcall *resize =
|
vhdl_fcall *resize =
|
||||||
new vhdl_fcall("Resize", vhdl_type::nsigned(out_width));
|
new vhdl_fcall("Resize", vhdl_type::nsigned(out_width));
|
||||||
resize->add_expr(expr);
|
resize->add_expr(expr);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue