VHDL novice question

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
 
Roberto,
Bad news. Can't do it now.

Good news. It is a candidate for the next language rev. See:
http://www.eda.org/vhdl-200x/vhdl-200x-ft/proposals/proposals.html

It is proposal # FT14

Cheers,
Jim

I found a thread on google news that seem to suggest that this is
impossible... just because of a crappy syntactic definition of VHDL.
please tell me it's not true. If it is, has anybody found a workaround?

Roberto


ra wrote:

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

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jim Lewis
Director of Training mailto:Jim@SynthWorks.com
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
BTW, is this any better in verilog?

Roberto


Jim Lewis wrote:

Roberto,
Bad news. Can't do it now.

Good news. It is a candidate for the next language rev. See:
http://www.eda.org/vhdl-200x/vhdl-200x-ft/proposals/proposals.html

It is proposal # FT14

Cheers,
Jim

I found a thread on google news that seem to suggest that this is
impossible... just because of a crappy syntactic definition of VHDL.
please tell me it's not true. If it is, has anybody found a workaround?

Roberto


ra wrote:

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
 

Welcome to EDABoard.com

Sponsor

Back
Top