--An example for a module using package.. library IEEE; use IEEE.STD_LOGIC_1164.ALL; --use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; use IEEE.numeric_std.all; --note this line.The package is compiled to this directory by default. --so don't forget to include this directory. library work; --this line also is must.This includes the particular package into your program. use work.test_pkg.all; entity tutora is port (clk : in std_logic; o : out unsigned(7 downto 0); a, b : in unsigned(7 downto 0)); end tutora; architecture Behavioral of tutora is signal c : unsigned(7 downto 0) :=(others => '0'); begin process(clk) begin if(clk'event and clk='1') then c<=divide( a , b ); o<=c; end if; end process; end Behavioral; --Package declaration for the above program library IEEE; use IEEE.std_logic_1164.all; --use IEEE.std_logic_arith.all; use IEEE.numeric_std.all; package test_pkg is --function declaration. function divide(a : UNSIGNED; b: UNSIGNED) return UNSIGNED; end test_pkg; --end of package. package body test_pkg is --start of package body --definition of function function divide(a : UNSIGNED; b: UNSIGNED) return UNSIGNED is variable a1 : unsigned(a'length-1 downto 0):=a; variable b1 : unsigned(b'length-1 downto 0):=b; variable p1 : unsigned(b'length downto 0):=(others => '0'); variable i : integer:=0; begin -- Just name the fields in order... for i in 0 to b'length-1 loop p1(b'length-1 downto 1) := p1(b'length-2 downto 0); p1(0) := a1(a'length-1); a1(a'length-1 downto 1) := a1(a'length-2 downto 0); p1 := p1-b1; if(p1(b'length-1) ='1')then a1(0) := '0'; p1 := p1+b1; else a1(0) := '1'; end if; end loop; return a1; end divide; --end function end test_pkg; --end of the package body