A
Amal
Is there a way (in VHDL93) to define an array of vectors in a package
and set the array size and vector size later? Basically, I would like
to set the number of array elements and the vector sizes later (maybe
using a function call). I know this could be done using an enity with
generics like this:
entity mem is
generic (
d : positive := 32;
w : positive := 8
);
port (
...
);
end entity mem;
architecture rtl of mem is
type memType is array( 0 to d-1 ) of std_logic_vector( w-1 downto 0);
signal memory : memType;
begin
end architecture rtl;
But preferably, I would like to define the array in a package and
provide public functions to set the array size and access routines.
The advantage is having a set of packages with self contained routines
that mimic the object-oriented (abstraction and data hiding) features
of object-oriented langugaes. I know there is a VHDL-200x-FT proposal
FT14 that includes partial and unconstrained array elements. But is
there a way to do it using VHDL93?
The following is a hypothetical example that would not compile!
package my_pkg
type arrayType is array( natural range <> ) of bit_vector( natural
range <> );
type memType is
record
d : integer;
w : integer;
memory : arrayType(0 to depth-1)( w-1 downto 0);
-- or any other initialization routine to initialize a ROM
-- := init(????)
end record;
procedure setMemSize( d: integer; w : integer );
end package my_pkg;
package body my_pkg is
procedure setMemSize( signal mem: in memType; d: integer; w : integer
) is
begin
mem.d := d;
mem.w := w;
mem.memory <= (others=>(others=>'0');
end procedure setMemSize;
end package body my_pkg;
-- Amal
and set the array size and vector size later? Basically, I would like
to set the number of array elements and the vector sizes later (maybe
using a function call). I know this could be done using an enity with
generics like this:
entity mem is
generic (
d : positive := 32;
w : positive := 8
);
port (
...
);
end entity mem;
architecture rtl of mem is
type memType is array( 0 to d-1 ) of std_logic_vector( w-1 downto 0);
signal memory : memType;
begin
end architecture rtl;
But preferably, I would like to define the array in a package and
provide public functions to set the array size and access routines.
The advantage is having a set of packages with self contained routines
that mimic the object-oriented (abstraction and data hiding) features
of object-oriented langugaes. I know there is a VHDL-200x-FT proposal
FT14 that includes partial and unconstrained array elements. But is
there a way to do it using VHDL93?
The following is a hypothetical example that would not compile!
package my_pkg
type arrayType is array( natural range <> ) of bit_vector( natural
range <> );
type memType is
record
d : integer;
w : integer;
memory : arrayType(0 to depth-1)( w-1 downto 0);
-- or any other initialization routine to initialize a ROM
-- := init(????)
end record;
procedure setMemSize( d: integer; w : integer );
end package my_pkg;
package body my_pkg is
procedure setMemSize( signal mem: in memType; d: integer; w : integer
) is
begin
mem.d := d;
mem.w := w;
mem.memory <= (others=>(others=>'0');
end procedure setMemSize;
end package body my_pkg;
-- Amal