lib & package

T

trescot@gmail.com

Guest
I am new to VHDL and I am really having a hard time with library and
packages. Well to include packages in verilog we just used `include
directive, but in VHDL, I guess we have to make a library and refer
thouse files w.r to those lib.

I have 3 packages that I am using in my design.
For simplification lets call it a_pkg.vhd , b_pkg.vhd, c_pkg.vhd.
Now my question is if all these packages is in the same folder as other
rtl, how should I include them in my other files? What is the use of
lib?


Thanks
Trescot
 
trescot@gmail.com schrieb:


For simplification lets call it a_pkg.vhd , b_pkg.vhd, c_pkg.vhd.
Now my question is if all these packages is in the same folder as other
rtl, how should I include them in my other files? What is the use of
lib?
Compile them to a library. you can use the same library you use for your
actual design (this library is WORK).

In any component you want to use the packages, write

library work;
use work.a_pkg.ALL;
use work.b_pkg.ALL;
use work.b_pkg.ALL;

As you can see, if you compile the packages into a different library,
just give its name in the use clause.

Ralf
 
The vhdl language standard defines an implicit context which is assumed
for every design unit, and is the equivalent of the following
statements:

library STD, WORK ; use STD.STANDARD.all ;

Therefore you never have to say "library work;"

If a package or anything else is compiled into the same library you are
compiling the current module (i.e. it is the "current" or "working"
library), you simply need to prefix that package/whatever reference
with "work." (i.e. use work.package.all;)

Also, a secondary unit (package body or architecture) inherits the
context of its primary unit (the package or the entity). So you never
have to repeat the same library and use statements from the
package/entity to the package body or architecture, even if they are in
different files.

Finally, the context clause applies to the design unit in which it is
contained, not the remaning portion of the file. Therefore, if you
define more than one primary unit (package or entity) in the same file,
they all must have their own, complete context explicitly stated
(except for the aforementioned LRM defined implicit context).

I strongly recommend that anything referenced from the same library as
what is being compiled, use the work prefix, rather than the literal
name of the library that you are using. That way, your entire body of
work is portable to any library name, and as long as all of it is
compiled into the same library, without changes to the source code.

Andy


Ralf Hildebrandt wrote:
trescot@gmail.com schrieb:


For simplification lets call it a_pkg.vhd , b_pkg.vhd, c_pkg.vhd.
Now my question is if all these packages is in the same folder as other
rtl, how should I include them in my other files? What is the use of
lib?

Compile them to a library. you can use the same library you use for your
actual design (this library is WORK).

In any component you want to use the packages, write

library work;
use work.a_pkg.ALL;
use work.b_pkg.ALL;
use work.b_pkg.ALL;

As you can see, if you compile the packages into a different library,
just give its name in the use clause.

Ralf
 

Welcome to EDABoard.com

Sponsor

Back
Top