3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-06-28 08:58:45 +00:00

sv: fix size cast clipping expression width

This commit is contained in:
Zachary Snow 2021-12-30 00:01:30 -07:00 committed by Zachary Snow
parent cb17eeaf50
commit 8c509a5659
3 changed files with 11 additions and 1 deletions

View file

@ -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;