Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

VHDL "library" and "use.all" clause

Status
Not open for further replies.

shaiko

Advanced Member level 5
Joined
Aug 20, 2011
Messages
2,644
Helped
303
Reputation
608
Reaction score
297
Trophy points
1,363
Activity points
18,302
Hello,

Consider the following code before the entity section of a .vhd file:

Code:
library x;
use x.all ;

As far as I understand the first line tells the compiler that 'x' is a library and the second line makes all the packages in this library visible for the entity to follow.
Am I correct?
 

Yes it does, plus all the entities, but it does not make their contents visible.
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Re: VHDL "library" and "use.all" clause

but it does not make their contents visible
Mind reading my next question...

If it doesn't make the contents visible, what's the motivation of simply making the package & entity names visible?
 

Because you don't need the library name when you use direct instantiation for an entity or create a new package from a generic package.

Eg

Code:
Inst : entity some_entity
Port map (

That's about the only use I know.
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
And how would the same instantiation look if I wouldn't use
library x;
use x.all ;
?
 

Then you would use:
Code:
Inst : entity [COLOR="#FF0000"]x.[/COLOR]some_entity
Port map (
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Consider the following real life scenario:

altera_mf is a library name.
altera_mf_components is a package inside this library.
dcfifo_mixed_widths is a component inside this package.

I tried all of the lines below - and they all compile,
Can you please explain what does each of the lines mean and how they differ between themselves?

Code:
inst : entity altera_mf.altera_mf_components.dcfifo_mixed_widths

Code:
inst : entity altera_mf_components.dcfifo_mixed_widths

Code:
inst : entity altera_mf.dcfifo_mixed_widths
 

Not really any different.
1. Full path to component.
2. Component from visible package
3. Entity from library

For 1 and 2, your just instantiating the component and mapping it during elaboration
3 is a direct entity instantiation
 
  • Like
Reactions: shaiko

    shaiko

    Points: 2
    Helpful Answer Positive Rating
Is there a way to make visible all packages of a library and all their components with a short code?

Something like:
Library some_library.all.all ;
 

see https://www.doulos.com/knowhow/vhdl_designers_guide/vhdl_2008/vhdl_200x_merged/#context

Code:
-- vhdl 2008
library ieee;
context ieee.ieee_std_context;

-- replaces
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

standard caveats about vhdl-2008 support apply. same for "work" being a special library.

Code:
-- this code would be in a file compiled into <some library>.  it doesn't need to be ieee or unisim.
-- it would be accessed with:
-- library <whatever>;
-- context <whatever>.xilinx_with_mostly_safe_math;
context xilinx_with_mostly_safe_math is
  library ieee;
  use ieee.std_logic_1164.all;
  use ieee.numeric_std.all;
  use ieee.numeric_signed."-"; -- gets both one and two arg forms
  use ieee.numeric_unsigned."+";
  use ieee.numeric_unsigned.to_integer;
  library unisim;
  use unisim.vcomponents.all;
end context;
 
Last edited:
Using
inst : entity altera_mf_components.dcfifo_mixed_widths
and
inst : component altera_mf_components.dcfifo_mixed_widths
Both compile...Is it the same??
 

Iirc, using component keyword is for a component instantiation, and is optional. Using entity will compile against an entity. If you're compiling in quartus it's a bit more relaxed about things.

Wondering why it's important. Is this just academic?
 

Wondering why it's important.
Just to know the rules...
I simply noticed that the same code that compiles with Modelsim, generates errors in VCS.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top