Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)

vhdl library help

Altera_Forum
Honored Contributor II
1,707 Views

Hi all. Im doing a final year project and I to make things easier I need to make a custom library with functions. How do I make my own library? I tried a bunch of things like adding my own vhdl file into the quartus installation directory library folders. No luck there. 

 

I have a function but I cant put it into my main entity file or its architecture. If I do and I call it I get a synthesis error saying that the <function name> object is used but not declared. I am thinking this has to do with the function not being declared (as in C).  

 

Basically I have this function defined. It compiles. But what is wrong here? Do I need to make my own library for this VHDL function or do I need to declare it at the top of the file? 

 

 

Thanks
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
831 Views

You have to put your function in a package and add the package text to the list of project files. By default, the package is compiled to the library work. You can specify a different library target in different ways, e.g. by an assignment or a synthesis directive in the source. Consult the Quartus software manual about design libraries.

0 Kudos
Altera_Forum
Honored Contributor II
831 Views

This is how you declare and use packages: 

 

package my_function_package is --put constants here --put function/procedure declarations here - note: this is not the entire function function do_stuff return something; end package my_functions_package; --the body is where you put all the function code package body my_function_package is --this is where the code actually goes function do_stuff return something is begin --do stuff end function do_stuff; end package body my_function_package; --then in the file you want to use the function --unless you have specified my_library, replace it with work library my_library; --not needed if library is work use my_library.my_function_package.all;  

You can also put functions directly into architectures or processes. You just define them before the "begin": 

 

architecture rtl of some_entity is --function goes here begin process(clk) --function goes here, you can also declare constants and variables here begin --something end process; end architecture rtl;
0 Kudos
Reply