Add translation for not-equals operator

This commit is contained in:
Nick Gasson 2008-06-16 12:47:41 +01:00
parent 849e7cb4d5
commit 7cde5f247e
3 changed files with 11 additions and 1 deletions

View File

@ -119,7 +119,11 @@ static vhdl_expr *translate_numeric(vhdl_expr *lhs, vhdl_expr *rhs,
static vhdl_expr *translate_relation(vhdl_expr *lhs, vhdl_expr *rhs, static vhdl_expr *translate_relation(vhdl_expr *lhs, vhdl_expr *rhs,
vhdl_binop_t op) vhdl_binop_t op)
{ {
return new vhdl_binop_expr(lhs, op, rhs, vhdl_type::boolean()); // Generate any necessary casts
// Arbitrarily, the RHS is casted to the type of the LHS
vhdl_expr *r_cast = rhs->cast(lhs->get_type());
return new vhdl_binop_expr(lhs, op, r_cast, vhdl_type::boolean());
} }
static vhdl_expr *translate_binary(ivl_expr_t e) static vhdl_expr *translate_binary(ivl_expr_t e)
@ -137,6 +141,8 @@ static vhdl_expr *translate_binary(ivl_expr_t e)
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':
return translate_relation(lhs, rhs, VHDL_BINOP_NEQ);
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));

View File

@ -690,6 +690,9 @@ void vhdl_binop_expr::emit(std::ofstream &of, int level) const
case VHDL_BINOP_EQ: case VHDL_BINOP_EQ:
of << " = "; of << " = ";
break; break;
case VHDL_BINOP_NEQ:
of << " /= ";
break;
case VHDL_BINOP_ADD: case VHDL_BINOP_ADD:
of << " + "; of << " + ";
break; break;

View File

@ -57,6 +57,7 @@ enum vhdl_binop_t {
VHDL_BINOP_AND, VHDL_BINOP_AND,
VHDL_BINOP_OR, VHDL_BINOP_OR,
VHDL_BINOP_EQ, VHDL_BINOP_EQ,
VHDL_BINOP_NEQ,
VHDL_BINOP_ADD, VHDL_BINOP_ADD,
}; };