aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/ast
diff options
context:
space:
mode:
authorZachary Snow <zach@zachjs.com>2021-12-30 00:01:30 -0700
committerZachary Snow <zachary.j.snow@gmail.com>2022-01-03 08:17:35 -0700
commit8c509a5659d540dc41f6cc19ee6989fc249f519d (patch)
tree95269bdb728345b781ed31c081bd35ed00462cec /frontends/ast
parentcb17eeaf5008a87384b3888dc34993928daba918 (diff)
downloadyosys-8c509a5659d540dc41f6cc19ee6989fc249f519d.tar.gz
yosys-8c509a5659d540dc41f6cc19ee6989fc249f519d.tar.bz2
yosys-8c509a5659d540dc41f6cc19ee6989fc249f519d.zip
sv: fix size cast clipping expression width
Diffstat (limited to 'frontends/ast')
-rw-r--r--frontends/ast/genrtlil.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/frontends/ast/genrtlil.cc b/frontends/ast/genrtlil.cc
index 1fe74bb72..2788a850f 100644
--- a/frontends/ast/genrtlil.cc
+++ b/frontends/ast/genrtlil.cc
@@ -932,7 +932,8 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
if (children.at(0)->type != AST_CONSTANT)
log_file_error(filename, location.first_line, "Static cast with non constant expression!\n");
children.at(1)->detectSignWidthWorker(width_hint, sign_hint);
- width_hint = children.at(0)->bitsAsConst().as_int();
+ this_width = children.at(0)->bitsAsConst().as_int();
+ width_hint = max(width_hint, this_width);
if (width_hint <= 0)
log_file_error(filename, location.first_line, "Static cast with zero or negative size!\n");
break;