diff --git a/tgt-vhdl/expr.cc b/tgt-vhdl/expr.cc index 0bf7d7991..e88d60935 100644 --- a/tgt-vhdl/expr.cc +++ b/tgt-vhdl/expr.cc @@ -446,22 +446,25 @@ static vhdl_expr *translate_binary(ivl_expr_t e) static vhdl_expr *translate_select(ivl_expr_t e) { - vhdl_var_ref *from = - dynamic_cast(translate_expr(ivl_expr_oper1(e))); - if (NULL == from) { - error("Can only select from variable reference"); + vhdl_expr *from = translate_expr(ivl_expr_oper1(e)); + if (NULL == from) return NULL; - } ivl_expr_t o2 = ivl_expr_oper2(e); if (o2) { + vhdl_var_ref *from_var_ref = dynamic_cast(from); + if (NULL == from_var_ref) { + error("Can only select from variable reference"); + return NULL; + } + vhdl_expr *base = translate_expr(ivl_expr_oper2(e)); if (NULL == base) return NULL; vhdl_type integer(VHDL_TYPE_INTEGER); - from->set_slice(base->cast(&integer), ivl_expr_width(e) - 1); - return from; + from_var_ref->set_slice(base->cast(&integer), ivl_expr_width(e) - 1); + return from_var_ref; } else return from->resize(ivl_expr_width(e)); diff --git a/tgt-vhdl/scope.cc b/tgt-vhdl/scope.cc index 2d4272049..ee0abdd7e 100644 --- a/tgt-vhdl/scope.cc +++ b/tgt-vhdl/scope.cc @@ -275,7 +275,7 @@ static string make_safe_name(ivl_signal_t sig) const char *base = ivl_signal_basename(sig); if (base[0] == '_') return string("VL") + base; - + const char *vhdl_reserved[] = { "in", "out", "entity", "architecture", "inout", "array", "is", "not", "and", "or", "bus", "bit", "line", // Etc...