# How to use an array type as parameter of a Procedure

I want to read input values from a file and store them in an array

I have defined a custom array type in a package as :

TYPE qit IS ('0', '1', 'Z', 'X');
...
Type qitArray IS Array(Natural Range <>) OF qit;


and I have a procedure defined as :

Procedure ReadFromFile(Signal Output : OUT qitArray; File_Name : IN String; Delay : Time);


In Test Bench, I have declared a qitArray signal and I have passed it to procedure as parameter like this :

 Constant Input_FName : String := "input_file.txt";
...
Signal Output : qitArray;
Begin
...
End;


there is no compile error on the package file, but when I want to compile Test Bench, an error says :

Array type of "Output" does not have an index constraint

The array length is unknown

How can I use an unknown-length array type ( or dynamic array ) as parameter in a procedure ?

• Duplicate of stackoverflow.com/questions/36968274/… – user_1818839 May 1 '16 at 16:28
• @BrianDrummond : I have deleted it from SO – G3ntle_Man May 1 '16 at 16:33
• You cannot have arrays of unknown size. It's a hardware description language, everything has a size. So figure out what's the maximum size of your array. Either use one of your 4 values as empty/unused or define a fivths value or return a second parameter size/length like in C. – Paebbels May 1 '16 at 17:09
• Could you provide an example of your input file and clarify which characteristics of it will vary? (e.g., number of lines, length of each line, etc.) – rick May 3 '16 at 21:29