diff --git a/PExpr.h b/PExpr.h index 5fd2b8ff6..b2c32854f 100644 --- a/PExpr.h +++ b/PExpr.h @@ -596,7 +596,7 @@ class PENumber : public PExpr { virtual unsigned test_width(Design*des, NetScope*scope, width_mode_t&mode); - virtual NetEConst*elaborate_expr(Design*des, NetScope*scope, + virtual NetExpr *elaborate_expr(Design*des, NetScope*scope, ivl_type_t type, unsigned flags) const; virtual NetEConst*elaborate_expr(Design*des, NetScope*, unsigned expr_wid, unsigned) const; diff --git a/elab_expr.cc b/elab_expr.cc index c3e2e3293..0c9270bf7 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -4843,7 +4843,7 @@ unsigned PENumber::test_width(Design*, NetScope*, width_mode_t&mode) return expr_width_; } -NetEConst* PENumber::elaborate_expr(Design*des, NetScope*, ivl_type_t ntype, unsigned) const +NetExpr* PENumber::elaborate_expr(Design*des, NetScope*, ivl_type_t ntype, unsigned) const { const netvector_t*use_type = dynamic_cast (ntype); if (use_type == 0) { @@ -4854,6 +4854,15 @@ NetEConst* PENumber::elaborate_expr(Design*des, NetScope*, ivl_type_t ntype, uns return 0; } + // Special case: If the context type is REAL, then cast the + // vector value to a real and rethrn a NetECReal. + if (ntype->base_type() == IVL_VT_REAL) { + verireal val (value_->as_long()); + NetECReal*tmp = new NetECReal(val); + tmp->set_line(*this); + return tmp; + } + verinum use_val = value(); use_val .has_sign( use_type->get_signed() ); use_val = cast_to_width(use_val, use_type->packed_width());