Project

General

Profile

Download (7.77 KB) Statistics
| Branch: | Tag: | Revision:
1

    
2
-- Copyright (C) 1996 Morgan Kaufmann Publishers, Inc
3

    
4
-- This file is part of VESTs (Vhdl tESTs).
5

    
6
-- VESTs is free software; you can redistribute it and/or modify it
7
-- under the terms of the GNU General Public License as published by the
8
-- Free Software Foundation; either version 2 of the License, or (at
9
-- your option) any later version. 
10

    
11
-- VESTs is distributed in the hope that it will be useful, but WITHOUT
12
-- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
-- FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
-- for more details. 
15

    
16
-- You should have received a copy of the GNU General Public License
17
-- along with VESTs; if not, write to the Free Software Foundation,
18
-- Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
19

    
20
-- ---------------------------------------------------------------------
21
--
22
-- $Id: math_real.vhd,v 1.2 2001-10-26 16:29:37 paw Exp $
23
-- $Revision: 1.2 $
24
--
25
-- ---------------------------------------------------------------------
26

    
27
--------------------------------------------------------------- 
28
--
29
-- This source file may be used and distributed without restriction.
30
-- No declarations or definitions shall be included in this package. 
31
--
32
--   ****************************************************************
33
--   *                                                              *
34
--   *                      W A R N I N G		 	    *
35
--   *								    *
36
--   *   This DRAFT version IS NOT endorsed or approved by IEEE     *
37
--   *								    *
38
--   ****************************************************************
39
--
40
-- Title:    PACKAGE MATH_REAL
41
--
42
-- Library:  This package shall be compiled into a library 
43
--           symbolically named IEEE.
44
--
45
-- Purpose:  VHDL declarations for mathematical package MATH_REAL
46
--	     which contains common real constants, common real
47
--	     functions, and real trascendental functions.
48
--
49
-- Author:   Based on work by IEEE VHDL Math Package Study Group 
50
--
51
-- Notes:
52
-- 	The package body shall be considered the formal definition of 
53
-- 	the semantics of this package. Tool developers may choose to implement 
54
-- 	the package body in the most efficient manner available to them.
55
--
56
-- History:
57
--	Version 0.4		JAT	4/15/93
58
-------------------------------------------------------------
59
Library IEEE;
60

    
61
Package MATH_REAL is
62
--synopsys synthesis_off
63

    
64
  constant  MATH_E :         real := 2.71828_18284_59045_23536;  
65
                                        -- value of e
66
  constant  MATH_1_E:        real := 0.36787_94411_71442_32160;
67
                                        -- value of 1/e
68
  constant  MATH_PI :        real := 3.14159_26535_89793_23846;  
69
                                        -- value of pi
70
  constant  MATH_1_PI :      real := 0.31830_98861_83790_67154;  
71
                                        -- value of 1/pi
72
  constant  MATH_LOG_OF_2:   real := 0.69314_71805_59945_30942;
73
                                        -- natural log of 2
74
  constant  MATH_LOG_OF_10:  real := 2.30258_50929_94045_68402;
75
                                        -- natural log of10
76
  constant  MATH_LOG2_OF_E:  real := 1.44269_50408_88963_4074;
77
                                        -- log base 2 of e
78
  constant  MATH_LOG10_OF_E: real := 0.43429_44819_03251_82765;
79
                                        -- log base 10 of e
80
  constant  MATH_SQRT2:      real := 1.41421_35623_73095_04880; 
81
                                        -- sqrt of 2
82
  constant  MATH_SQRT1_2:    real := 0.70710_67811_86547_52440; 
83
                                        -- sqrt of 1/2
84
  constant  MATH_SQRT_PI:    real := 1.77245_38509_05516_02730; 
85
                                        -- sqrt of pi
86
  constant  MATH_DEG_TO_RAD: real := 0.01745_32925_19943_29577;
87
  -- conversion factor from degree to radian
88
  constant  MATH_RAD_TO_DEG: real := 57.29577_95130_82320_87685;
89
  -- conversion factor from radian to degree
90

    
91
  --
92
  -- attribute for functions whose implementation is foreign (C native)
93
  --
94
  -- attribute FOREIGN: string;  -- predefined attribute in VHDL-1992
95
  --
96

    
97
  function SIGN (X: real ) return real;
98
  -- returns 1.0 if X > 0.0; 0.0 if X == 0.0; -1.0 if X < 0.0
99

    
100
  function CEIL (X : real ) return real;
101
  -- returns smallest integer value (as real) not less than X
102

    
103
  function FLOOR (X : real ) return real;
104
  -- returns largest integer value (as real) not greater than X
105

    
106
  function ROUND (X : real ) return real;
107
  -- returns FLOOR(X + 0.5) if X > 0.0;
108
  -- return CEIL(X - 0.5) if X < 0.0
109
  
110
  function FMAX (X, Y : real ) return real;
111
  -- returns the algebraically larger of X and Y
112

    
113
  function FMIN (X, Y : real ) return real;
114
  -- returns the algebraically smaller of X and Y
115

    
116
  function SRAND (seed: in integer ) return integer;
117
  -- attribute FOREIGN of SRAND: function is "C_NATIVE"; 
118
  -- for VHDL-1992 standard
119
  --
120
  -- sets value of seed for sequence of pseudo-random numbers.
121
  -- returns the value of the seed.
122
  -- It uses the native C function srand().
123

    
124
  function RAND return integer;		
125
  -- attribute FOREIGN of RAND: function is "C_NATIVE"; 
126
  -- for VHDL-1992 standard
127
  --
128
  -- returns an integer pseudo-random number with uniform distribution.
129
  -- It uses the native C function rand(). 
130
  -- Seed for the sequence is initialized with the
131
  -- SRAND() function and value of the seed is changed every
132
  -- time SRAND() is called,  but it is not visible.
133
  -- The range of generated values is platform dependent.
134

    
135
  function GET_RAND_MAX return integer;		
136
  -- attribute FOREIGN of GET_RAND_MAX: function is "C_NATIVE"; 
137
  -- for VHDL-1992 standard
138
  --
139
  -- returns the upper bound of the range of the
140
  -- pseudo-random numbers generated by  RAND().
141
  -- The support for this function is platform dependent.
142
  -- It may not be available in some platforms.
143
  -- Note: the value of (RAND() / GET_RAND_MAX()) is a
144
  --       pseudo-random number distributed between 0 & 1.
145

    
146
  function SQRT (X : real ) return real;
147
  -- returns square root of X;  X >= 0.0
148

    
149
  function CBRT (X : real ) return real;
150
  -- returns cube root of X
151

    
152
  function "**" (X : integer; Y : real) return real;
153
  -- returns Y power of X ==>  X**Y;
154
  -- error if X = 0 and Y <= 0.0
155
  -- error if X < 0 and Y does not have an integral value
156

    
157
  function "**" (X : real; Y : real) return real;
158
  -- returns Y power of X ==>  X**Y;
159
  -- error if X = 0.0 and Y <= 0.0
160
  -- error if X < 0.0 and Y does not have an integral value
161

    
162
  function EXP  (X : real ) return real;
163
  -- returns e**X; where e = MATH_E
164

    
165
  function LOG (X : real ) return real;
166
  -- returns natural logarithm of X; X > 0
167

    
168
  function LOG (BASE: positive; X : real) return real;
169
  -- returns logarithm base BASE of X; X > 0
170

    
171
  function  SIN (X : real ) return real;
172
  -- returns sin X; X in radians
173

    
174
  function  COS ( X : real ) return real;
175
  -- returns cos X; X in radians
176

    
177
  function  TAN (X : real ) return real;
178
  -- returns tan X; X in radians
179
  -- X /= ((2k+1) * PI/2), where k is an integer
180

    
181
  function  ASIN (X : real ) return real; 
182
  -- returns  -PI/2 < asin X < PI/2; | X | <= 1.0
183

    
184
  function  ACOS (X : real ) return real;
185
  -- returns  0 < acos X < PI; | X | <= 1.0
186

    
187
  function  ATAN (X : real) return real;
188
  -- returns  -PI/2 < atan X < PI/2
189

    
190
  function  ATAN2 (X : real; Y : real) return real;
191
  -- returns  atan (X/Y); -PI < atan2(X,Y) < PI; Y /= 0.0
192

    
193
  function SINH (X : real) return real;
194
  -- hyperbolic sine; returns (e**X - e**(-X))/2
195

    
196
  function  COSH (X : real) return real;
197
  -- hyperbolic cosine; returns (e**X + e**(-X))/2
198

    
199
  function  TANH (X : real) return real;
200
  -- hyperbolic tangent; -- returns (e**X - e**(-X))/(e**X + e**(-X))
201
  
202
  function ASINH (X : real) return real;
203
  -- returns ln( X + sqrt( X**2 + 1))
204

    
205
  function ACOSH (X : real) return real;
206
  -- returns ln( X + sqrt( X**2 - 1));   X >= 1.0
207

    
208
  function ATANH (X : real) return real;
209
  -- returns (ln( (1 + X)/(1 - X)))/2 ; | X | < 1.0
210

    
211
--synopsys synthesis_on
212
end  MATH_REAL;
(266-266/267)