- added real veriants of NextPower...

git-svn-id: http://moon:8086/svn/vhdl/trunk@180 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
2009-01-02 15:28:01 +00:00
parent 377b8c0993
commit e8ddaf8d98
+15 -2
View File
@@ -1,5 +1,5 @@
-----------------------------------------------------------------------
-- $Header: /tmp/cvsroot/VHDL/lib/misc/utils_pkg.vhd,v 1.1 2008-08-23 08:20:29 Jens Exp $
-- $Header: /tmp/cvsroot/VHDL/lib/misc/utils_pkg.vhd,v 1.2 2009-01-02 15:28:01 Jens Exp $
-----------------------------------------------------------------------
library IEEE;
@@ -12,6 +12,8 @@ package utils_pkg is
-- Constants
-- Functions
function NextPowerOfTwo(x : real) return real;
function NextExpBaseTwo(x : real) return real;
function NextPowerOfTwo(x : natural) return natural;
function NextExpBaseTwo(x : natural) return natural;
function GCD(a, b : natural) return natural;
@@ -22,9 +24,20 @@ end utils_pkg;
package body utils_pkg is
function NextExpBaseTwo(x : real) return real is
begin
return ceil(log2(x));
end NextExpBaseTwo;
function NextPowerOfTwo(x : real) return real is
begin
return 2.0**NextExpBaseTwo(x);
end NextPowerOfTwo;
function NextExpBaseTwo(x : natural) return natural is
begin
return natural(ceil(log2(real(x))));
return natural(NextExpBaseTwo(real(x)));
end NextExpBaseTwo;
function NextPowerOfTwo(x : natural) return natural is