mirror of
https://github.com/YosysHQ/yosys
synced 2025-08-07 11:41:23 +00:00
Fix constants bound to redeclared function args
The changes in #2476 ensured that function inputs like `input x;` retained their single-bit size when instantiated with a constant argument and turned into a localparam. That change did not handle the possibility for an input to be redeclared later on with an explicit width, such as `integer x;`.
This commit is contained in:
parent
4491548037
commit
1419c8761c
2 changed files with 26 additions and 5 deletions
|
@ -3344,11 +3344,22 @@ skip_dynamic_range_lvalue_expansion:;
|
|||
wire->children.insert(wire->children.begin(), arg->clone());
|
||||
// args without a range implicitly have width 1
|
||||
if (wire->children.back()->type != AST_RANGE) {
|
||||
AstNode* range = new AstNode();
|
||||
range->type = AST_RANGE;
|
||||
wire->children.push_back(range);
|
||||
range->children.push_back(mkconst_int(0, true));
|
||||
range->children.push_back(mkconst_int(0, true));
|
||||
// check if this wire is redeclared with an explicit size
|
||||
bool uses_explicit_size = false;
|
||||
for (const AstNode *other_child : decl->children)
|
||||
if (other_child->type == AST_WIRE && child->str == other_child->str
|
||||
&& !other_child->children.empty()
|
||||
&& other_child->children.back()->type == AST_RANGE) {
|
||||
uses_explicit_size = true;
|
||||
break;
|
||||
}
|
||||
if (!uses_explicit_size) {
|
||||
AstNode* range = new AstNode();
|
||||
range->type = AST_RANGE;
|
||||
wire->children.push_back(range);
|
||||
range->children.push_back(mkconst_int(0, true));
|
||||
range->children.push_back(mkconst_int(0, true));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue