Electrical – How to use an array type as parameter of a Procedure

modelsimvhdl

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
  ReadFromFile(Output, Input_FName, 20 ns);
  ...
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 ?

Best Answer

Your procedure is fine, it can accept any size qitArray. But when you declare your signal in your test bench, which you later pass to the procedure, it has to have a well defined length.