mirror of https://github.com/YosysHQ/yosys.git
simplify.cc: Fix unsized const in params
This commit is contained in:
parent
5d0847f6fb
commit
a5cc905184
|
|
@ -2231,9 +2231,13 @@ bool AstNode::simplify(bool const_fold, int stage, int width_hint, bool sign_hin
|
||||||
}
|
}
|
||||||
if (children[0]->type == AST_CONSTANT) {
|
if (children[0]->type == AST_CONSTANT) {
|
||||||
if (width != int(children[0]->bits.size())) {
|
if (width != int(children[0]->bits.size())) {
|
||||||
RTLIL::SigSpec sig(children[0]->bits);
|
RTLIL::Const val;
|
||||||
sig.extend_u0(width, children[0]->is_signed);
|
if (children[0]->is_unsized) {
|
||||||
children[0] = mkconst_bits(location, sig.as_const().to_bits(), is_signed);
|
val = children[0]->bitsAsUnsizedConst(width);
|
||||||
|
} else {
|
||||||
|
val = children[0]->bitsAsConst(width);
|
||||||
|
}
|
||||||
|
children[0] = mkconst_bits(location, val.to_bits(), is_signed);
|
||||||
fixup_hierarchy_flags();
|
fixup_hierarchy_flags();
|
||||||
}
|
}
|
||||||
children[0]->is_signed = is_signed;
|
children[0]->is_signed = is_signed;
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,11 @@ module pass_through(
|
||||||
endmodule
|
endmodule
|
||||||
|
|
||||||
module top;
|
module top;
|
||||||
|
localparam logic [63:0]
|
||||||
|
l01 = '0,
|
||||||
|
l02 = '1,
|
||||||
|
l03 = 'x,
|
||||||
|
l04 = 'z;
|
||||||
logic [63:0]
|
logic [63:0]
|
||||||
o01, o02, o03, o04,
|
o01, o02, o03, o04,
|
||||||
o05, o06, o07, o08,
|
o05, o06, o07, o08,
|
||||||
|
|
@ -36,5 +41,9 @@ module top;
|
||||||
assert (o10 === {64 {1'b1}});
|
assert (o10 === {64 {1'b1}});
|
||||||
assert (o11 === {64 {1'bx}});
|
assert (o11 === {64 {1'bx}});
|
||||||
assert (o12 === {64 {1'bz}});
|
assert (o12 === {64 {1'bz}});
|
||||||
|
assert (l01 === {64 {1'b0}});
|
||||||
|
assert (l02 === {64 {1'b1}});
|
||||||
|
assert (l03 === {64 {1'bx}});
|
||||||
|
assert (l04 === {64 {1'bz}});
|
||||||
end
|
end
|
||||||
endmodule
|
endmodule
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue