------------------------------------------------------------------------ -- -- **************************************************************** -- * * -- * W A R N I N G * -- * * -- * This DRAFT version IS NOT endorsed or approved by IEEE * -- * * -- **************************************************************** -- -- Title: PACKAGE MATH_REAL -- -- Library: This package shall be compiled into a library -- symbolically named IEEE. -- -- Developers: IEEE VHDL Mathematical Package Group (par 1076.2) -- -- Purpose: This package defines a standard for designers to use in -- describing VHDL models that make use of common real constants, -- and common real elementary mathematical functions. -- -- Limitation: The values generated by the functions in this package may -- vary from platform to platform, and the precision of results -- is only guranteed to be the minimum required by IEEE 1076-1993. -- -- Notes: -- This source file may be used and distributed without -- restriction, as long as it is not sold or distributed for -- profit. -- -- This package cannot be sold or distributed for profit. -- -- No declarations or definitions shall be included in, or -- excluded from, this package. The "package declaration" -- defines the types, subtypes, and declarations of MATH_REAL. -- The standard mathematical definition and conventional meaning -- of the mathematical functions that are part of this standard, -- which are clarified by the MATH_REAL package body, represent -- the formal semantics of the implementation of the MATH_REAL -- package declaration. Tool developers may choose to implement -- the package body in the most efficient manner available to them. -- -- ------------------------------------------------------------------------- -- Modification history: -- ------------------------------------------------------------------------- -- Version: | Mod. date: | Modified by: -- v0.1 | 6/22/92 | Jose A. Torres -- v0.2 | 1/15/93 | Jose A. Torres -- v0.3 | 4/13/93 | Jose A. Torres -- v0.4 | 4/19/93 | Jose A. Torres -- v0.5 | 4/20/93 | Jose A. Torres -- v0.6 | 4/23/93 | Jose A. Torres -- v0.7 | 5/28/93 | Jose A. Torres -- v0.8 | 9/02/94 | Jose A. Torres -- v0.9 | 9/30/94 | Jose A. Torres -- v0.91 | 1/25/95 | Jose A. Torres -- v0.92 | 3/05/95 | Jose A. Torres -- v0.93 | 3/06/95 | Jose A. Torres -- v0.94 | 3/07/95 | Jose A. Torres -- v0.95 | 3/10/95 | Jose A. Torres -- v0.96 | 3/11/95 | Jose A. Torres -- v0.97 | 3/21/95 | Jose A. Torres -- v0.98 | 3/22/95 | Jose A. Torres -- v0.99 | 3/24/95 | Jose A. Torres ------------------------------------------------------------- Package MATH_REAL is -- -- commonly used constants -- constant MATH_E : real := 2.71828_18284_59045_23536; -- value of e constant MATH_1_OVER_E: real := 0.36787_94411_71442_32160; -- value of 1/e constant MATH_PI : real := 3.14159_26535_89793_23846; -- value of pi constant MATH_TWO_PI : real := 6.28318_53071_79586_47692; -- value of 2*pi constant MATH_1_OVER_PI : real := 0.31830_98861_83790_67154; -- value of 1/pi constant MATH_HALF_PI : real := 1.57079_63267_94896_61923; -- value of pi/2 constant MATH_Q_PI: real := 0.78539_81633_97448_30961; -- value of pi/4 constant MATH_3_HALF_PI: real := 4.71238_89803_84689_85769; -- value 3*pi/2 constant MATH_LOG_OF_2: real := 0.69314_71805_59945_30942; -- natural log of 2 constant MATH_LOG_OF_10: real := 2.30258_50929_94045_68402; -- natural log of10 constant MATH_LOG2_OF_E: real := 1.44269_50408_88963_4074; -- log base 2 of e constant MATH_LOG10_OF_E: real := 0.43429_44819_03251_82765; -- log base 10 of e constant MATH_SQRT2: real := 1.41421_35623_73095_04880; -- sqrt of 2 constant MATH_SQRT1_2: real := 0.70710_67811_86547_52440; -- sqrt of 1/2 constant MATH_SQRT_PI: real := 1.77245_38509_05516_02730; -- sqrt of pi constant MATH_DEG_TO_RAD: real := 0.01745_32925_19943_29577; -- conversion factor from degree to radian constant MATH_RAD_TO_DEG: real := 57.29577_95130_82320_87685; -- conversion factor from radian to degree -- -- function declarations -- function SIGN (X: real ) return real; -- returns 1.0 if X > 0.0; 0.0 if X = 0.0; -1.0 if X < 0.0 function CEIL (X : real ) return real; -- returns smallest integer value (as real) not less than X function FLOOR (X : real ) return real; -- returns largest integer value (as real) not greater than X function ROUND (X : real ) return real; -- returns the floating value of the integer nearest X -- returns 0.0 if X = 0.0 function TRUNC (X : real ) return real; -- truncates X towards 0.0 and returns truncated value -- returns 0.0 if X = 0.0 function "MOD" (X, Y: real ) return real; -- returns floating point modulus of X/Y, with the same sign as Y, -- an absolute value less than the absolute value of Y, and -- for some integer value N the result satisfies the relation -- X = Y*N + MOD(X,Y) -- ABS(MOD(X,Y)) < ABS(Y) -- error if Y = 0.0 function FMAX (X, Y : real ) return real; -- returns the algebraically larger of X and Y -- FMAX(X,Y) = X when X = Y function FMIN (X, Y : real ) return real; -- returns the algebraically smaller of X and Y -- FMIN(X,Y) = X when X = Y procedure UNIFORM (variable Seed1,Seed2:inout integer; variable X:out real); -- returns a pseudo-random number with uniform distribution in the -- interval (0.0, 1.0). -- Before the first call to UNIFORM, the seed values (Seed1, Seed2) must -- be initialized to values in the range [1, 2147483562] and -- [1, 2147483398] respectively. The seed values are modified after -- each call to UNIFORM. -- This random number generator is portable for 32-bit computers, and -- it has period ~2.30584*(10**18) for each set of seed values. -- error if any of the seeds is outside of valid ranges function SQRT (X : real ) return real; -- returns square root of X; X >= 0.0 -- error if X < 0 -- SQRT(X) >= 0.0 -- SQRT(0.0) = 0.0; SQRT(1.0) = 1.0 function CBRT (X : real ) return real; -- returns cube root of X -- CBRT(0.0) = 0.0; CBRT(1.0) = 1.0; CBRT(-1.0) = -1.0 function "**" (X : integer; Y : real) return real; -- returns Y power of X ==> X**Y; -- X**Y >= 0.0 -- error if X = 0 and Y <= 0.0 -- error if X < 0 -- X**0.0 = 1.0; X > 0.0 -- 0.0**Y = 0.0; Y > 0.0 -- X**1.0 = X -- 1.0**Y = 1.0 function "**" (X : real; Y : real) return real; -- returns Y power of X ==> X**Y; -- X**Y >= 0.0 -- error if X = 0 and Y <= 0.0 -- error if X < 0 -- X**0.0 = 1.0; X > 0.0 -- 0.0**Y = 0.0; Y > 0.0 -- X**1.0 = X -- 1.0**Y = 1.0 function EXP (X : real ) return real; -- returns e**X; where e = MATH_E -- EXP(X) >= 0.0 -- EXP(0.0) = 1.0 function LOG (X : real ) return real; -- returns natural logarithm of X; X > 0 -- error if X <= 0.0 -- LOG(X) is mathematically unbounded -- LOG(1.0) = 0.0 function LOG (X: real; BASE: positive) return real; -- returns logarithm base BASE of X; X > 0; BASE > 1 -- error if X <= 0.0 -- error if BASE <= 1 -- LOG(X, BASE) is mathematically unbounded -- LOG(1.0, BASE) = 0.0 function SIN (X : real ) return real; -- returns sin X; X in radians -- ABS(SIN(X)) <= 1.0 -- SIN(0.0) = 0.0 function COS ( X : real ) return real; -- returns cos X; X in radians -- ABS(COS(X)) <= 1.0 -- COS(0.0) = 1.0 function TAN (X : real ) return real; -- returns tan X; X in radians -- error if X = ((2*k+1) * PI/2), where k is an integer -- TAN(X) is mathematically unbounded -- TAN(0.0) = 0.0 function ARCSIN (X : real ) return real; -- returns asin X; | X | <= 1 -- error if ABS(X) > 1.0 -- ABS(ARCSIN(X) <= MATH_PI/2.0 -- ARCSIN(0.0) = 0.0 -- ARCSIN(1.0) = MATH_PI/2.0 -- ARCSIN(-1.0) = -MATH_PI/2.0 function ARCCOS (X : real ) return real; -- returns acos X ; | X | <= 1 -- error if ABS(X) > 1.0 -- 0.0 <= ARCCOS(X) <= MATH_PI -- ARCCOS(1.0) = 0.0 -- ARCCOS(0.0) = MATH_PI/2.0 -- ARCCOS(-1.0) = MATH_PI function ARCTAN (Y : real) return real; -- returns atan Y; which is the angle in the quadrant containing -- the point (1.0, Y) whose tangent is Y -- ABS(ARCTAN(Y)) <= MATH_PI/2.0 -- ARCTAN(0.0) = 0.0 function ARCTAN (Y : real; X : real) return real; -- returns ARCTAN(Y/X); which is the angle in the quadrant containing -- the point (X, Y) whose tangent is Y/X; X /= 0.0 -- ABS(ARCTAN(Y,1.0)) <= MATH_PI/2.0 -- 0.0 <= ARCTAN(Y,X) <= MATH_PI when Y >= 0.0 -- -MATH_PI <= ARCTAN(Y,X) <= 0.0 when Y <= 0.0 -- ARCTAN(0.0, 0.0) = 0.0 -- ARCTAN(Y, 0.0) = MATH_PI/2.0 when Y > 0.0 -- ARCTAN(Y, 0.0) = -MATH_PI/2.0 when Y < 0.0 function SINH (X : real) return real; -- hyperbolic sine; returns (EXP(X) - EXP(-X))/2 -- SINH(X) is mathematically unbounded -- SINH(0.0) = 0.0 function COSH (X : real) return real; -- hyperbolic cosine; returns (EXP(X) + EXP(-X))/2 -- COSH(X) >= 1.0 -- COSH(0.0) = 1.0 function TANH (X : real) return real; -- hyperbolic tangent; -- returns (EXP(X) - EXP(-X))/(EXP(X) + EXP(-X)) -- ABS(TANH(X)) <= 1.0 -- TANH(0.0) = 0.0 function ARCSINH (X : real) return real; -- returns LOG( X + SQRT( X*X + 1)) -- ARCSINH(X) is mathematically unbounded -- ARCSINH(0.0) = 0.0 function ARCCOSH (X : real) return real; -- returns LOG( X + SQRT( X*X - 1)); X >= 1.0 -- ARCCOSH(X) >= 0.0 -- error if X < 1.0 -- ARCCOSH(1.0) = 0.0 function ARCTANH (X : real) return real; -- returns (LOG( (1 + X)/(1 - X)))/2 ; | X | < 1 -- ARCTANH(X) is mathematically unbounded -- error if ABS(X) >= 1.0 -- ARCTANH(0.0) = 0.0 end MATH_REAL; ------------------------------------------------------------------------ -- -- **************************************************************** -- * * -- * W A R N I N G * -- * * -- * This DRAFT version IS NOT endorsed or approved by IEEE * -- * * -- **************************************************************** -- -- Title: PACKAGE MATH_COMPLEX -- -- Library: This package shall be compiled into a library -- symbolically named IEEE. -- -- Developers: IEEE VHDL Mathematical Package Group (par 1076.2) -- -- Purpose: This package defines a standard for designers to use in -- describing VHDL models that make use of common complex -- constants, and common complex mathematical functions and -- operators. -- -- Limitation: The values generated by the functions in this package may -- vary from platform to platform, and the precision of results -- is only guranteed to be the minimum required by IEEE 1076-1993. -- -- Notes: -- This source file may be used and distributed without -- restriction, as long as it is not sold or distributed for -- profit. -- -- This package cannot be sold or distributed for profit. -- -- No declarations or definitions shall be included in, or -- excluded from, this package. The "package declaration" -- defines the types, subtypes, and declarations of MATH_COMPLEX. -- The standard mathematical definition and conventional meaning -- of the mathematical functions that are part of this standard, -- which are clarified by the MATH_COMPLEX package body, represent -- the formal semantics of the implementation of the MATH_COMPLEX -- package declaration. Tool developers may choose to implement -- the package body in the most efficient manner available to them. -- -- ------------------------------------------------------------------------- -- Modification history: -- ------------------------------------------------------------------------- -- Version: | Mod. date: | Modified by: -- v0.1 | 6/22/92 | Jose A. Torres -- v0.2 | 1/15/93 | Jose A. Torres -- v0.3 | 4/13/93 | Jose A. Torres -- v0.4 | 4/19/93 | Jose A. Torres -- v0.5 | 4/20/93 | Jose A. Torres -- v0.6 | 4/23/93 | Jose A. Torres -- v0.7 | 5/28/93 | Jose A. Torres -- v0.8 | 9/02/94 | Jose A. Torres -- v0.9 | 9/30/94 | Jose A. Torres -- v0.91 | 1/25/95 | Jose A. Torres -- v0.92 | 3/05/95 | Jose A. Torres -- v0.93 | 3/06/95 | Jose A. Torres -- v0.94 | 3/07/95 | Jose A. Torres -- v0.95 | 3/10/95 | Jose A. Torres -- v0.96 | 3/11/95 | Jose A. Torres -- v0.97 | 3/21/95 | Jose A. Torres -- v0.98 | 3/22/95 | Jose A. Torres -- v0.99 | 3/24/95 | Jose A. Torres ------------------------------------------------------------- Package MATH_COMPLEX is type COMPLEX is record RE, IM: real; end record; type COMPLEX_POLAR is record MAG: real; ARG: real; end record; constant CBASE_1: complex := COMPLEX'(1.0, 0.0); constant CBASE_j: complex := COMPLEX'(0.0, 1.0); constant CZERO: complex := COMPLEX'(0.0, 0.0); function CMPLX(X: in real; Y: in real:= 0.0 ) return complex; -- returns complex number X + iY function COMPLEX_TO_POLAR(Z: in complex ) return complex_polar; -- converts complex to complex_polar function POLAR_TO_COMPLEX(Z: in complex_polar ) return complex; -- converts complex_polar to complex function "ABS"(Z: in complex ) return real; -- returns absolute value (magnitude) of Z -- ABS(Z) = SQRT(Z.re*Z.re + Z.im*Z.im) function "ABS"(Z: in complex_polar ) return real; -- returns absolute value (magnitude) of Z -- ABS(Z) = Z.mag function ARG(Z: in complex ) return real; -- returns argument (angle) in radians of a complex number -- ARG(Z) = ARCTAN(Z.im, Z.re) function ARG(Z: in complex_polar ) return real; -- returns argument (angle) in radians of a complex number -- ARG(Z) = Z.arg function "-" (Z: in complex ) return complex; -- unary minus; returns -x -jy for Z= x + jy function "-" (Z: in complex_polar ) return complex_polar; -- unary minus; returns (Z.mag, Z.arg + MATH_PI) function CONJ (Z: in complex) return complex; -- returns complex conjugate x-jy for Z = x + jy function CONJ (Z: in complex_polar) return complex_polar; -- returns complex conjugate (Z.mag, -Z.arg) function SQRT(Z: in complex ) return complex; -- returns square root of Z; value with positive real part function SQRT(Z: in complex_polar ) return complex_polar; -- returns square root of Z; value with positive real part function EXP(Z: in complex ) return complex; -- returns e**Z function EXP(Z: in complex_polar ) return complex_polar; -- returns e**Z function LOG(Z: in complex ) return complex; -- returns natural logarithm of Z -- LOG(0) = -REAL'HIGH -- LOG(1) = 0.0 -- LOG(-1) = CBASE_j*MATH_PI -- LOG(MATH_E) = 1.0 -- LOG(+/-j) = +/-CBASE_j*0.5*MATH_PI -- error if Z.mag = 0.0 -- ABS(Z.arg) < MATH_PI function LOG(Z: in complex_polar ) return complex_polar; -- returns natural logarithm of Z -- LOG(0) = -REAL'HIGH -- LOG(1) = 0.0 -- LOG(-1) = CBASE_j*MATH_PI -- LOG(MATH_E) = 1.0 -- LOG(+/-j) = +/-CBASE_j*0.5*MATH_PI -- error if Z.mag = 0.0 -- ABS(Z.arg) < MATH_PI -- arithmetic operators function "+" ( L: in complex; R: in complex ) return complex; function "+" ( L: in real; R: in complex ) return complex; function "+" ( L: in complex; R: in real ) return complex; function "+" ( L: in complex_polar; R: in complex_polar) return complex_polar; function "+" ( L: in real; R: in complex_polar) return complex_polar; function "+" ( L: in complex_polar; R: in real) return complex_polar; function "-" ( L: in complex; R: in complex ) return complex; function "-" ( L: in real; R: in complex ) return complex; function "-" ( L: in complex; R: in real ) return complex; function "-" ( L: in complex_polar; R: in complex_polar) return complex_polar; function "-" ( L: in real; R: in complex_polar) return complex_polar; function "-" ( L: in complex_polar; R: in real) return complex_polar; function "*" ( L: in complex; R: in complex ) return complex; function "*" ( L: in real; R: in complex ) return complex; function "*" ( L: in complex; R: in real ) return complex; function "*" ( L: in complex_polar; R: in complex_polar) return complex_polar; function "*" ( L: in real; R: in complex_polar) return complex_polar; function "*" ( L: in complex_polar; R: in real) return complex_polar; function "/" ( L: in complex; R: in complex ) return complex; function "/" ( L: in real; R: in complex ) return complex; function "/" ( L: in complex; R: in real ) return complex; function "/" ( L: in complex_polar; R: in complex_polar) return complex_polar; function "/" ( L: in real; R: in complex_polar) return complex_polar; function "/" ( L: in complex_polar; R: in real) return complex_polar; end MATH_COMPLEX;