Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - Variable array size in entity

 
Thread Tools Search this Thread
Old 02-23-2009, 01:42 PM   #1
Default Variable array size in entity


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


FabM
  Reply With Quote
Old 02-23-2009, 02:03 PM   #2
Enes Erdin
 
Posts: n/a
Default Re: Variable array size in entity
Have a look at

http://groups.google.com/group/comp....22837e3c69d8d/

Have a nice synthesis,

--enes



Enes Erdin
  Reply With Quote
Old 02-23-2009, 04:35 PM   #3
Tricky
 
Posts: n/a
Default Re: Variable array size in entity
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
);


Tricky
  Reply With Quote
Old 02-24-2009, 08:35 AM   #4
FabM
 
Posts: n/a
Default Re: Variable array size in entity

>
> 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


FabM
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
VHDL and EDK: Custom IP core containing an array as a port using EDK allsey_1987 Hardware 0 10-27-2009 02:26 PM
Error: Physical sythesis tool PALAC is not supported by Formal Verification tool Conf bbiandov Software 0 12-22-2008 05:25 AM
Variable scope toller Hardware 1 04-21-2008 08:28 PM
synthesis error sekhar_kollati Hardware 0 11-13-2007 04:48 AM
Variable Scope in asp.Net jansi_rk Software 1 09-18-2006 06:05 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46