EmbDev.net

Forum: FPGA, VHDL & Verilog How do I declare a packed array in Verilog?


von Kevin S. (kvnsmnsn)


Rate this post
useful
not useful
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?

von Vancouver (Guest)


Rate this post
useful
not useful
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]

von Kevin S. (kvnsmnsn)


Rate this post
useful
not useful
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?

von Vancouver (Guest)


Rate this post
useful
not useful
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.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.