mirror of https://github.com/YosysHQ/yosys.git
Merge pull request #2476 from zachjs/const-arg-width
Fix constants bound to single bit arguments (fixes #2383)
This commit is contained in:
commit
8ef6b77dc3
|
@ -3342,6 +3342,14 @@ skip_dynamic_range_lvalue_expansion:;
|
||||||
wire->type = AST_LOCALPARAM;
|
wire->type = AST_LOCALPARAM;
|
||||||
wire->attributes.erase(ID::nosync);
|
wire->attributes.erase(ID::nosync);
|
||||||
wire->children.insert(wire->children.begin(), arg->clone());
|
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));
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
AstNode *wire_id = new AstNode(AST_IDENTIFIER);
|
AstNode *wire_id = new AstNode(AST_IDENTIFIER);
|
||||||
|
|
|
@ -44,6 +44,12 @@ module top;
|
||||||
end
|
end
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function automatic [16:0] operation4;
|
||||||
|
input [15:0] a;
|
||||||
|
input b;
|
||||||
|
operation4 = {a, b};
|
||||||
|
endfunction
|
||||||
|
|
||||||
wire [31:0] a;
|
wire [31:0] a;
|
||||||
assign a = 2;
|
assign a = 2;
|
||||||
|
|
||||||
|
@ -61,6 +67,9 @@ module top;
|
||||||
wire [31:0] x3;
|
wire [31:0] x3;
|
||||||
assign x3 = operation3(A, a);
|
assign x3 = operation3(A, a);
|
||||||
|
|
||||||
|
wire [16:0] x4;
|
||||||
|
assign x4 = operation4(a[15:0], 0);
|
||||||
|
|
||||||
// `define VERIFY
|
// `define VERIFY
|
||||||
`ifdef VERIFY
|
`ifdef VERIFY
|
||||||
assert property (a == 2);
|
assert property (a == 2);
|
||||||
|
@ -69,5 +78,6 @@ module top;
|
||||||
assert property (x1b == 16);
|
assert property (x1b == 16);
|
||||||
assert property (x2 == 4);
|
assert property (x2 == 4);
|
||||||
assert property (x3 == 16);
|
assert property (x3 == 16);
|
||||||
|
assert property (x4 == a << 1);
|
||||||
`endif
|
`endif
|
||||||
endmodule
|
endmodule
|
||||||
|
|
Loading…
Reference in New Issue