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

Reply

VHDL - variable sized port map

 
Thread Tools Search this Thread
Old 03-18-2006, 01:37 AM   #1
Default variable sized port map


Is there a way to have a variable sized port map in VHDL? I am not
talking about using a generic statement to make a variable sized bus,
but I want to have a varying number of inputs as specified by a generic
statement. Is there a way to specifiy an array of standard logic
vectors in the port map, maybe??

Thanks in advance.
S



sanborne
  Reply With Quote
Old 03-18-2006, 06:39 PM   #2
KJ
 
Posts: n/a
Default Re: variable sized port map
Is this something that you're looking for?

type t_MY_TYPE is std_logic_vector(15 downto 0);
type arr_t_MY_TYPE is array (natural range <>) of t_MY_TYPE;

entity My_Entity is generic(N: natural)
port(Gazintas: in arr_t_MY_TYPE(1 to N);
Gzzoutas: out arr_t_MY_TYPE(1 to N));
end My_Entity;

Here 'Gazinta' and 'Gazouta' are both arrays of 16 bit std_logic_vectors;
You can make an array of anything by first defining a new type and then an
array of that type. The 'base' type t_MY_TYPE could have been an enumerated
list or a record type and the rest of the code would be unchanged. For
example,

type t_MY_TYPE is record
One_Potato: natural range 1 to 50;
Two_Potato: std_logic_vector(7 downto 0);
end record;

KJ

"sanborne" <> wrote in message
news: oups.com...
> Is there a way to have a variable sized port map in VHDL? I am not
> talking about using a generic statement to make a variable sized bus,
> but I want to have a varying number of inputs as specified by a generic
> statement. Is there a way to specifiy an array of standard logic
> vectors in the port map, maybe??
>
> Thanks in advance.
> S
>





KJ
  Reply With Quote
Old 03-20-2006, 06:54 PM   #3
sanborne
 
Posts: n/a
Default Re: variable sized port map
Thankyou very much. That is what I was looking for, and I think it
answers my question.

I am pretty new to VHDL. Is there a good VHDL reference that you would
suggest that has stuff like this? I have questions about the code that
you posted that I think would be best answered on my own if I had a
good book. I have searched the internet quite a bit, and have not found
much more than really basic reference materials. (If you have any good
websites to suggest, I would like that too.)

But for example, why would you use the <> operator in "arr_t_MY_TYPE"
instead of an actual explicit range? And what is a "record" data type
and how is it useful? I should note that I am primarily interested in
synthesizable VHDL. So if you give examples that are only really useful
in testbenches or some other non-synthesizable application, please say
so.

And thanks a lot for your response.



sanborne
  Reply With Quote
Old 03-20-2006, 07:36 PM   #4
Mike Treseler
 
Posts: n/a
Default Re: variable sized port map
sanborne wrote:

> Is there a good VHDL reference that you would
> suggest that has stuff like this?


Designer's Guide to VHDL by Ashenden

> I have questions about the code that
> you posted that I think would be best answered on my own if I had a
> good book.


Good examples like KJ's provide focus
and motivation to open a book.
This is a good way to learn.

> I have searched the internet quite a bit, and have not found
> much more than really basic reference materials. (If you have any good
> websites to suggest, I would like that too.)


I like the examples here:
http://home.comcast.net/~mike_treseler/

> But for example, why would you use the <> operator in "arr_t_MY_TYPE"
> instead of an actual explicit range?


That is an unconstrained range that can
be used on a type *declaration*.
You have to "fill in the box" with
an actual range when you *use* this type.

-- Mike Treseler


Mike Treseler
  Reply With Quote
Old 03-20-2006, 10:10 PM   #5
Andy
 
Posts: n/a
Default Re: variable sized port map
You really don't have to specify the range until you specify storage
for the data (i.e. declare a signal or variable to hold it). The ports
can be left unconstrained, and will take their widths from the
signal/port they are connected to when they are instantiated. Different
instantiations of the same entity could use different widths. Note
that only the top level array can be left unconstrained in a typedef.
You can have unconstrained arrays of constrained arrays, but not arrays
of unconstrained arrays.

entity My_Entity is
port(Gazintas: in arr_t_MY_TYPE;
Gzzoutas: out arr_t_MY_TYPE);
end My_Entity;

Use Gazintas'range or Gazintas'length in the ensuing architecture to
get the range/length of the port data.

For obvious reasons, you cannot have an unconstrained port on the top
level entity.

Andy



Andy
  Reply With Quote
Old 03-20-2006, 11:43 PM   #6
sanborne
 
Posts: n/a
Default Re: variable sized port map
Is there any reason to do this instead of a generic width input for the
array?

S



sanborne
  Reply With Quote
Old 03-26-2006, 11:05 PM   #7
Mike Treseler
 
Posts: n/a
Default Re: variable sized port map
sanborne wrote:
> Is there any reason to do this instead of a generic width input for the
> array?


The self-aligning ports might be nice
for a design with many sub-entities using
a common local bus.

A generic width allows a default value:

entity uart is
generic (char_len_c : natural := 8;
tic_per_bit_c : natural := 4);

that can be handy when running a quick
test sim or synthesis of the sub-entity alone.


It doesn't really make much difference.


-- Mike Treseler


Mike Treseler
  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
Can not access console port of Cisco 7200 vxr mansurbd Hardware 1 01-12-2009 06:53 PM
How to check current event and port status for Aliwei FXO gateway Robin wang Hardware 0 04-11-2008 09:54 AM
Port 445: Effective/Safe Blocking Samwise General Help Related Topics 0 01-06-2008 09:19 PM
Long, regarding a "lost" COM port smackedass A+ Certification 4 02-05-2007 04:55 PM
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