I have been trying to declare my type in a separate "mytypes.vhd" file as follows:
library ieee;
use ieee.std_logic_1164.all;
package mytypes is
type my_bus_array_type is array (0 to 3) of std_logic_vector(7 downto 0);
end package mytypes;
and then define an entity as follows:
library ieee;
use ieee.std_logic_1164.all;
library work;
use work.mytypes.all;
entity my_entity is
port(
bus_array : in my_bus_array_type;
...
);
end my_entity;
Well, this is not working. When I try to add the component to my library with the Altera Qsys tool, I get the following error:
Error: Verilog HDL or VHDL XML Interface error at my_entity.vhd(41): port "bus_array" has an unsupported type File: /home/project/my_entity.vhd Line: 41
Please note that the problem is the fact that I am trying to define inside an entity an array of standard_logic_vector, i.e. a multidimensional array. This code works correctly if I define an array of std_logic instead.
You mentioned you're using Quartus, which can be picky about using std_logic_vectors as base types for other items.
I do what I think you're after in Quartus using subtypes:
mytypes.vhd file:
my_entity.vhd file:
It's up to you whether you want to define the array range in the entity (perhaps using a generic), or in your package.