Add regression tests for member selects on package scoped identifiers

Check that indices to package scoped identifiers are evaluated in the scope
where the identifier is accessed and not in the scope where the identifier
is declared.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-12-27 20:30:29 -08:00
parent 710267e9bb
commit b07a66b8a3
5 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,18 @@
// Check that indices to a package scoped identifier get evaluated in the scope
// where the identifier is used, not where the identifier is declared.
package P;
localparam N = 1;
logic [3:0] x = 4'b0101;
endpackage
module test;
localparam N = 2;
initial begin
if (P::x[N] === 1'b1) begin
$display("PASSED");
end else begin
$display("FAILED");
end
end
endmodule

View File

@ -0,0 +1,21 @@
// Check that indices to a struct member for package scoped identifier get
// evaluated in the scope where the identifier is used, not where the identifier
// is declared.
package P;
localparam N = 1;
struct packed {
logic [3:0] x;
} s = 4'b0101;
endpackage
module test;
localparam N = 2;
initial begin
if (P::s.x[N] === 1'b1) begin
$display("PASSED");
end else begin
$display("FAILED");
end
end
endmodule

View File

@ -0,0 +1,24 @@
// Check that indices to a property for package scoped identifier get evaluated
// in the scope where the identifier is used, not where the identifier is
// declared.
package P;
localparam N = 1;
class C;
localparam X = 4'b0101;
endclass
C c = new;
endpackage
module test;
localparam N = 2;
initial begin
if (P::c.X[N] === 1'b1) begin
$display("PASSED");
end else begin
$display("FAILED");
end
end
endmodule

View File

@ -692,6 +692,9 @@ sv_ps_function4 normal,-g2009 ivltests
sv_ps_function5 normal,-g2009 ivltests
sv_ps_function6 normal,-g2009 ivltests
sv_ps_function7 normal,-g2009 ivltests
sv_ps_member_sel1 normal,-g2009 ivltests
sv_ps_member_sel2 normal,-g2009 ivltests
sv_ps_member_sel3 normal,-g2009 ivltests
sv_ps_type1 normal,-g2009 ivltests
sv_ps_type_cast1 normal,-g2009 ivltests
sv_ps_type_cast2 normal,-g2009 ivltests

View File

@ -458,6 +458,7 @@ sv_port_default6 CE,-g2009,-pallowsigned=1 ivltests
sv_port_default7 CE,-g2009,-pallowsigned=1 ivltests
sv_port_default8 CE,-g2009,-pallowsigned=1 ivltests
sv_port_default9 CE,-g2009 ivltests
sv_ps_member_sel3 CE,-g2009 ivltests
sv_ps_type_class1 CE,-g2009 ivltests
sv_ps_type_class_prop CE,-g2009 ivltests
sv_root_class CE,-g2009 ivltests