From 7cde5f247e26b09002f92979db29ec1250bb1a37 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Mon, 16 Jun 2008 12:47:41 +0100 Subject: [PATCH] Add translation for not-equals operator --- tgt-vhdl/expr.cc | 8 +++++++- tgt-vhdl/vhdl_syntax.cc | 3 +++ tgt-vhdl/vhdl_syntax.hh | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tgt-vhdl/expr.cc b/tgt-vhdl/expr.cc index 7aa6d9fca..8e302efc4 100644 --- a/tgt-vhdl/expr.cc +++ b/tgt-vhdl/expr.cc @@ -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, 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) @@ -137,6 +141,8 @@ static vhdl_expr *translate_binary(ivl_expr_t e) return translate_numeric(lhs, rhs, VHDL_BINOP_ADD); case 'e': return translate_relation(lhs, rhs, VHDL_BINOP_EQ); + case 'N': + return translate_relation(lhs, rhs, VHDL_BINOP_NEQ); default: error("No translation for binary opcode '%c'\n", ivl_expr_opcode(e)); diff --git a/tgt-vhdl/vhdl_syntax.cc b/tgt-vhdl/vhdl_syntax.cc index ef33a79ab..fd9ba1805 100644 --- a/tgt-vhdl/vhdl_syntax.cc +++ b/tgt-vhdl/vhdl_syntax.cc @@ -690,6 +690,9 @@ void vhdl_binop_expr::emit(std::ofstream &of, int level) const case VHDL_BINOP_EQ: of << " = "; break; + case VHDL_BINOP_NEQ: + of << " /= "; + break; case VHDL_BINOP_ADD: of << " + "; break; diff --git a/tgt-vhdl/vhdl_syntax.hh b/tgt-vhdl/vhdl_syntax.hh index cf17f8dfd..5ceb45546 100644 --- a/tgt-vhdl/vhdl_syntax.hh +++ b/tgt-vhdl/vhdl_syntax.hh @@ -57,6 +57,7 @@ enum vhdl_binop_t { VHDL_BINOP_AND, VHDL_BINOP_OR, VHDL_BINOP_EQ, + VHDL_BINOP_NEQ, VHDL_BINOP_ADD, };