Add XOR operator and catch default case branch

This commit is contained in:
Nick Gasson 2008-06-24 10:55:45 +01:00
parent f261bf7e97
commit 4188fbecee
4 changed files with 18 additions and 4 deletions

View File

@ -182,6 +182,8 @@ static vhdl_expr *translate_binary(ivl_expr_t e)
return translate_shift(lhs, rhs, VHDL_BINOP_SL); return translate_shift(lhs, rhs, VHDL_BINOP_SL);
case 'r': case 'r':
return translate_shift(lhs, rhs, VHDL_BINOP_SR); return translate_shift(lhs, rhs, VHDL_BINOP_SR);
case '^':
return translate_numeric(lhs, rhs, VHDL_BINOP_XOR);
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

@ -24,6 +24,7 @@
#include <cstring> #include <cstring>
#include <cassert> #include <cassert>
#include <sstream> #include <sstream>
#include <typeinfo>
/* /*
* VHDL has no real equivalent of Verilog's $finish task. The * VHDL has no real equivalent of Verilog's $finish task. The
@ -430,9 +431,15 @@ static int draw_case(vhdl_process *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++) {
vhdl_expr *when = translate_expr(ivl_stmt_case_expr(stmt, i)); vhdl_expr *when;
ivl_expr_t net = ivl_stmt_case_expr(stmt, i);
if (net) {
when = translate_expr(net);
if (NULL == when) if (NULL == when)
return 1; return 1;
}
else
when = new vhdl_var_ref("others", NULL);
vhdl_case_branch *branch = new vhdl_case_branch(when); vhdl_case_branch *branch = new vhdl_case_branch(when);
vhdlcase->add_branch(branch); vhdlcase->add_branch(branch);

View File

@ -23,6 +23,7 @@
#include <cassert> #include <cassert>
#include <iostream> #include <iostream>
#include <typeinfo>
vhdl_entity::vhdl_entity(const char *name, const char *derived_from, vhdl_entity::vhdl_entity(const char *name, const char *derived_from,
vhdl_arch *arch) vhdl_arch *arch)
@ -813,6 +814,9 @@ void vhdl_binop_expr::emit(std::ofstream &of, int level) const
case VHDL_BINOP_SR: case VHDL_BINOP_SR:
of << " srl "; of << " srl ";
break; break;
case VHDL_BINOP_XOR:
of << " xor ";
break;
} }
(*it)->emit(of, level); (*it)->emit(of, level);

View File

@ -73,6 +73,7 @@ enum vhdl_binop_t {
VHDL_BINOP_GT, VHDL_BINOP_GT,
VHDL_BINOP_SL, VHDL_BINOP_SL,
VHDL_BINOP_SR, VHDL_BINOP_SR,
VHDL_BINOP_XOR,
}; };
/* /*