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

Reply

VHDL - Fully definable ports of array of std_logic_vectors?

 
Thread Tools Search this Thread
Old 12-12-2007, 05:57 PM   #1
Default Fully definable ports of array of std_logic_vectors?


Hello,

I have a construct that I would like to build to have fully definable
ports which are arrays of std_logic_vectors, but from what I have
read, I haven't figured out yet a way to do this in
VHDL-1987/1993/2002. It seems that this will be possible in
VHDL-200X. Does anybody know a way that I could create a functional
equivalent to this using one of today's standards? I don't think that
using a package to define the types is really an option since I will
be instantiating multiple copies of this in the same design with
different array and vector lengths (correct me if I'm wrong).

Thanks for the help!
John

entity sample is

generic (
array_length_g : positive := 4;
vector_length_g : positive := 12);
port (
clk : in std_logic;
clk_enable : in std_logic;
reset_n : in std_logic;
input : in array(0 to array_length_g-1) of
std_logic_vector(vector_length_g-1 downto 0);
output : out array(0 to array_length_g-1) of
std_logic_vector(vector_length_g-1 downto 0);

end sample;


paragon.john@gmail.com
  Reply With Quote
Old 12-12-2007, 08:32 PM   #2
KJ
 
Posts: n/a
Default Re: Fully definable ports of array of std_logic_vectors?
On Dec 12, 12:57 pm, paragon.j...@gmail.com wrote:
> Hello,
>
> I have a construct that I would like to build to have fully definable
> ports which are arrays of std_logic_vectors, but from what I have
> read, I haven't figured out yet a way to do this in
> VHDL-1987/1993/2002. It seems that this will be possible in
> VHDL-200X. Does anybody know a way that I could create a functional
> equivalent to this using one of today's standards? I don't think that
> using a package to define the types is really an option since I will
> be instantiating multiple copies of this in the same design with
> different array and vector lengths (correct me if I'm wrong).
>


You have to use a two dimensional array. First define a new type that
is a two dimensional array of std_ulogic (or std_logic if you'd
prefer).

type sulv2d is array(natural range<>, natural range<>) of std_ulogic;

Now you use that type on your entity
input : in sulv2d(0 to array_length_g-1,vector_length_g-1 downto
0);

It works and is synthesizable.

KJ


KJ
  Reply With Quote
Old 12-17-2007, 02:57 PM   #3
Andy
 
Posts: n/a
Default Re: Fully definable ports of array of std_logic_vectors?
On Dec 12, 2:32 pm, KJ <Kevin.Jenni...@unisys.com> wrote:
> On Dec 12, 12:57 pm, paragon.j...@gmail.com wrote:
>
> > Hello,

>
> > I have a construct that I would like to build to have fully definable
> > ports which are arrays of std_logic_vectors, but from what I have
> > read, I haven't figured out yet a way to do this in
> > VHDL-1987/1993/2002. It seems that this will be possible in
> > VHDL-200X. Does anybody know a way that I could create a functional
> > equivalent to this using one of today's standards? I don't think that
> > using a package to define the types is really an option since I will
> > be instantiating multiple copies of this in the same design with
> > different array and vector lengths (correct me if I'm wrong).

>
> You have to use a two dimensional array. First define a new type that
> is a two dimensional array of std_ulogic (or std_logic if you'd
> prefer).
>
> type sulv2d is array(natural range<>, natural range<>) of std_ulogic;
>
> Now you use that type on your entity
> input : in sulv2d(0 to array_length_g-1,vector_length_g-1 downto
> 0);
>
> It works and is synthesizable.
>
> KJ


I think what the OP is concerned about is that the length of the
elements in the array must also be defined in the package (per 2002
and earlier std), which then limits instances to always using that
same element length.

For a completely flexible interface, I would simply use an
SLV(array_length_g*vector_length_g - 1 downto 0) for the port, and
then in the architecture declare the array of vectors from the
generics, and declare functions to convert back and forth between the
flat vector and the array of vectors.

Not as clean as he wants, but until 200x is implemented, I don't know
of other choices that meet his needs.

Andy


Andy
  Reply With Quote
Old 12-17-2007, 04:33 PM   #4
KJ
 
Posts: n/a
Default Re: Fully definable ports of array of std_logic_vectors?

"Andy" <> wrote in message
news:b53be4d6-3899-4606-a9cb-...
> On Dec 12, 2:32 pm, KJ <Kevin.Jenni...@unisys.com> wrote:
>> On Dec 12, 12:57 pm, paragon.j...@gmail.com wrote:
>>
>>
>> You have to use a two dimensional array. First define a new type that
>> is a two dimensional array of std_ulogic (or std_logic if you'd
>> prefer).
>>
>> type sulv2d is array(natural range<>, natural range<>) of std_ulogic;
>>
>> Now you use that type on your entity
>> input : in sulv2d(0 to array_length_g-1,vector_length_g-1 downto
>> 0);
>>
>> It works and is synthesizable.
>>
>> KJ

>
> I think what the OP is concerned about is that the length of the
> elements in the array must also be defined in the package (per 2002
> and earlier std), which then limits instances to always using that
> same element length.
>

Yes, and both the two dimensional array solution that I proposed and the one
dimensional one that you propose both accomplish that.

> For a completely flexible interface, I would simply use an
> SLV(array_length_g*vector_length_g - 1 downto 0) for the port, and
> then in the architecture declare the array of vectors from the
> generics, and declare functions to convert back and forth between the
> flat vector and the array of vectors.
>

The one-d approach has an advantage if the synthesis tool does not support
two-d. Other than that they are essentially equivalent. Both will require
copy/paste conversion functions so that one can work with things like
address(2) and mean the entire address bus.

The two-d approach has a readability advantage, you don't have to multiply
in your head to figure out that address(213) is bit 13 of the 21st entry
(zero based) of an array of 10 bit addresses. Using two-d that same bit
would be address(21)(13).

KJ




KJ
  Reply With Quote
Old 12-17-2007, 07:16 PM   #5
Andy
 
Posts: n/a
Default Re: Fully definable ports of array of std_logic_vectors?
On Dec 17, 10:33 am, "KJ" <kkjenni...@sbcglobal.net> wrote:
> "Andy" <jonesa...@comcast.net> wrote in message
>
> news:b53be4d6-3899-4606-a9cb-...
>
> > On Dec 12, 2:32 pm, KJ <Kevin.Jenni...@unisys.com> wrote:
> >> On Dec 12, 12:57 pm, paragon.j...@gmail.com wrote:

>
> >> You have to use a two dimensional array. First define a new type that
> >> is a two dimensional array of std_ulogic (or std_logic if you'd
> >> prefer).

>
> >> type sulv2d is array(natural range<>, natural range<>) of std_ulogic;

>
> >> Now you use that type on your entity
> >> input : in sulv2d(0 to array_length_g-1,vector_length_g-1 downto
> >> 0);

>
> >> It works and is synthesizable.

>
> >> KJ

>
> > I think what the OP is concerned about is that the length of the
> > elements in the array must also be defined in the package (per 2002
> > and earlier std), which then limits instances to always using that
> > same element length.

>
> Yes, and both the two dimensional array solution that I proposed and the one
> dimensional one that you propose both accomplish that.
>
> > For a completely flexible interface, I would simply use an
> > SLV(array_length_g*vector_length_g - 1 downto 0) for the port, and
> > then in the architecture declare the array of vectors from the
> > generics, and declare functions to convert back and forth between the
> > flat vector and the array of vectors.

>
> The one-d approach has an advantage if the synthesis tool does not support
> two-d. Other than that they are essentially equivalent. Both will require
> copy/paste conversion functions so that one can work with things like
> address(2) and mean the entire address bus.
>
> The two-d approach has a readability advantage, you don't have to multiply
> in your head to figure out that address(213) is bit 13 of the 21st entry
> (zero based) of an array of 10 bit addresses. Using two-d that same bit
> would be address(21)(13).
>
> KJ


Thanks, I did not realize that multi-dimensioned array typedefs
allowed all index ranges to be unconstrained (as opposed to arrays of
arrays, where the inner array index must be constrained in the outer
array typedef for vhdl 2002 and earlier).

Learn something new every day....

Andy


Andy
  Reply With Quote
Old 12-20-2007, 07:09 PM   #6
Amal
 
Posts: n/a
Default Re: Fully definable ports of array of std_logic_vectors?
On Dec 17, 2:16 pm, Andy <jonesa...@comcast.net> wrote:
> On Dec 17, 10:33 am, "KJ" <kkjenni...@sbcglobal.net> wrote:
>
>
>
> > "Andy" <jonesa...@comcast.net> wrote in message

>
> >news:b53be4d6-3899-4606-a9cb-...

>
> > > On Dec 12, 2:32 pm, KJ <Kevin.Jenni...@unisys.com> wrote:
> > >> On Dec 12, 12:57 pm, paragon.j...@gmail.com wrote:

>
> > >> You have to use a two dimensional array. First define a new type that
> > >> is a two dimensional array of std_ulogic (or std_logic if you'd
> > >> prefer).

>
> > >> type sulv2d is array(natural range<>, natural range<>) of std_ulogic;

>
> > >> Now you use that type on your entity
> > >> input : in sulv2d(0 to array_length_g-1,vector_length_g-1 downto
> > >> 0);

>
> > >> It works and is synthesizable.

>
> > >> KJ

>
> > > I think what the OP is concerned about is that the length of the
> > > elements in the array must also be defined in the package (per 2002
> > > and earlier std), which then limits instances to always using that
> > > same element length.

>
> > Yes, and both the two dimensional array solution that I proposed and the one
> > dimensional one that you propose both accomplish that.

>
> > > For a completely flexible interface, I would simply use an
> > > SLV(array_length_g*vector_length_g - 1 downto 0) for the port, and
> > > then in the architecture declare the array of vectors from the
> > > generics, and declare functions to convert back and forth between the
> > > flat vector and the array of vectors.

>
> > The one-d approach has an advantage if the synthesis tool does not support
> > two-d. Other than that they are essentially equivalent. Both will require
> > copy/paste conversion functions so that one can work with things like
> > address(2) and mean the entire address bus.

>
> > The two-d approach has a readability advantage, you don't have to multiply
> > in your head to figure out that address(213) is bit 13 of the 21st entry
> > (zero based) of an array of 10 bit addresses. Using two-d that same bit
> > would be address(21)(13).

>
> > KJ

>
> Thanks, I did not realize that multi-dimensioned array typedefs
> allowed all index ranges to be unconstrained (as opposed to arrays of
> arrays, where the inner array index must be constrained in the outer
> array typedef for vhdl 2002 and earlier).
>
> Learn something new every day....
>
> Andy


You can use multiD package that was posted here a while ago.

http://groups.google.com/group/comp....de62767a3a0487

Based on this idea I have been writing a new package that is very
similar to the Fortran array concept. The package is almost ready and
I will post it here as soon as I do some cleanup. You can get single
bits, a range (vector), or a section of an array by using scalar
index, a range using what I call tuple (lo, hi), or a range using what
I call a triplet (lo, hi, stride) or arbitrary indexes from the array
using a vector index.

Unfortunately this is done for std_logic(_vector) and by the time
VHDL-200x package generics come, you can have constraint array of
arrays too. So there will be no point in having this package by then.

For most applications this is overkill, but if you want to develop
fully generic components, you might need this. Lets say, for a
generic FIR filter with N taps, you need N coefficients each W bits
wide.

-- Amal


Amal
  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
constants as of array of integers, for loops octavsly Hardware 0 04-25-2009 11:53 AM
Array Programme rits Software 2 03-04-2009 05:18 PM
Re: USB issue ... some USB 2 ports working only in USB 1 mode hungsolo2005@yahoo.com A+ Certification 0 06-14-2006 08:26 PM
DVD Verdict reviews: HERBIE: FULLY LOADED, THE DUKES OF HAZZARD: UNRATED EDITION, and more! DVD Verdict DVD Video 0 12-05-2005 09:13 AM
alot of open ports leno bob A+ Certification 8 03-27-2005 11:44 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