mirror of
https://github.com/steveicarus/iverilog.git
synced 2026-08-29 01:03:29 +02:00
Fix implicit casts in assignments (part 1).
This patch adds support for implicit casts to the elaborate_rval_expr() function. This will handle the majority of cases where an implicit cast can occur.
This commit is contained in:
committed by
Stephen Williams
parent
03ebd2f98d
commit
22769afd20
@@ -1591,6 +1591,39 @@ NetEConst* NetEUReduce::eval_arguments_(const NetExpr*ex) const
|
||||
return tmp;
|
||||
}
|
||||
|
||||
NetExpr* NetECast::eval_arguments_(const NetExpr*ex) const
|
||||
{
|
||||
NetExpr*res = 0;
|
||||
switch (op_) {
|
||||
case 'r':
|
||||
if (const NetEConst*val = dynamic_cast<const NetEConst*>(ex)) {
|
||||
verireal res_val = verireal(val->value().as_double());
|
||||
res = new NetECReal(res_val);
|
||||
}
|
||||
break;
|
||||
case '2':
|
||||
if (const NetEConst*val = dynamic_cast<const NetEConst*>(ex)) {
|
||||
verinum res_val(val->value());
|
||||
res_val.cast_to_int2();
|
||||
res = new NetEConst(res_val);
|
||||
}
|
||||
case 'v':
|
||||
if (const NetECReal*val = dynamic_cast<const NetECReal*>(ex)) {
|
||||
verinum res_val = verinum(val->value().as_double(), false);
|
||||
res = new NetEConst(res_val);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ivl_assert(*this, 0);
|
||||
return 0;
|
||||
}
|
||||
if (res == 0) return 0;
|
||||
|
||||
ivl_assert(*this, res);
|
||||
eval_debug(this, res, op_ == 'r');
|
||||
return res;
|
||||
}
|
||||
|
||||
NetEConst* NetESFunc::evaluate_clog2_(const NetExpr*arg_) const
|
||||
{
|
||||
const NetEConst*tmpi = dynamic_cast<const NetEConst*>(arg_);
|
||||
|
||||
Reference in New Issue
Block a user