Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Re: Multi-dimentional arrays in components using generics

Reply
Thread Tools

Re: Multi-dimentional arrays in components using generics

 
 
Willem Oosthuizen
Guest
Posts: n/a
 
      07-09-2003
I can put the types in a PACKAGE, but how do I pass the generics to the
PACKAGE?

"Willem Oosthuizen" <> wrote in message
news:begood$1u5$...
> How do I do multi-dimentional arrays in components using generics
>
> I tried the following. This does not work. I need to define the type
> array(Depth -1 downto 0) of std_logic_vector(Width-1 downto 0) and
> type array(Depth -2 downto 0) of std_logic_vector(Width-2 downto 0)
> somewhere. But where?
>
> COMPONENT Reduce is
> generic
> ( Width : integer;
> Depth : integer
> );
> port
> ( D_IN : IN array(Depth -1 downto 0) of std_logic_vector(Width-1 downto
> 0);
> Q : OUT array(Depth -2 downto 0) of std_logic_vector(Width-2

downto
> 0);
> );
> end COMPONENT;
>
>
>
>



 
Reply With Quote
 
 
 
 
Jonathan Bromley
Guest
Posts: n/a
 
      07-09-2003
Hi Willem,

> "Willem Oosthuizen" <> wrote in message
> news:begood$1u5$...
> > How do I do multi-dimentional arrays in components using generics
> >
> > I tried the following. This does not work. I need to define the type
> > array(Depth -1 downto 0) of std_logic_vector(Width-1 downto 0) and
> > type array(Depth -2 downto 0) of std_logic_vector(Width-2 downto 0)
> > somewhere. But where?

[and then...]
> I can put the types in a PACKAGE, but how do I pass the generics to the
> PACKAGE?


This is all a bit horrible in VHDL. When you make an array of something,
the full details of that "something" must be known. Your need for a
parameterisable 2-dimensional array is usually solved in one of the
following ways:

(1) Use a true 2-dimensional array
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

type Arr2D is array (Depth-1 downto 0, Width-1 downto 0) of std_logic;

This is legal VHDL, and you can then create arrays and subscript them:

signal S: Arr2D;
....
S(3,4) <= '0';

But unfortunately it doesn't play well with std_logic_vector
because there is no easy way to copy a row or column of this 2-d
array to/from a 1-D vector - you have to use a FOR loop.

(2) Put the subtype in a package
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

as you suggested...

package MyTypes is
constant Width: integer; --- deferred constant, no value
subtype Row_T is std_logic_vector(Width-1 downto 0);
end;

....
type Vec2D is array(Depth-1 downto 0) of Row_T;

But then, as you say, you need "to pass a generic
into the package". You can't do that. There is only
one "instance" of a package in any given VHDL simulation,
so the package can't have a generic. I've got close to
what you need by using a deferred constant; you set
up the deferred constant's value in the package body:

package body MyTypes is
constant Width: integer := 5;
end;

This package body can be compiled separately, just before
you elaborate the design, but the same Width value will apply
throughout the simulation.

(3) Fake it up with a big 1-D array
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

No help at all, because you can't take a slice
that has non-static bounds.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Sorry I can't help more. It's a somewhat messy problem.


 
Reply With Quote
 
 
 
Reply

Thread Tools

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generics in VHDL - number of components pbartosz VHDL 2 03-09-2011 02:47 PM
Components with GENERICs Analog_Guy VHDL 3 07-02-2010 02:28 AM
generics depending on generics Soul VHDL 0 02-02-2009 09:14 AM
Multidimensional arrays and arrays of arrays Philipp Java 21 01-20-2009 08:33 AM
Can't convert a generics list of objects into a generics list ofinterfaces Juergen Berchtel Java 1 05-20-2005 02:07 PM



Advertisments
 



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 47 48 49 50 51 52 53 54 55 56 57