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

Reply

VHDL - generic question

 
Thread Tools Search this Thread
Old 08-06-2004, 03:51 AM   #1
Default generic question


I've created a library of components to use in my designs.
Most of these components use "generic" widths.

For example, a 2-to-1 mux takes two std_logic_vector(width-1 downto 0)
inputs, and outputs one of them.
My question is as follows:

Is there a more generic way to describe this so that the inputs can be
std_logic?
XST doesn't seem to like std_logic_vector(0 downto 0).

Or, do I have to do what I have been doing, and define one component for
std_logic, and one for std_logic_vector?

Thanks,

Adam




The Weiss Family
  Reply With Quote
Old 08-06-2004, 04:19 AM   #2
Allan Herriman
 
Posts: n/a
Default Re: generic question
On Thu, 5 Aug 2004 19:51:51 -0700, "The Weiss Family"
<> wrote:

>I've created a library of components to use in my designs.
>Most of these components use "generic" widths.
>
>For example, a 2-to-1 mux takes two std_logic_vector(width-1 downto 0)
>inputs, and outputs one of them.
>My question is as follows:
>
>Is there a more generic way to describe this so that the inputs can be
>std_logic?
>XST doesn't seem to like std_logic_vector(0 downto 0).


XST handles this just fine.

svl <= sl;
or
svl(0 downto 0) <= sl;

won't work, as you are trying to assign signals of different type.
This is illegal VHDL, and won't work in any proper VHDL tool, not just
XST. Your simulator, for example, wouldn't compile this either.
BTW, any reasonable design flow involves simulation before synthesis.

OTOH,
svl(0) <= sl,

will work fine, as the *elements* of the std_logic_vector have the
right type.

>Or, do I have to do what I have been doing, and define one component for
>std_logic, and one for std_logic_vector?


No, one copy, using std_logic_vector, is all you need.

Regards,
Allan.


Allan Herriman
  Reply With Quote
Old 08-06-2004, 04:51 AM   #3
Jim Lewis
 
Posts: n/a
Default Re: generic question
> I've created a library of components to use in my designs.
> Most of these components use "generic" widths.
>
> For example, a 2-to-1 mux takes two std_logic_vector(width-1 downto 0)
> inputs, and outputs one of them.


An alternate solution would be to use a subprogram.
Subprograms are overloadable. You can also use an
unconstrained array.

A function works well for this as then you could write:

Y <= Mux2(Sel1, A, B) and Mux2(Sel2, C, D) ;


Cheers,
Jim
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Jim Lewis
Director of Training private.php?do=newpm&u=
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~


Jim Lewis
  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
Re: Dial-up Modem Question w_tom A+ Certification 0 09-18-2005 09:12 PM
"Installing two drives" question - what next? Jim A+ Certification 12 08-07-2005 01:19 PM
Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good God DVD Video 3 04-25-2005 04:19 PM
Re: Good morning or good evening depending upon your location. I want to ask you the most important question of your life. Your joy or sorrow for all eternity depends upon your answer. The question is: Are you saved? It is not a question of how good Filthy Mcnasty DVD Video 0 04-25-2005 04:29 AM
Re: Safe Mode Question (A+ question) Gordon Findlay A+ Certification 0 06-16-2004 10:48 AM




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