Add regression test for chained type definitions
Check that chained type definitions declared in different scopes are handled correctly. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
54afdc1e6b
commit
998d0c655d
|
|
@ -0,0 +1,51 @@
|
||||||
|
// Check that chained type definitions declared in different scopes work
|
||||||
|
// correctly.
|
||||||
|
|
||||||
|
package P1;
|
||||||
|
localparam A = 8;
|
||||||
|
typedef logic [A-1:0] T;
|
||||||
|
endpackage
|
||||||
|
|
||||||
|
package P2;
|
||||||
|
localparam A = 4;
|
||||||
|
typedef P1::T T;
|
||||||
|
endpackage
|
||||||
|
|
||||||
|
bit failed = 1'b0;
|
||||||
|
|
||||||
|
`define check(expr, val) \
|
||||||
|
if (expr !== val) begin \
|
||||||
|
$display("FAILED: %s, expected %0d, got %0d", `"expr`", val, expr); \
|
||||||
|
failed = 1'b1; \
|
||||||
|
end
|
||||||
|
|
||||||
|
module test;
|
||||||
|
localparam A = 2;
|
||||||
|
|
||||||
|
typedef P2::T T;
|
||||||
|
|
||||||
|
T x;
|
||||||
|
P1::T y;
|
||||||
|
P2::T z;
|
||||||
|
|
||||||
|
initial begin
|
||||||
|
x = 8'hff;
|
||||||
|
y = 8'hff;
|
||||||
|
z = 8'hff;
|
||||||
|
|
||||||
|
`check(x, 8'hff);
|
||||||
|
`check($bits(T), 8);
|
||||||
|
`check($bits(x), 8);
|
||||||
|
`check(y, 8'hff);
|
||||||
|
`check($bits(y), 8);
|
||||||
|
`check($bits(P1::T), 8);
|
||||||
|
`check(z, 8'hff);
|
||||||
|
`check($bits(z), 8);
|
||||||
|
`check($bits(P2::T), 8);
|
||||||
|
|
||||||
|
if (!failed) begin
|
||||||
|
$display("PASSED");
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
endmodule
|
||||||
|
|
@ -704,6 +704,7 @@ sv_typedef_array_base1 normal,-g2009 ivltests
|
||||||
sv_typedef_array_base2 normal,-g2009 ivltests
|
sv_typedef_array_base2 normal,-g2009 ivltests
|
||||||
sv_typedef_array_base3 normal,-g2009 ivltests
|
sv_typedef_array_base3 normal,-g2009 ivltests
|
||||||
sv_typedef_array_base4 normal,-g2009 ivltests
|
sv_typedef_array_base4 normal,-g2009 ivltests
|
||||||
|
sv_typedef_chained normal,-g2009 ivltests
|
||||||
sv_typedef_darray_base1 normal,-g2009 ivltests
|
sv_typedef_darray_base1 normal,-g2009 ivltests
|
||||||
sv_typedef_darray_base2 normal,-g2009 ivltests
|
sv_typedef_darray_base2 normal,-g2009 ivltests
|
||||||
sv_typedef_darray_base3 normal,-g2009 ivltests
|
sv_typedef_darray_base3 normal,-g2009 ivltests
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue