Avoid VHDL type error in concurrent assignment
When translating a relational LPM to concurrent VHDL assignment, the generated code would be incorrect if the input types differed in signedness.
This commit is contained in:
parent
2d97486897
commit
090f7730e6
|
|
@ -97,15 +97,22 @@ static vhdl_expr *rel_lpm_to_expr(vhdl_scope *scope, ivl_lpm_t lpm, vhdl_binop_t
|
|||
{
|
||||
vhdl_binop_expr *expr = new vhdl_binop_expr(op, vhdl_type::boolean());
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
vhdl_expr *e = readable_ref(scope, ivl_lpm_data(lpm, i));
|
||||
if (NULL == e) {
|
||||
delete expr;
|
||||
vhdl_expr *lhs = readable_ref(scope, ivl_lpm_data(lpm, 0));
|
||||
if (NULL == lhs)
|
||||
return NULL;
|
||||
|
||||
vhdl_expr *rhs = readable_ref(scope, ivl_lpm_data(lpm, 1));
|
||||
if (NULL == rhs) {
|
||||
delete lhs;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
expr->add_expr(e);
|
||||
}
|
||||
// Ensure LHS and RHS are the same type
|
||||
if (lhs->get_type() != rhs->get_type())
|
||||
rhs = rhs->cast(lhs->get_type());
|
||||
|
||||
expr->add_expr(lhs);
|
||||
expr->add_expr(rhs);
|
||||
|
||||
// Need to make sure output is std_logic rather than Boolean
|
||||
vhdl_type std_logic(VHDL_TYPE_STD_LOGIC);
|
||||
|
|
|
|||
Loading…
Reference in New Issue