R
ra
Guest
Hi,
I'm trying to define a component whose number of input ports, as well as
the size of the ports depend on a generic parameter. I was hoping to use
the following syntax:
entity mycomponent is
generic (
NUM_INPUTS : integer := 4;
DATA_WIDTH : integer := 32;
);
port(
CLK : in std_logic;
RESET : in std_logic;
A : array(0 to NUM_INPUTS-1) of std_logic_vector(0 to
DATA_WIDTH-1);
end mycomponent;
But modelsim doesn't seem to like this. I tried also
entity mycomponent is
generic (
NUM_INPUTS : integer := 4;
DATA_WIDTH : integer := 32;
);
port(
CLK : in std_logic;
RESET : in std_logic;
A : array(natural range 0 to NUM_INPUTS-1) of
std_logic_vector(0 to DATA_WIDTH-1);
end mycomponent;
Which didn't work either. As modelSim always complain with the message:
Error: mycomponent.vhd(61): near "array": expecting: STRING IDENTIFIER
I'm starting to think that I can't use array in the port declaration,
and I need to declare a type. However, because I'm using the type in the
ports, I need to do that in a package (which is kind of annoying).
Anyway, I tried that, defining the package as follows:
package my_util is
type std_logic_arr is array(natural range <> of std_logic;
type std_logic_vector_arr is array(natural range <> of
std_logic_vector(natural range <>
end my_util;
But that didn't work either.
Can anybody suggest how to do this, possibly without requiring a package?
Thanks,
Roberto
I'm trying to define a component whose number of input ports, as well as
the size of the ports depend on a generic parameter. I was hoping to use
the following syntax:
entity mycomponent is
generic (
NUM_INPUTS : integer := 4;
DATA_WIDTH : integer := 32;
);
port(
CLK : in std_logic;
RESET : in std_logic;
A : array(0 to NUM_INPUTS-1) of std_logic_vector(0 to
DATA_WIDTH-1);
end mycomponent;
But modelsim doesn't seem to like this. I tried also
entity mycomponent is
generic (
NUM_INPUTS : integer := 4;
DATA_WIDTH : integer := 32;
);
port(
CLK : in std_logic;
RESET : in std_logic;
A : array(natural range 0 to NUM_INPUTS-1) of
std_logic_vector(0 to DATA_WIDTH-1);
end mycomponent;
Which didn't work either. As modelSim always complain with the message:
Error: mycomponent.vhd(61): near "array": expecting: STRING IDENTIFIER
I'm starting to think that I can't use array in the port declaration,
and I need to declare a type. However, because I'm using the type in the
ports, I need to do that in a package (which is kind of annoying).
Anyway, I tried that, defining the package as follows:
package my_util is
type std_logic_arr is array(natural range <> of std_logic;
type std_logic_vector_arr is array(natural range <> of
std_logic_vector(natural range <>
end my_util;
But that didn't work either.
Can anybody suggest how to do this, possibly without requiring a package?
Thanks,
Roberto