mirror of
https://github.com/steveicarus/iverilog.git
synced 2026-08-22 05:47:31 +02:00
Resize constants in eval_expr when needed.
If we are given an unsized constant that is smaller then the requested
width then resize the constant to fit.
(cherry picked from commit acb55916da)
This commit is contained in:
+8
-1
@@ -289,8 +289,15 @@ NetExpr* elab_and_eval(Design*des, NetScope*scope,
|
|||||||
void eval_expr(NetExpr*&expr, int prune_width)
|
void eval_expr(NetExpr*&expr, int prune_width)
|
||||||
{
|
{
|
||||||
assert(expr);
|
assert(expr);
|
||||||
if (dynamic_cast<NetEConst*>(expr)) return;
|
|
||||||
if (dynamic_cast<NetECReal*>(expr)) return;
|
if (dynamic_cast<NetECReal*>(expr)) return;
|
||||||
|
/* Resize a constant if allowed and needed. */
|
||||||
|
if (NetEConst *tmp = dynamic_cast<NetEConst*>(expr)) {
|
||||||
|
if (prune_width <= 0) return;
|
||||||
|
if (tmp->has_width()) return;
|
||||||
|
if ((unsigned)prune_width <= tmp->expr_width()) return;
|
||||||
|
expr = pad_to_width(expr, (unsigned)prune_width, *expr);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
NetExpr*tmp = expr->eval_tree(prune_width);
|
NetExpr*tmp = expr->eval_tree(prune_width);
|
||||||
if (tmp != 0) {
|
if (tmp != 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user