Closed kele14x closed 1 year ago
The resulting expression for these literals depends on the context in which they are used. It sounds like you may have found a case where the converted result is not behaviorally equivalent to the source. Could you share a concrete test case so that I can work on this issue? Thank you!
Hi,
Seems GitHub does no allow me directly upload .sv file. So I compress file issue_test.sv into a zip:
The issue was on line 11
logic [7:0] dout;
...
dout <= '1;
dout
is a 8-bit logic value, which will be reset to 8'hFF
when rst
is assert. But generated .v file set it to 1:
dout <= 1'sb1;
In this particular context, 1'sb1
is functionally equivalent to '1
(and 8'hFF
) due to sign-extension. sv2v uses 1'sb1
as an optimization, as it is equivalent to '1
regardless of the type of the left-hand side.
As a basic example, the below prints 111111
as desired.
module top;
logic [5:0] x;
initial begin
x = 1'sb1;
$display("%b", x);
end
endmodule
Thanks @zachjs, I made a mistake on purpose of 'sd
. It should work as desired.
IEEE 2800-2017 5.7.1 Specifies unsized single-bit value as "set all bit". But sv2v write out signle bit value (
'0 -> 1'sb0
and'1 -> 1'sb1
).Tested with sv2v v0.0.10-0-g87642c0 on Windows.