From 6ff80e80a4423118c39d23d86be2e6a96622857d Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Fri, 18 Jul 2008 12:30:24 +0100 Subject: [PATCH] Catch case where (un)signed is converted to boolean --- tgt-vhdl/vhdl_syntax.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tgt-vhdl/vhdl_syntax.cc b/tgt-vhdl/vhdl_syntax.cc index b41bdf31c..7eda301da 100644 --- a/tgt-vhdl/vhdl_syntax.cc +++ b/tgt-vhdl/vhdl_syntax.cc @@ -422,10 +422,15 @@ vhdl_expr *vhdl_expr::cast(const vhdl_type *to) return resize(to->get_width()); } else if (to->get_name() == VHDL_TYPE_BOOLEAN) { - // '1' is true all else are false - vhdl_const_bit *one = new vhdl_const_bit('1'); - return new vhdl_binop_expr - (this, VHDL_BINOP_EQ, one, vhdl_type::boolean()); + if (type_->get_name() == VHDL_TYPE_STD_LOGIC) { + // '1' is true all else are false + vhdl_const_bit *one = new vhdl_const_bit('1'); + return new vhdl_binop_expr + (this, VHDL_BINOP_EQ, one, vhdl_type::boolean()); + } + else { + assert(false); + } } else if (to->get_name() == VHDL_TYPE_INTEGER) { vhdl_fcall *conv = new vhdl_fcall("To_Integer", new vhdl_type(*to));