Merge pull request #721 from larsclausen/vvp-struct-sign

tgt-vvp: Handle signedness when passing struct member to system function
This commit is contained in:
Stephen Williams 2022-06-01 23:11:58 -07:00 committed by GitHub
commit e4d2b05976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,46 @@
// Check that the signedness of a struct member is handled correctly when passed
// to a system function
module test;
bit failed = 1'b0;
struct packed {
int s;
int unsigned u;
} x;
int s;
int unsigned u;
logic [16*8-1:0] s1;
logic [16*8-1:0] s2;
initial begin
u = -10;
s = -20;
x.u = u;
x.s = s;
$swrite(s1, s);
$swrite(s2, x.s);
if (s1 != s2) begin
failed = 1'b1;
$display("FAILED. Expected %s, got %s.", s1, s2);
end
$swrite(s1, u);
$swrite(s2, x.u);
if (s1 != s2) begin
failed = 1'b1;
$display("FAILED. Expected %s, got %s.", s1, s2);
end
if (!failed) begin
$display("PASSED");
end
end
endmodule

View File

@ -456,6 +456,7 @@ struct_member_signed normal,-g2009 ivltests
struct_packed_array normal,-g2009 ivltests
struct_packed_array2 normal,-g2009 ivltests
struct_packed_sysfunct normal,-g2009 ivltests
struct_packed_sysfunct2 normal,-g2009 ivltests
struct_packed_write_read2 normal,-g2009 ivltests
struct_invalid_member CE,-g2009 ivltests gold=struct_invalid_member.gold
struct_signed normal,-g2009 ivltests

View File

@ -927,6 +927,7 @@ 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_packed_sysfunct2 normal,-g2009,-pallowsigned=1 ivltests
struct_signed normal,-g2009,-pallowsigned=1 ivltests
sv_for_variable normal,-g2009,-pallowsigned=1 ivltests
sv_foreach1 normal,-g2009,-pallowsigned=1 ivltests

View File

@ -199,6 +199,11 @@ static int get_vpi_taskfunc_signal_arg(struct args_info *result,
if (ivl_expr_value(vexpr) == IVL_VT_DARRAY)
return 0;
/* Part select is always unsigned. If the expression is signed
* fallback. */
if (ivl_expr_signed(expr))
return 0;
/* The signal is part of an array. */
/* Add &APV<> code here when it is finished. */
bexpr = ivl_expr_oper2(expr);