Variable array size in entity

F

FabM

Guest
Hello,

I want to do a variable array size port configurable with generic
value. The goal is to have a generic variables port output.

I try this but it doesn't work, Xilinx ISE require type declaration at
the end of entity.

Entity rams_line is
generic
(
p_size : natural := 10; -- size (in bits) of pixel values
matrix_size : natural := 3; -- size of convolution matrix
);
type ltab is array(1 to matrix_size) of std_logic_vector(p_size-1
downto 0);
port
(
-- output/read
line_tab : out ltab
);
end entity;

If you have an idea ?

FabM
 
Have a look at

http://groups.google.com/group/comp.lang.vhdl/browse_thread/thread/80822837e3c69d8d/

Have a nice synthesis,

--enes
 
On 23 Feb, 13:42, FabM <lepingouin....@gmail.com> wrote:
Hello,

I want to do a variable array size port configurable with generic
value. The goal is to have a generic variables port output.

I try this but it doesn't work, Xilinx ISE require type declaration at
the end of entity.

Entity rams_line is
generic
(
    p_size : natural := 10;       -- size (in bits) of pixel values
    matrix_size : natural := 3;   -- size of convolution matrix
);
type ltab is array(1 to matrix_size) of std_logic_vector(p_size-1
downto 0);
port
(
    -- output/read
    line_tab : out ltab
);
end entity;

If you have an idea ?

FabM

VHDL 2008 supports type declarations in generics, but Im not sure
whether this is meant as full types or subtypes. But this is unlikely
to be supported by synthesis vendors for some time.

Otherwise, the only way to do this is by declaring the constants and
2d array type in a packing, and including the package in the design
file. The only problem is, until VHDL 2008, 2d arrays (of the style
you have) have to have the object dimension fixed. ie:

type ltab is array(natural range <>) of std_logic_vector(p_size-1
downto 0);

But, usually, things like word widths are set for an entire design, so
that shouldnt be a problem.

once you've fixed p_size in a package constant, you set set
matrix_size on an entity by entity basis, via the generic. You
actually dont even need this generic, you can just have this:

package setup_package is
constant P_SIZE : natural := 10;
type ltab is array(natural range <>) of std_logic_vector(P_SIZE-1
downto 0); --although I would probably recommend unsigneds instead of
std_logic-vector as you are doing arithmatic on these values.
end package setup_package;

etity rams_line is
port (
line_tab : out ltab
)
--inside entity code you can use attributes like 'range, 'high, 'low
to do the indexing

......

--inside architecture:
signal ent1_line_tab : ltab(1 to 3); -- MATRIX_SIZE = 3;

...

my_rams_line : entity work.rams_line
port map (
line_tab => ent1_line_tab --size implied from connecting signal
);
 
VHDL 2008 supports type declarations in generics, but Im not sure
whether this is meant as full types or subtypes. But this is unlikely
to be supported by synthesis vendors for some time.

Otherwise, the only way to do this is by declaring the constants and
2d array type in a packing, and including the package in the design
file. The only problem is, until VHDL 2008, 2d arrays (of the style
you have) have to have the object dimension fixed. ie:

type ltab is array(natural range <>) of std_logic_vector(p_size-1
downto 0);

But, usually, things like word widths are set for an entire design, so
that shouldnt be a problem.

once you've fixed p_size in a package constant, you set set
matrix_size on an entity by entity basis, via the generic. You
actually dont even need this generic, you can just have this:

package setup_package is
  constant P_SIZE      : natural := 10;
  type ltab is array(natural range <>) of std_logic_vector(P_SIZE-1
downto 0); --although I would probably recommend unsigneds instead of
std_logic-vector as you are doing arithmatic on these values.
end package setup_package;

etity rams_line is
port (
  line_tab : out ltab
)
--inside entity code you can use attributes like 'range, 'high, 'low
to do the indexing

.....

--inside architecture:
signal ent1_line_tab : ltab(1 to 3); -- MATRIX_SIZE = 3;

..

my_rams_line : entity work.rams_line
port map (
  line_tab => ent1_line_tab   --size implied from connecting signal
);
Thank you very much for your quick and detailed response. I will try
this.

FabM
 
Tricky wrote:
On 23 Feb, 13:42, FabM <lepingouin....@gmail.com> wrote:
Hello,

I want to do a variable array size port configurable with generic
value. The goal is to have a generic variables port output.

I try this but it doesn't work, Xilinx ISE require type declaration at
the end of entity.

Entity rams_line is
generic
(
p_size : natural := 10; -- size (in bits) of pixel values
matrix_size : natural := 3; -- size of convolution matrix
);
type ltab is array(1 to matrix_size) of std_logic_vector(p_size-1
downto 0);
port
(
-- output/read
line_tab : out ltab
);
end entity;

If you have an idea ?

FabM


VHDL 2008 supports type declarations in generics, but Im not sure
whether this is meant as full types or subtypes. But this is unlikely
to be supported by synthesis vendors for some time.
This is a very significant feature for verification, so I expect the
simulator vendors are already working on it. Particularly wrt type and
subprogram generics on packages. I already have package prototypes that
will be switched over once we have this capability.

Since this is a required feature to implement fixed_generic_pkg and
float_generic_pkg, I expect that this feature is also a high priority
for synthesis vendors.

OTOH, in VHDL-2008, there is a better way to do this. You can
create unconstrained arrays of unconstrained elements:

type array_of_vectors is array (natural range <>) of std_logic_vector ;

Then in your entity:

port (
line_tab : array_of_vectors (p_size)(matrix_size) ;
)

Numerous people have been wanting to do this here on c.l.v.
Since VHDL-2008 is already an IEEE standard and that these features
were part of Accellera VHDL 3.0 revision in 2006, you need to
be proactive and ask your vendors to implement it (and why
they didn't start implementing in 2006 as most had members
participating).

Cheers,
Jim
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jim Lewis SynthWorks VHDL Training http://www.synthworks.com

A bird in the hand may be worth two in the bush,
but it sure makes it hard to type.
 

Welcome to EDABoard.com

Sponsor

Back
Top