Compare logic values for === and !==
This commit is contained in:
parent
d7bb5658f2
commit
6622b5fe3a
|
|
@ -70,6 +70,7 @@ static vhdl_expr *translate_unary(ivl_expr_t e)
|
||||||
|
|
||||||
switch (ivl_expr_opcode(e)) {
|
switch (ivl_expr_opcode(e)) {
|
||||||
case '!':
|
case '!':
|
||||||
|
case '~':
|
||||||
return new vhdl_unaryop_expr
|
return new vhdl_unaryop_expr
|
||||||
(VHDL_UNARYOP_NOT, operand, new vhdl_type(*operand->get_type()));
|
(VHDL_UNARYOP_NOT, operand, new vhdl_type(*operand->get_type()));
|
||||||
default:
|
default:
|
||||||
|
|
@ -136,13 +137,36 @@ static vhdl_expr *translate_binary(ivl_expr_t e)
|
||||||
if (NULL == rhs)
|
if (NULL == rhs)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
// For === and !== we need to compare std_logic_vectors
|
||||||
|
// rather than signeds
|
||||||
|
vhdl_type std_logic_vector(VHDL_TYPE_STD_LOGIC_VECTOR);
|
||||||
|
bool vectorop =
|
||||||
|
(lhs->get_type()->get_name() == VHDL_TYPE_SIGNED
|
||||||
|
|| lhs->get_type()->get_name() == VHDL_TYPE_UNSIGNED) &&
|
||||||
|
(rhs->get_type()->get_name() == VHDL_TYPE_SIGNED
|
||||||
|
|| rhs->get_type()->get_name() == VHDL_TYPE_UNSIGNED);
|
||||||
|
|
||||||
switch (ivl_expr_opcode(e)) {
|
switch (ivl_expr_opcode(e)) {
|
||||||
case '+':
|
case '+':
|
||||||
return translate_numeric(lhs, rhs, VHDL_BINOP_ADD);
|
return translate_numeric(lhs, rhs, VHDL_BINOP_ADD);
|
||||||
case 'e':
|
case 'e':
|
||||||
return translate_relation(lhs, rhs, VHDL_BINOP_EQ);
|
return translate_relation(lhs, rhs, VHDL_BINOP_EQ);
|
||||||
case 'N':
|
case 'E':
|
||||||
|
if (vectorop)
|
||||||
|
return translate_relation(lhs->cast(&std_logic_vector),
|
||||||
|
rhs->cast(&std_logic_vector), VHDL_BINOP_EQ);
|
||||||
|
else
|
||||||
|
return translate_relation(lhs, rhs, VHDL_BINOP_EQ);
|
||||||
|
case 'n':
|
||||||
return translate_relation(lhs, rhs, VHDL_BINOP_NEQ);
|
return translate_relation(lhs, rhs, VHDL_BINOP_NEQ);
|
||||||
|
case 'N':
|
||||||
|
if (vectorop)
|
||||||
|
return translate_relation(lhs->cast(&std_logic_vector),
|
||||||
|
rhs->cast(&std_logic_vector), VHDL_BINOP_NEQ);
|
||||||
|
else
|
||||||
|
return translate_relation(lhs, rhs, VHDL_BINOP_NEQ);
|
||||||
|
case 'o':
|
||||||
|
return translate_relation(lhs, rhs, VHDL_BINOP_OR);
|
||||||
default:
|
default:
|
||||||
error("No translation for binary opcode '%c'\n",
|
error("No translation for binary opcode '%c'\n",
|
||||||
ivl_expr_opcode(e));
|
ivl_expr_opcode(e));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue