Add logical AND operator

This commit is contained in:
Nick Gasson 2008-07-04 11:10:20 +01:00
parent 19cbab78b2
commit c54b36c902
4 changed files with 15 additions and 17 deletions

View File

@ -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 '<':

View File

@ -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;
}

View File

@ -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;";
}

View File

@ -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_;
};