include both power-of-two and non-power-of-two testcases
authorN. Engelhardt <nak@symbioticeda.com>
Tue, 18 Aug 2020 16:54:22 +0000 (18:54 +0200)
committerN. Engelhardt <nak@symbioticeda.com>
Tue, 18 Aug 2020 16:54:22 +0000 (18:54 +0200)
tests/svtypes/struct_array.sv

index 9c90375ee3515d70e078aa9265d49abfb5d844bf..873f7befdf71a8d71ca21457c26e584d0fdf46f8 100644 (file)
@@ -1,9 +1,9 @@
 // test for array indexing in structures
 
 module top;
-       
+
        struct packed {
-               bit [7:0] [7:0] a;      // 8 element packed array of bytes
+               bit [5:0] [7:0] a;      // 6 element packed array of bytes
                bit [15:0] b;           // filler for non-zero offset
        } s;
 
@@ -13,13 +13,30 @@ module top;
                s.a[2:1] = 16'h1234;
                s.a[5] = 8'h42;
 
-               s.a[7] = '1;
-               s.a[7][1:0] = '0;
-
                s.b = '1;
                s.b[1:0] = '0;
        end
 
-       always_comb assert(s==80'hFC00_4200_0012_3400_FFFC);
+       always_comb assert(s==64'h4200_0012_3400_FFFC);
+
+       struct packed {
+               bit [7:0] [7:0] a;      // 8 element packed array of bytes
+               bit [15:0] b;           // filler for non-zero offset
+       } s2;
+
+       initial begin
+               s2 = '0;
+
+               s2.a[2:1] = 16'h1234;
+               s2.a[5] = 8'h42;
+
+               s2.a[7] = '1;
+               s2.a[7][1:0] = '0;
+
+               s2.b = '1;
+               s2.b[1:0] = '0;
+       end
+
+       always_comb assert(s2==80'hFC00_4200_0012_3400_FFFC);
 
 endmodule