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;