aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgingold <gingold@b72b5c32-5f01-0410-b925-b5c7b92870f7>2006-04-04 21:48:40 +0000
committergingold <gingold@b72b5c32-5f01-0410-b925-b5c7b92870f7>2006-04-04 21:48:40 +0000
commitb00440301d5950003f0fc53d45935d52f075bd8f (patch)
tree2ca624e24284d272ba64d48c88bb51c2181edc64
parent024122adc0a5dba2fce2110dceb9ad4378031839 (diff)
downloadghdl-b00440301d5950003f0fc53d45935d52f075bd8f.tar.gz
ghdl-b00440301d5950003f0fc53d45935d52f075bd8f.tar.bz2
ghdl-b00440301d5950003f0fc53d45935d52f075bd8f.zip
math lib updated
-rw-r--r--libraries/ieee/math_real-body.vhdl34
-rw-r--r--libraries/ieee/math_real.vhdl36
2 files changed, 58 insertions, 12 deletions
diff --git a/libraries/ieee/math_real-body.vhdl b/libraries/ieee/math_real-body.vhdl
index 1473f6787..41e6a084d 100644
--- a/libraries/ieee/math_real-body.vhdl
+++ b/libraries/ieee/math_real-body.vhdl
@@ -43,6 +43,8 @@
--
-- GHDL history
-- 2005-04-07 Initial version.
+-- 2005-12-23 I. Curtis : overhaul of log functions to bring in line
+-- with ieee standard
-------------------------------------------------------------
Library IEEE;
@@ -246,19 +248,31 @@ Package body MATH_REAL is
return c_log(x);
end LOG;
- function LOG (BASE: positive; X : real) return real is
- -- returns logarithm base BASE of X; X > 0
+ function LOG (X : in real; BASE: in real) return real is
+ -- returns logarithm base BASE of X; X > 0
begin
- -- check validity of argument
- if ( BASE <= 0 ) or ( x <= 0.0 ) then
- assert false report "BASE <= 0 or X <= 0.0 in LOG(BASE, X)"
- severity ERROR;
- return(REAL'LOW);
- end if;
- -- compute the value
- return (LOG(X)/LOG(REAL(BASE)));
+ -- check validity of argument
+ if ( BASE <= 0.0 ) or ( x <= 0.0 ) then
+ assert false report "BASE <= 0.0 or X <= 0.0 in LOG(BASE, X)"
+ severity ERROR;
+ return(REAL'LOW);
+ end if;
+ -- compute the value
+ return (LOG(X)/LOG(BASE));
end LOG;
+ function LOG2 (X : in real) return real is
+ -- returns logarithm BASE 2 of X; X > 0
+ begin
+ return LOG(X) / MATH_LOG_OF_2;
+ end LOG2;
+
+ function LOG10 (X : in real) return real is
+ -- returns logarithm BASE 10 of X; X > 0
+ begin
+ return LOG(X) / MATH_LOG_OF_10;
+ end LOG10;
+
function SIN (X : real ) return real is
begin
assert false severity failure;
diff --git a/libraries/ieee/math_real.vhdl b/libraries/ieee/math_real.vhdl
index c70d2160b..b2c818a4b 100644
--- a/libraries/ieee/math_real.vhdl
+++ b/libraries/ieee/math_real.vhdl
@@ -43,11 +43,17 @@
-- GHDL history
-- 2005-04-07 Initial version.
-- 2005-09-01 Some PI constants added.
+-- 2005-12-20 I. Curtis : significant overhaul to bring closer in line
+-- with ieee standard
+
-------------------------------------------------------------
Library IEEE;
Package MATH_REAL is
-
+ -- IAC: should have a string with copyright notice
+ -- constant CopyRightNotice: STRING
+ -- := "GPL";
+
--
-- commonly used constants
--
@@ -95,6 +101,10 @@ Package MATH_REAL is
attribute foreign of round : function is "VHPIDIRECT round";
-- returns integer FLOOR(X + 0.5) if X > 0;
-- return integer CEIL(X - 0.5) if X < 0
+
+ -- IAC: we are missing the function TRUNC
+ -- IAC: we are missing the function MOD
+ -- IAC: functions FMAX and FMIN should be renamed REALMAX and REALMIN
function FMAX (X, Y : real ) return real;
attribute foreign of fmax : function is "VHPIDIRECT fmax";
@@ -118,6 +128,8 @@ Package MATH_REAL is
-- initialize their values (INIT_SEED) will be provided, and the UNIFORM
-- procedure call will be modified accordingly.
+ -- IAC: functions SRAND, RAND and GET_RAND_MAX should not be visible
+
function SRAND (seed: in integer ) return integer;
attribute foreign of srand : function is "VHPIDIRECT srand";
--
@@ -169,9 +181,15 @@ Package MATH_REAL is
function LOG (X : real ) return real;
-- returns natural logarithm of X; X > 0
- function LOG (BASE: positive; X : real) return real;
+ function LOG (X: in real; BASE: in real) return real;
-- returns logarithm base BASE of X; X > 0
+ function LOG2 (X : in real ) return real;
+ -- returns logarithm base 2 of X; X > 0
+
+ function LOG10 (X : in real ) return real;
+ -- returns logarithm base 10 of X; X > 0
+
function SIN (X : real ) return real;
attribute foreign of sin : function is "VHPIDIRECT sin";
-- returns sin X; X in radians
@@ -185,16 +203,24 @@ Package MATH_REAL is
-- returns tan X; X in radians
-- X /= ((2k+1) * PI/2), where k is an integer
+ -- IAC: function should be called ARCSIN
+
function ASIN (X : real ) return real;
-- returns -PI/2 < asin X < PI/2; | X | <= 1
+ -- IAC: function should be called ARCCOS
+
function ACOS (X : real ) return real;
-- returns 0 < acos X < PI; | X | <= 1
+
+ -- IAC: function should be called ARCTAN
+
function ATAN (X : real) return real;
attribute foreign of atan : function is "VHPIDIRECT atan";
-- returns -PI/2 < atan X < PI/2
+ -- IAC: function ATAN2 should not exist
function ATAN2 (X : real; Y : real) return real;
-- returns atan (X/Y); -PI < atan2(X,Y) < PI; Y /= 0.0
@@ -209,14 +235,20 @@ Package MATH_REAL is
function TANH (X : real) return real;
attribute foreign of tanh : function is "VHPIDIRECT tanh";
-- hyperbolic tangent; -- returns (e**X - e**(-X))/(e**X + e**(-X))
+
+ -- IAC: function should be called ARCSINH
function ASINH (X : real) return real;
attribute foreign of asinh : function is "VHPIDIRECT asinh";
-- returns ln( X + sqrt( X**2 + 1))
+ -- IAC: function should be called ARCCOSH
+
function ACOSH (X : real) return real;
-- returns ln( X + sqrt( X**2 - 1)); X >= 1
+ -- IAC: function should be called ARCTANH
+
function ATANH (X : real) return real;
-- returns (ln( (1 + X)/(1 - X)))/2 ; | X | < 1