Add logical AND operator
This commit is contained in:
parent
19cbab78b2
commit
c54b36c902
|
|
@ -172,6 +172,8 @@ static vhdl_expr *translate_binary(ivl_expr_t e)
|
||||||
return translate_relation(lhs, rhs, VHDL_BINOP_NEQ);
|
return translate_relation(lhs, rhs, VHDL_BINOP_NEQ);
|
||||||
case '&': // Bitwise AND
|
case '&': // Bitwise AND
|
||||||
return translate_numeric(lhs, rhs, VHDL_BINOP_AND);
|
return translate_numeric(lhs, rhs, VHDL_BINOP_AND);
|
||||||
|
case 'a': // Logical AND
|
||||||
|
return translate_relation(lhs, rhs, VHDL_BINOP_AND);
|
||||||
case 'o':
|
case 'o':
|
||||||
return translate_relation(lhs, rhs, VHDL_BINOP_OR);
|
return translate_relation(lhs, rhs, VHDL_BINOP_OR);
|
||||||
case '<':
|
case '<':
|
||||||
|
|
|
||||||
|
|
@ -461,27 +461,30 @@ static int draw_case(vhdl_procedural *proc, stmt_container *container,
|
||||||
|
|
||||||
int nbranches = ivl_stmt_case_count(stmt);
|
int nbranches = ivl_stmt_case_count(stmt);
|
||||||
for (int i = 0; i < nbranches; i++) {
|
for (int i = 0; i < nbranches; i++) {
|
||||||
stmt_container *container;
|
vhdl_expr *when;
|
||||||
ivl_expr_t net = ivl_stmt_case_expr(stmt, i);
|
ivl_expr_t net = ivl_stmt_case_expr(stmt, i);
|
||||||
if (net) {
|
if (net) {
|
||||||
vhdl_expr *when = translate_expr(net)->cast(test->get_type());
|
when = translate_expr(net)->cast(test->get_type());
|
||||||
if (NULL == when)
|
if (NULL == when)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
vhdl_case_branch *branch = new vhdl_case_branch(when);
|
|
||||||
vhdlcase->add_branch(branch);
|
|
||||||
container = branch->get_container();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
container = vhdlcase->get_others_container();
|
when = new vhdl_var_ref("others", NULL);
|
||||||
have_others = true;
|
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)
|
if (!have_others) {
|
||||||
vhdlcase->get_others_container()->add_stmt(new vhdl_null_stmt());
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -734,11 +734,6 @@ void vhdl_case_stmt::emit(std::ostream &of, int level) const
|
||||||
case_branch_list_t::const_iterator it;
|
case_branch_list_t::const_iterator it;
|
||||||
for (it = branches_.begin(); it != branches_.end(); ++it)
|
for (it = branches_.begin(); it != branches_.end(); ++it)
|
||||||
(*it)->emit(of, level);
|
(*it)->emit(of, level);
|
||||||
|
|
||||||
if (!others_.empty()) {
|
|
||||||
of << "when others =>";
|
|
||||||
others_.emit(of, indent(level));
|
|
||||||
}
|
|
||||||
|
|
||||||
of << "end case;";
|
of << "end case;";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -367,11 +367,9 @@ public:
|
||||||
|
|
||||||
void add_branch(vhdl_case_branch *b) { branches_.push_back(b); }
|
void add_branch(vhdl_case_branch *b) { branches_.push_back(b); }
|
||||||
void emit(std::ostream &of, int level) const;
|
void emit(std::ostream &of, int level) const;
|
||||||
stmt_container *get_others_container() { return &others_; }
|
|
||||||
private:
|
private:
|
||||||
vhdl_expr *test_;
|
vhdl_expr *test_;
|
||||||
case_branch_list_t branches_;
|
case_branch_list_t branches_;
|
||||||
stmt_container others_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue