Add regression test for struct member signedness
Check that when using a struct member in an expression its signedness is handled correctly. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
662e82c013
commit
1c0955178d
|
|
@ -0,0 +1,41 @@
|
|||
// Tests that the signedness for struct members is handled correctly
|
||||
|
||||
module test;
|
||||
|
||||
struct packed {
|
||||
logic [15:0] x;
|
||||
logic signed [15:0] y;
|
||||
} s;
|
||||
|
||||
bit failed = 1'b0;
|
||||
|
||||
`define check(x) \
|
||||
if (!(x)) begin \
|
||||
$display("FAILED: ", `"x`"); \
|
||||
failed = 1'b1; \
|
||||
end
|
||||
|
||||
initial begin
|
||||
s.x = -1;
|
||||
s.y = -1;
|
||||
|
||||
`check(!$is_signed(s.x));
|
||||
`check($is_signed(s.y));
|
||||
|
||||
// These evaluate as signed
|
||||
`check($signed(s.x) < 0);
|
||||
`check(s.y < 0);
|
||||
|
||||
// These all evaluate as unsigned
|
||||
`check(s.x > 0);
|
||||
`check(s.y[15:0] > 0)
|
||||
`check({s.y} > 0)
|
||||
`check($unsigned(s.y) > 0)
|
||||
`check(s.y > 16'h0)
|
||||
|
||||
if (!failed) begin
|
||||
$display("PASSED");
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
|
|
@ -383,6 +383,7 @@ struct7 normal,-g2009 ivltests
|
|||
struct8 normal,-g2009 ivltests
|
||||
struct9 normal,-g2009 ivltests
|
||||
struct_line_info CE,-g2009 ivltests gold=struct_line_info.gold
|
||||
struct_member_signed normal,-g2009 ivltests
|
||||
struct_packed_array normal,-g2009 ivltests
|
||||
struct_packed_array2 normal,-g2009 ivltests
|
||||
struct_packed_sysfunct normal,-g2009 ivltests
|
||||
|
|
|
|||
|
|
@ -839,6 +839,7 @@ simple_longint normal,-g2009,-pallowsigned=1 ivltests
|
|||
simple_shortint normal,-g2009,-pallowsigned=1 ivltests
|
||||
size_cast3 normal,-g2009,-pallowsigned=1 ivltests
|
||||
size_cast5 normal,-g2009,-pallowsigned=1 ivltests
|
||||
struct_member_signed normal,-g2009,-pallowsigned=1 ivltests
|
||||
struct_packed_array normal,-g2009,-pallowsigned=1 ivltests
|
||||
struct_packed_array2 normal,-g2009,-pallowsigned=1 ivltests
|
||||
struct_signed normal,-g2009,-pallowsigned=1 ivltests
|
||||
|
|
|
|||
Loading…
Reference in New Issue