Merge branch 'vhdl'

This commit is contained in:
Stephen Williams 2008-11-13 15:45:37 -08:00
commit d06092d7d7
2 changed files with 11 additions and 8 deletions

View File

@ -446,22 +446,25 @@ static vhdl_expr *translate_binary(ivl_expr_t e)
static vhdl_expr *translate_select(ivl_expr_t e) static vhdl_expr *translate_select(ivl_expr_t e)
{ {
vhdl_var_ref *from = vhdl_expr *from = translate_expr(ivl_expr_oper1(e));
dynamic_cast<vhdl_var_ref*>(translate_expr(ivl_expr_oper1(e))); if (NULL == from)
if (NULL == from) {
error("Can only select from variable reference");
return NULL; return NULL;
}
ivl_expr_t o2 = ivl_expr_oper2(e); ivl_expr_t o2 = ivl_expr_oper2(e);
if (o2) { if (o2) {
vhdl_var_ref *from_var_ref = dynamic_cast<vhdl_var_ref*>(from);
if (NULL == from_var_ref) {
error("Can only select from variable reference");
return NULL;
}
vhdl_expr *base = translate_expr(ivl_expr_oper2(e)); vhdl_expr *base = translate_expr(ivl_expr_oper2(e));
if (NULL == base) if (NULL == base)
return NULL; return NULL;
vhdl_type integer(VHDL_TYPE_INTEGER); vhdl_type integer(VHDL_TYPE_INTEGER);
from->set_slice(base->cast(&integer), ivl_expr_width(e) - 1); from_var_ref->set_slice(base->cast(&integer), ivl_expr_width(e) - 1);
return from; return from_var_ref;
} }
else else
return from->resize(ivl_expr_width(e)); return from->resize(ivl_expr_width(e));

View File

@ -275,7 +275,7 @@ static string make_safe_name(ivl_signal_t sig)
const char *base = ivl_signal_basename(sig); const char *base = ivl_signal_basename(sig);
if (base[0] == '_') if (base[0] == '_')
return string("VL") + base; return string("VL") + base;
const char *vhdl_reserved[] = { const char *vhdl_reserved[] = {
"in", "out", "entity", "architecture", "inout", "array", "in", "out", "entity", "architecture", "inout", "array",
"is", "not", "and", "or", "bus", "bit", "line", // Etc... "is", "not", "and", "or", "bus", "bit", "line", // Etc...