Add test for direct packed arrays of struct and enums

It is possible to directly declare a packed array of a struct or enum
without having to create a typedef first.

Add a check to the array_packed test that this is supported and works as
expected.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-01-15 19:02:10 +01:00
parent 3ca1c129ce
commit c670170ac0
1 changed files with 15 additions and 5 deletions

View File

@ -23,6 +23,10 @@ EP [2:0] epp1;
EPP epp2;
EPP [3:0] eppp;
enum logic [7:0] {
B
} [1:0] ep3;
typedef struct packed {
longint x;
} S1;
@ -54,6 +58,10 @@ SP [9:0] spp1;
SPP spp2;
SPP [1:0] sppp;
struct packed {
S2 s;
} [3:0] sp3;
bit failed = 1'b0;
initial begin
@ -65,17 +73,19 @@ initial begin
failed |= $bits(e) !== 8;
failed |= $bits(ep1) !== $bits(e) * 2;
failed |= $bits(ep2) !== $bits(ep1);
failed |= $bits(ep3) !== $bits(ep1);
failed |= $bits(epp1) !== $bits(ep1) * 3;
failed |= $bits(epp2) !== $bits(epp1);
failed |= $bits(eppp) !== $bits(epp1) * 4;
// Packed arrays of structs
failed |= $bits(s) !== S_SIZE;
failed |= $bits(sp1) != $bits(s) * 4;
failed |= $bits(sp2) != $bits(sp1);
failed |= $bits(spp1) != $bits(sp1) * 10;
failed |= $bits(spp1) != $bits(spp2);
failed |= $bits(sppp) != $bits(spp1) * 2;
failed |= $bits(sp1) !== $bits(s) * 4;
failed |= $bits(sp2) !== $bits(sp1);
failed |= $bits(sp3) !== $bits(sp1);
failed |= $bits(spp1) !== $bits(sp1) * 10;
failed |= $bits(spp1) !== $bits(spp2);
failed |= $bits(sppp) !== $bits(spp1) * 2;
if (failed)
$display("FAILED");