mirror of https://github.com/YosysHQ/yosys.git
Merge pull request #2506 from zachjs/const-arg-redeclare
Fix constants bound to redeclared function args
This commit is contained in:
commit
ce7f06f76e
|
@ -3344,12 +3344,23 @@ skip_dynamic_range_lvalue_expansion:;
|
||||||
wire->children.insert(wire->children.begin(), arg->clone());
|
wire->children.insert(wire->children.begin(), arg->clone());
|
||||||
// args without a range implicitly have width 1
|
// args without a range implicitly have width 1
|
||||||
if (wire->children.back()->type != AST_RANGE) {
|
if (wire->children.back()->type != AST_RANGE) {
|
||||||
|
// 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();
|
AstNode* range = new AstNode();
|
||||||
range->type = AST_RANGE;
|
range->type = AST_RANGE;
|
||||||
wire->children.push_back(range);
|
wire->children.push_back(range);
|
||||||
range->children.push_back(mkconst_int(0, true));
|
range->children.push_back(mkconst_int(0, true));
|
||||||
range->children.push_back(mkconst_int(0, true));
|
range->children.push_back(mkconst_int(0, true));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
AstNode *wire_id = new AstNode(AST_IDENTIFIER);
|
AstNode *wire_id = new AstNode(AST_IDENTIFIER);
|
||||||
|
|
|
@ -50,6 +50,12 @@ module top;
|
||||||
operation4 = {a, b};
|
operation4 = {a, b};
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function automatic integer operation5;
|
||||||
|
input x;
|
||||||
|
integer x;
|
||||||
|
operation5 = x;
|
||||||
|
endfunction
|
||||||
|
|
||||||
wire [31:0] a;
|
wire [31:0] a;
|
||||||
assign a = 2;
|
assign a = 2;
|
||||||
|
|
||||||
|
@ -70,6 +76,9 @@ module top;
|
||||||
wire [16:0] x4;
|
wire [16:0] x4;
|
||||||
assign x4 = operation4(a[15:0], 0);
|
assign x4 = operation4(a[15:0], 0);
|
||||||
|
|
||||||
|
wire [31:0] x5;
|
||||||
|
assign x5 = operation5(64);
|
||||||
|
|
||||||
// `define VERIFY
|
// `define VERIFY
|
||||||
`ifdef VERIFY
|
`ifdef VERIFY
|
||||||
assert property (a == 2);
|
assert property (a == 2);
|
||||||
|
@ -79,5 +88,6 @@ module top;
|
||||||
assert property (x2 == 4);
|
assert property (x2 == 4);
|
||||||
assert property (x3 == 16);
|
assert property (x3 == 16);
|
||||||
assert property (x4 == a << 1);
|
assert property (x4 == a << 1);
|
||||||
|
assert property (x5 == 64);
|
||||||
`endif
|
`endif
|
||||||
endmodule
|
endmodule
|
||||||
|
|
Loading…
Reference in New Issue