diff --git a/tgt-vhdl/expr.cc b/tgt-vhdl/expr.cc index 6bd65c2f7..43901518e 100644 --- a/tgt-vhdl/expr.cc +++ b/tgt-vhdl/expr.cc @@ -172,6 +172,8 @@ static vhdl_expr *translate_binary(ivl_expr_t e) return translate_relation(lhs, rhs, VHDL_BINOP_NEQ); case '&': // Bitwise AND return translate_numeric(lhs, rhs, VHDL_BINOP_AND); + case 'a': // Logical AND + return translate_relation(lhs, rhs, VHDL_BINOP_AND); case 'o': return translate_relation(lhs, rhs, VHDL_BINOP_OR); case '<': diff --git a/tgt-vhdl/stmt.cc b/tgt-vhdl/stmt.cc index 2589fc0c3..456f36be8 100644 --- a/tgt-vhdl/stmt.cc +++ b/tgt-vhdl/stmt.cc @@ -461,27 +461,30 @@ static int draw_case(vhdl_procedural *proc, stmt_container *container, int nbranches = ivl_stmt_case_count(stmt); for (int i = 0; i < nbranches; i++) { - stmt_container *container; + vhdl_expr *when; ivl_expr_t net = ivl_stmt_case_expr(stmt, i); if (net) { - vhdl_expr *when = translate_expr(net)->cast(test->get_type()); + when = translate_expr(net)->cast(test->get_type()); if (NULL == when) return 1; - - vhdl_case_branch *branch = new vhdl_case_branch(when); - vhdlcase->add_branch(branch); - container = branch->get_container(); } else { - container = vhdlcase->get_others_container(); + when = new vhdl_var_ref("others", NULL); have_others = true; } - draw_stmt(proc, container, ivl_stmt_case_stmt(stmt, i)); + vhdl_case_branch *branch = new vhdl_case_branch(when); + vhdlcase->add_branch(branch); + + draw_stmt(proc, branch->get_container(), ivl_stmt_case_stmt(stmt, i)); } - if (!have_others) - vhdlcase->get_others_container()->add_stmt(new vhdl_null_stmt()); + if (!have_others) { + vhdl_case_branch *others = + new vhdl_case_branch(new vhdl_var_ref("others", NULL)); + others->get_container()->add_stmt(new vhdl_null_stmt()); + vhdlcase->add_branch(others); + } return 0; } diff --git a/tgt-vhdl/vhdl_syntax.cc b/tgt-vhdl/vhdl_syntax.cc index 036c6e889..2d4d1e984 100644 --- a/tgt-vhdl/vhdl_syntax.cc +++ b/tgt-vhdl/vhdl_syntax.cc @@ -734,11 +734,6 @@ void vhdl_case_stmt::emit(std::ostream &of, int level) const case_branch_list_t::const_iterator it; for (it = branches_.begin(); it != branches_.end(); ++it) (*it)->emit(of, level); - - if (!others_.empty()) { - of << "when others =>"; - others_.emit(of, indent(level)); - } of << "end case;"; } diff --git a/tgt-vhdl/vhdl_syntax.hh b/tgt-vhdl/vhdl_syntax.hh index 53ee27d94..c87eea284 100644 --- a/tgt-vhdl/vhdl_syntax.hh +++ b/tgt-vhdl/vhdl_syntax.hh @@ -367,11 +367,9 @@ public: void add_branch(vhdl_case_branch *b) { branches_.push_back(b); } void emit(std::ostream &of, int level) const; - stmt_container *get_others_container() { return &others_; } private: vhdl_expr *test_; case_branch_list_t branches_; - stmt_container others_; };