Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > How to make custom types visible in other .vhd modules

Reply
Thread Tools

How to make custom types visible in other .vhd modules

 
 
Lango
Guest
Posts: n/a
 
      10-14-2009
Hello. I'd like to declare a custom type in only one place (such as
MyTypes.vhd), and then to be able to use it in any module I want
(other .vhd's). How to do this? Thanks for your help.
 
Reply With Quote
 
 
 
 
Lango
Guest
Posts: n/a
 
      10-14-2009
On Oct 13, 6:24*pm, Lango <(E-Mail Removed)> wrote:
> Hello. *I'd like to declare a custom type in only one place (such as
> MyTypes.vhd), and then to be able to use it in any module I want
> (other .vhd's). *How to do this? *Thanks for your help.


Got it, save a MyTypes.vhd with a package, as follows:

library IEEE;
use IEEE.STD_LOGIC_1164.all;

package MyTypes is
type type_name is (<whatever the type values are>);
end MyTypes;

package body MyTypes is
end MyTypes;

And then, inside any .vhd that you wish that package to be visible,
write:

use MyTypes.ALL;



 
Reply With Quote
 
 
 
 
Mike Treseler
Guest
Posts: n/a
 
      10-14-2009
Lango wrote:

> Got it, save a MyTypes.vhd with a package, as follows:


That's it.
More proof that posting a question stimulates the brain

The package body is required for functions and procedures.
See the package body base_proc here, for example:
http://mysite.verizon.net/miketresel...c_overload.vhd
 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      10-14-2009
On Oct 13, 11:05*pm, Lango <(E-Mail Removed)> wrote:
> And then, inside any .vhd that you wish that package to be visible,
> write:
>
> use MyTypes.ALL;


Scoping rules for use statements are not based on files. The
visibility of a use statement is limited to the next declared unit
immediately following it within the file. However, other units may
inherit that visibility. An example:

use mytypes.all;

entity bar is
-- mytypes is visible here directly
end entity bar;

architecture foo of bar is
-- mytypes is visible here only because of
-- inheritence from the entity bar.
-- It would still be visible even if this arch
-- was in a separate file.
end architecture foo;
 
Reply With Quote
 
Lango
Guest
Posts: n/a
 
      10-15-2009
On Oct 14, 6:29*am, Andy <(E-Mail Removed)> wrote:
> On Oct 13, 11:05*pm, Lango <(E-Mail Removed)> wrote:
>
> > And then, inside any .vhd that you wish that package to be visible,
> > write:

>
> > use MyTypes.ALL;

>
> Scoping rules for use statements are not based on files. The
> visibility of a use statement is limited to the next declared unit
> immediately following it within the file. However, other units may
> inherit that visibility. An example:
>


Thanks for the tip. I had experienced that I had to repeat the 'use'
when I declared a second entity in the same .vhd file. It felt weird
since it is the first language I see that does something like this and
I ended up putting the 2nd entity in a new file, but at least now I
know that this is how it is supposed to work.
 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Hide textbox / Make textbox not visible (NOT USING visible property) Jurjen de Groot ASP .Net Web Controls 0 05-19-2008 09:50 AM
How to make a hyperlink Visible or not visible in DataList Patrick Olurotimi Ige ASP .Net 7 06-15-2005 12:01 PM
Panel.Visible = True also make child controls visible. spamfurnace ASP .Net 1 05-24-2004 03:07 AM



Advertisments