Files
iverilog/ivtest/ivltests/enum_method_signed2.v
T
Lars-Peter Clausen 0c123b8498 Add regression tests for methods with signed return values
Check that the signedness of the return value of methods is handled
correctly.
  * When sign extending
  * When passing as a value to a system function

Check this for both methods on user defined class as well as built-in
methods on SystemVerilog types.

Signed-off-by: Lars-Peter Clausen <[email protected]>
2022-04-14 12:01:23 +02:00

36 lines
727 B
Verilog

// Check that the signedness of methods on the built-in enum type is handled
// correctly when calling the function with parenthesis and passing the result
// to a system function.
module test;
enum shortint {
A = -1,
B = -2,
C = -3
} es;
enum bit [15:0] {
X = 65535,
Y = 65534,
Z = 65533
} eu;
string s;
initial begin
es = B;
eu = Y;
s = $sformatf("%0d %0d %0d %0d %0d %0d %0d %0d",
es.first(), es.last(), es.prev(), es.next(),
eu.first(), eu.last(), eu.prev(), eu.next());
if (s == "-1 -3 -1 -3 65535 65533 65535 65533") begin
$display("PASSED");
end else begin
$display("FAILED s=%s", s);
end
end
endmodule