Programmable Devices
CPLDs, FPGAs, SoC FPGAs, Configuration, and Transceivers
Announcements
Need Forum Guidance? Click here

Search our FPGA Knowledge Articles here.
18484 Discussions

Tutorial for creating user Library?

Altera_Forum
Honored Contributor I
3,285 Views

It's my understanding that there is a "work" library in Quartus II that the user can add their own "packages" or components to and use this in VHDL files.  

 

I've read a little bit about this in some books, but nothing that gives a good working tutorial for it. Can anyone point me to a short and clear tutorial on how to create a component, entity, or package and install it in the "work" library so I can build up my own work library for future projects? The actual component or package that is being used for the tutorial can be quite simple. In fact, the simpler the better. Once I understand how to create packages and install them in the work library I can take it from there.  

 

Thanks
0 Kudos
3 Replies
Altera_Forum
Honored Contributor I
913 Views

Hello Robo_Pi, 

 

To start with, you can make your package .vhd file and put it together with the .vhd design using the package in the same project directory. 

 

Then, you need to include the package file in your project: 

 

Under Assignments / Settings / File, add both files to be included in the project (the packge first). 

 

To instantiate an entity defined in the package "bench_help": 

You can use someting like: work.bench_help.reset_generator(5000,5,CLOCK_50,RESET_P,RESET_N); 

 

where the package bench_help is: 

 

library ieee; 

use ieee.std_logic_1164.all; 

use ieee.numeric_std.all; 

 

library Std; 

Use Std.textio.all; 

 

package bench_help is 

procedure reset_generator(wt : in integer;len : in integer;signal clk : in std_logic; signal reset_p : out std_logic; signal reset_n : out std_logic); 

end bench_help; 

 

package body bench_help is 

 

procedure reset_generator(wt : in integer;  

len : in integer; 

signal clk : in std_logic;  

signal reset_p : out std_logic;  

signal reset_n : out std_logic) is 

variable i : integer; 

begin 

reset_p<='0'; 

reset_n<='1'; 

end procedure; 

 

end package body bench_help;  

 

Best Regards, 

Johi.
Altera_Forum
Honored Contributor I
913 Views

 

--- Quote Start ---  

It's my understanding that there is a "work" library in Quartus II that the user can add their own "packages" or components to and use this in VHDL files.  

 

--- Quote End ---  

 

In VHDL, there is no such thing as a "work" library. work is just kind of an identifier that refers to the current library. Do not mix up packages and libraries, btw.. Any library can contain a number of packages, just as it can contain entities and components. A package, OTOH, can contain components and entities as well. 

 

So, to achieve what you asked for, you literally don't need to do anything, since - by definition - everything you specify (entities, components, packages, ...) goes into the work library anyway. 

 

 

--- Quote Start ---  

 

I've read a little bit about this in some books, but nothing that gives a good working tutorial for it. Can anyone point me to a short and clear tutorial on how to create a component, entity, or package and install it in the "work" library so I can build up my own work library for future projects? The actual component or package that is being used for the tutorial can be quite simple. In fact, the simpler the better. Once I understand how to create packages and install them in the work library I can take it from there.  

 

Thanks 

--- Quote End ---  

 

 

If you want to put your design into several different libraries in a single project in Quartus, you have to explicitly assign your source files to a library. You can do that on the "File Properties" Dialog you get on right click of the file in the Project Navigator (this just adds a "-library" statement to the corresponding file assignment in Quartus' .qsf file). From then on from any file that isn't assigned to that library, entity and component declarations within that file can only be referred to with the library name you assigned above instead of work (as it would be the case otherwise). 

 

Bottom line is that this might not be what you want since the VHDL library concept basically just adds a bit of syntactic sugar to your projects. Quartus *still* wants to see all of your source files - regardless to which library they belong - at synthesis time. There is no way to use 'precompiled' libraries as you might have expected.
Altera_Forum
Honored Contributor I
913 Views

Ok, I'm new to Quartus II and VHDL. I was reading a book on VHDL and it has a chapter on "Design Partitioning" where it talks about creating packages and then using them via the work library. But this book isn't specific to any particular software and it doesn't go into detail of how to actually create the packages and install them into the library.  

 

As mfro suggests, I may not need to use this method anyway. I just like to work with modular designs so this "Design Partitioning" idea caught my attention. But I guess I can just include any previous entities that I've designed by simply adding the *.VHD files for those previous entities. My previous projects will become my 'library' I guess.  

 

As I say, I'm just starting out with this so I don't really have enough experience to know what I'm doing yet.
Reply