---------------------------------------------------------------------------- -- func_pkg.vhd -- Function Package -- Version 1.0 -- -- Copyright (C) 2017 H.Poetzl -- -- This program is free software: you can redistribute it and/or -- modify it under the terms of the GNU General Public License -- as published by the Free Software Foundation, either version -- 2 of the License, or (at your option) any later version. -- ---------------------------------------------------------------------------- library IEEE; use IEEE.std_logic_1164.ALL; package func_pkg is function f_div_ceil (constant dividend, divisor : in integer) return integer; end package; package body func_pkg is function f_div_ceil (constant dividend, divisor : in integer) return integer is variable i : integer; variable diff_tmp : integer; begin i := 1; diff_tmp := dividend - divisor; for j in 0 to (2**31) loop if (diff_tmp > 0) then diff_tmp := diff_tmp - divisor; i := i + 1; else exit; end if; end loop; return i; end function; end package body;