Make sure any calls to numeric_std Resize have correct type

The signed/unsigned-ness of an expression needs to be
preserved over any call to Resize. Also add a sanity
check to make sure non-vector types are not resized.
This commit is contained in:
Nick Gasson 2008-07-04 11:36:11 +01:00
parent 96d32b29c9
commit 1410c339de
1 changed files with 9 additions and 1 deletions

View File

@ -417,7 +417,15 @@ vhdl_expr *vhdl_expr::cast(const vhdl_type *to)
vhdl_expr *vhdl_expr::resize(int newwidth)
{
vhdl_type *rtype = vhdl_type::nsigned(newwidth);
vhdl_type *rtype;
assert(type_);
if (type_->get_name() == VHDL_TYPE_SIGNED)
rtype = vhdl_type::nsigned(newwidth);
else if (type_->get_name() == VHDL_TYPE_UNSIGNED)
rtype = vhdl_type::nunsigned(newwidth);
else
assert(false); // Doesn't make sense to resize non-vector type
vhdl_fcall *resize = new vhdl_fcall("Resize", rtype);
resize->add_expr(this);
resize->add_expr(new vhdl_const_int(newwidth));