How do I declare a packed array in Verilog?

OP #6371301
I've created an (enum) called (color), and included it in a packed 
(struct) called (triple), and then created a ten-element array called 
(group) in the following code:
1
module EnStAr ();
2

3
typedef enum { RED, ORANGE, YELLOW, GREEN, BLUE, VIOLET } color;
4
typedef struct packed
5
{   color clr;
6
  integer xCoo;
7
  integer yCoo;
8
} triple;
9

10
triple [ 9:0] group;
11

12
endmodule
When I execute the following command I get the following single error 
message:
1
D:\Hf\Verilog\Common>\Icarus\bin\iverilog -g2009 -o EnStAr.out EnStAr.sv
2
EnStAr.sv:10: Compound type is not PACKED in this context.
3

4
D:\Hf\Verilog\Common>
Line 10 is where I declare my array. Is this saying my array is not 
packed? If so, how do I fix this so that my array is packed? I guess the 
bottom line is, how do I change this file so that Icarus' simulator will 
compile it without error messages?
Guest #6375077
Could you solve the Problem? Your code compiles w/o problems in Questa. 
Maybe icarus cannot deal with packed arrays of complex elements. Do you 
really need a packed array here? Otherwise try
triple group [9:0]
OP #6376344
Vancouver: "Do you really need a packed array here? Otherwise try / 
triple group [9:0]". I tried that and it compiled without any complaint 
at all. Thanks! So I have to pack my (struct), but having done that I 
can't pack an array of that (struct)? Why is that?
Guest #6377153
To be honest, I dont know. Generally it is supported by SV, but it seems 
Icarus does not.
Anyway, a packed array only makes sense if you want to assign the 
complete array from a large bit vector for example. In this case, the 
array must be "dense", as the bit vector is. If the array elements are 
addressed via array index only, there is no need for using packed 
arrays.

Reply

A question of your own? This thread is over 6 years old. Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.

Start a new thread

A fix, an addition or feedback on this thread? Then reply here.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.