M
Marius Vollmer
Guest
Hi,
I would like to declare an entity that has a port with type
array (1 to columns) of signed (width-1 downto 0)
where both "columns" and "width" are generics of the entity. How can
I do that?
The natural (for me at least) formulation would be along the lines of
entity matrix_source is
generic (
filename : string;
rows, columns : integer;
row_delay, column_delay : integer;
zero_rows : integer;
width : integer);
subtype value is signed (width-1 downto 0);
type value_vector is array (natural range <> of value;
port (
clk : in std_logic;
rst : in std_logic;
data : out value_vector (1 to columns));
end matrix_source;
However, this is not legal VHDL since ports can not follow entity
declarative items such as the type declarations.
I would be happy to put "value" and "value_vector" into a package but
I can't since "width" is a generic and unknown to that package.
I tried to use a multi-dimensional unconstrained array such as
type signed_vector is array (natural range <>, natural range <>
of std_logic;
and used it as
port (
data : out signed_vector (1 to columns, width-1 downto 0));
but that is unnatural (to me) since you than need to write stuff like
data (col, width-1 downto 0) <= to_signed (..., width);
which is not only unnatural but also illegal VHDL since you can't
slice a multi-dimensional array.
I must be missing something...
Thanks in advance!
--
Marius Vollmer AG Datentechnik / E-Technik
Tel: +49-231-755-3036 Universität Dortmund
Fax: +49-231-755-3251 Otto-Hahn-Str.4
http://www-dt.e-technik.uni-dortmund.de 44221 Dortmund, Germany
I would like to declare an entity that has a port with type
array (1 to columns) of signed (width-1 downto 0)
where both "columns" and "width" are generics of the entity. How can
I do that?
The natural (for me at least) formulation would be along the lines of
entity matrix_source is
generic (
filename : string;
rows, columns : integer;
row_delay, column_delay : integer;
zero_rows : integer;
width : integer);
subtype value is signed (width-1 downto 0);
type value_vector is array (natural range <> of value;
port (
clk : in std_logic;
rst : in std_logic;
data : out value_vector (1 to columns));
end matrix_source;
However, this is not legal VHDL since ports can not follow entity
declarative items such as the type declarations.
I would be happy to put "value" and "value_vector" into a package but
I can't since "width" is a generic and unknown to that package.
I tried to use a multi-dimensional unconstrained array such as
type signed_vector is array (natural range <>, natural range <>
of std_logic;
and used it as
port (
data : out signed_vector (1 to columns, width-1 downto 0));
but that is unnatural (to me) since you than need to write stuff like
data (col, width-1 downto 0) <= to_signed (..., width);
which is not only unnatural but also illegal VHDL since you can't
slice a multi-dimensional array.
I must be missing something...
Thanks in advance!
--
Marius Vollmer AG Datentechnik / E-Technik
Tel: +49-231-755-3036 Universität Dortmund
Fax: +49-231-755-3251 Otto-Hahn-Str.4
http://www-dt.e-technik.uni-dortmund.de 44221 Dortmund, Germany