diff options
Diffstat (limited to 'libraries/ieee/math_complex-body.vhdl')
-rw-r--r-- | libraries/ieee/math_complex-body.vhdl | 218 |
1 files changed, 108 insertions, 110 deletions
diff --git a/libraries/ieee/math_complex-body.vhdl b/libraries/ieee/math_complex-body.vhdl index 97fb6bbdf..6245b8eca 100644 --- a/libraries/ieee/math_complex-body.vhdl +++ b/libraries/ieee/math_complex-body.vhdl @@ -1,53 +1,52 @@ ------------------------------------------------------------------------- +-- ----------------------------------------------------------------- +-- +-- Copyright 2019 IEEE P1076 WG Authors +-- +-- See the LICENSE file distributed with this work for copyright and +-- licensing information and the AUTHORS file. +-- +-- This file to you under the Apache License, Version 2.0 (the "License"). +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +-- implied. See the License for the specific language governing +-- permissions and limitations under the License. -- --- Copyright 1996 by IEEE. All rights reserved. --- --- This source file is an informative part of IEEE Std 1076.2-1996, IEEE Standard --- VHDL Mathematical Packages. This source file may not be copied, sold, or --- included with software that is sold without written permission from the IEEE --- Standards Department. This source file may be used to implement this standard --- and may be distributed in compiled form in any manner so long as the --- compiled form does not allow direct decompilation of the original source file. --- This source file may be copied for individual use between licensed users. --- This source file is provided on an AS IS basis. The IEEE disclaims ANY --- WARRANTY EXPRESS OR IMPLIED INCLUDING ANY WARRANTY OF MERCHANTABILITY --- AND FITNESS FOR USE FOR A PARTICULAR PURPOSE. The user of the source --- file shall indemnify and hold IEEE harmless from any damages or liability --- arising out of the use thereof. --- --- Title: Standard VHDL Mathematical Packages (IEEE Std 1076.2-1996, --- MATH_COMPLEX) --- --- Library: This package shall be compiled into a library --- symbolically named IEEE. --- --- Developers: IEEE DASC VHDL Mathematical Packages Working Group --- --- Purpose: This package body is a nonnormative implementation of the --- functionality defined in the MATH_COMPLEX package declaration. --- --- Limitation: The values generated by the functions in this package may --- vary from platform to platform, and the precision of results --- is only guaranteed to be the minimum required by IEEE Std 1076 --- -1993. --- --- Notes: --- 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 --- represent the formal semantics of the implementation of the --- MATH_COMPLEX package declaration. The purpose of the --- MATH_COMPLEX package body is to clarify such semantics and --- provide a guideline for implementations to verify their --- implementation of MATH_COMPLEX. Tool developers may choose to --- implement the package body in the most efficient manner --- available to them. --- --- ----------------------------------------------------------------------------- --- Version : 1.5 --- Date : 24 July 1996 --- ----------------------------------------------------------------------------- +-- Title : Standard VHDL Mathematical Packages +-- : (MATH_COMPLEX package body) +-- : +-- Library : This package shall be compiled into a library +-- : symbolically named IEEE. +-- : +-- Developers: IEEE DASC VHDL Mathematical Packages Working Group +-- : +-- 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 guaranteed to be the minimum required +-- : by IEEE Std 1076-2008. +-- : +-- Note : This package may be modified to include additional data +-- : required by tools, but it must in no way change the +-- : external interfaces or simulation behavior of the +-- : description. It is permissible to add comments and/or +-- : attributes to the package declarations, but not to change +-- : or delete any original lines of the package declaration. +-- : The package body may be changed only in accordance with +-- : the terms of Clause 16 of this standard. +-- : +-- -------------------------------------------------------------------- +-- $Revision: 1220 $ +-- $Date: 2008-04-10 17:16:09 +0930 (Thu, 10 Apr 2008) $ +-- -------------------------------------------------------------------- use WORK.MATH_REAL.all; @@ -89,7 +88,7 @@ package body MATH_COMPLEX is end if; return FALSE; - end "="; + end function "="; function "/=" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR ) return BOOLEAN @@ -125,7 +124,7 @@ package body MATH_COMPLEX is end if; return TRUE; - end "/="; + end function "/="; -- -- Other Functions Start Here @@ -138,7 +137,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(X, Y); - end CMPLX; + end function CMPLX; function GET_PRINCIPAL_VALUE(X: in REAL ) return PRINCIPAL_VALUE is @@ -163,7 +162,7 @@ package body MATH_COMPLEX is end loop; return PRINCIPAL_VALUE'(TEMP); - end GET_PRINCIPAL_VALUE; + end function GET_PRINCIPAL_VALUE; function COMPLEX_TO_POLAR(Z: in COMPLEX ) return COMPLEX_POLAR is -- Description: @@ -198,7 +197,7 @@ package body MATH_COMPLEX is return COMPLEX_POLAR'(SQRT(Z.RE*Z.RE + Z.IM*Z.IM), GET_PRINCIPAL_VALUE(TEMP)); - end COMPLEX_TO_POLAR; + end function COMPLEX_TO_POLAR; function POLAR_TO_COMPLEX(Z: in COMPLEX_POLAR ) return COMPLEX is -- Description: @@ -216,7 +215,7 @@ package body MATH_COMPLEX is -- Get value for general case return COMPLEX'( Z.MAG*COS(Z.ARG), Z.MAG*SIN(Z.ARG) ); - end POLAR_TO_COMPLEX; + end function POLAR_TO_COMPLEX; function "ABS"(Z: in COMPLEX ) return POSITIVE_REAL is @@ -228,7 +227,7 @@ package body MATH_COMPLEX is begin -- Get value for general case return POSITIVE_REAL'(SQRT(Z.RE*Z.RE + Z.IM*Z.IM)); - end "ABS"; + end function "ABS"; function "ABS"(Z: in COMPLEX_POLAR ) return POSITIVE_REAL is -- Description: @@ -248,7 +247,7 @@ package body MATH_COMPLEX is -- Get value for general case return Z.MAG; - end "ABS"; + end function "ABS"; function ARG(Z: in COMPLEX ) return PRINCIPAL_VALUE is @@ -262,7 +261,7 @@ package body MATH_COMPLEX is -- Get value for general case ZTEMP := COMPLEX_TO_POLAR(Z); return ZTEMP.ARG; - end ARG; + end function ARG; function ARG(Z: in COMPLEX_POLAR ) return PRINCIPAL_VALUE is -- Description: @@ -282,7 +281,7 @@ package body MATH_COMPLEX is -- Get value for general case return Z.ARG; - end ARG; + end function ARG; function "-" (Z: in COMPLEX ) return COMPLEX is -- Description: @@ -292,7 +291,7 @@ package body MATH_COMPLEX is begin -- Get value for general case return COMPLEX'(-Z.RE, -Z.IM); - end "-"; + end function "-"; function "-" (Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -314,7 +313,7 @@ package body MATH_COMPLEX is TEMP := REAL'(Z.ARG) + MATH_PI; return COMPLEX_POLAR'(Z.MAG, GET_PRINCIPAL_VALUE(TEMP)); - end "-"; + end function "-"; function CONJ (Z: in COMPLEX) return COMPLEX is -- Description: @@ -324,7 +323,7 @@ package body MATH_COMPLEX is begin -- Get value for general case return COMPLEX'(Z.RE, -Z.IM); - end CONJ; + end function CONJ; function CONJ (Z: in COMPLEX_POLAR) return COMPLEX_POLAR is -- Description: @@ -351,7 +350,7 @@ package body MATH_COMPLEX is end if; return COMPLEX_POLAR'(Z.MAG, TEMP); - end CONJ; + end function CONJ; function SQRT(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -394,7 +393,7 @@ package body MATH_COMPLEX is ZOUT.RE := 0.0; ZOUT.IM := TMAG*SIN(TARG + MATH_PI); return ZOUT; - end SQRT; + end function SQRT; function SQRT(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -435,7 +434,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(TARG); return ZOUT; - end SQRT; + end function SQRT; function EXP(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -467,7 +466,7 @@ package body MATH_COMPLEX is -- Get value for general case TEMP := EXP(Z.RE); return COMPLEX'(TEMP*COS(Z.IM), TEMP*SIN(Z.IM)); - end EXP; + end function EXP; function EXP(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -476,7 +475,6 @@ package body MATH_COMPLEX is -- a) Returns Z on error variable ZTEMP : COMPLEX; - variable temp: REAL; variable ZOUT : COMPLEX_POLAR; begin -- Check validity of input arguments @@ -513,7 +511,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(ZTEMP.IM); return ZOUT; - end EXP; + end function EXP; function LOG(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -558,7 +556,7 @@ package body MATH_COMPLEX is ZTEMP := COMPLEX_TO_POLAR(Z); TEMP := LOG(ZTEMP.MAG); return COMPLEX'(TEMP, ZTEMP.ARG); - end LOG; + end function LOG; function LOG2(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -592,7 +590,7 @@ package body MATH_COMPLEX is ZTEMP := COMPLEX_TO_POLAR(Z); TEMP := MATH_LOG2_OF_E*LOG(ZTEMP.MAG); return COMPLEX'(TEMP, MATH_LOG2_OF_E*ZTEMP.ARG); - end LOG2; + end function LOG2; function LOG10(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -625,7 +623,7 @@ package body MATH_COMPLEX is ZTEMP := COMPLEX_TO_POLAR(Z); TEMP := MATH_LOG10_OF_E*LOG(ZTEMP.MAG); return COMPLEX'(TEMP, MATH_LOG10_OF_E*ZTEMP.ARG); - end LOG10; + end function LOG10; function LOG(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is @@ -680,7 +678,7 @@ package body MATH_COMPLEX is ZTEMP.IM := Z.ARG; ZOUT := COMPLEX_TO_POLAR(ZTEMP); return ZOUT; - end LOG; + end function LOG; @@ -722,7 +720,7 @@ package body MATH_COMPLEX is ZTEMP.IM := MATH_LOG2_OF_E*Z.ARG; ZOUT := COMPLEX_TO_POLAR(ZTEMP); return ZOUT; - end LOG2; + end function LOG2; function LOG10(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -762,7 +760,7 @@ package body MATH_COMPLEX is ZTEMP.IM := MATH_LOG10_OF_E*Z.ARG; ZOUT := COMPLEX_TO_POLAR(ZTEMP); return ZOUT; - end LOG10; + end function LOG10; function LOG(Z: in COMPLEX; BASE: in REAL ) return COMPLEX is -- Description: @@ -804,7 +802,7 @@ package body MATH_COMPLEX is TEMPRE := LOG(ZTEMP.MAG, BASE); TEMPIM := ZTEMP.ARG/LOG(BASE); return COMPLEX'(TEMPRE, TEMPIM); - end LOG; + end function LOG; function LOG(Z: in COMPLEX_POLAR; BASE: in REAL ) return COMPLEX_POLAR is -- Description: @@ -851,7 +849,7 @@ package body MATH_COMPLEX is ZTEMP.IM := Z.ARG/LOG(BASE); ZOUT := COMPLEX_TO_POLAR(ZTEMP); return ZOUT; - end LOG; + end function LOG; function SIN(Z: in COMPLEX ) return COMPLEX is @@ -869,7 +867,7 @@ package body MATH_COMPLEX is -- Get value for general case return COMPLEX'(SIN(Z.RE)*COSH(Z.IM), COS(Z.RE)*SINH(Z.IM)); - end SIN; + end function SIN; function SIN(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -902,7 +900,7 @@ package body MATH_COMPLEX is Z2 := COMPLEX'(SIN(Z1.RE)*COSH(Z1.IM), COS(Z1.RE)*SINH(Z1.IM)); ZOUT := COMPLEX_TO_POLAR(Z2); return ZOUT; - end SIN; + end function SIN; function COS(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -921,7 +919,7 @@ package body MATH_COMPLEX is -- Get value for general case return COMPLEX'(COS(Z.RE)*COSH(Z.IM), -SIN(Z.RE)*SINH(Z.IM)); - end COS; + end function COS; function COS(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -954,7 +952,7 @@ package body MATH_COMPLEX is Z2 := COMPLEX'(COS(Z1.RE)*COSH(Z1.IM), -SIN(Z1.RE)*SINH(Z1.IM)); ZOUT := COMPLEX_TO_POLAR(Z2); return ZOUT; - end COS; + end function COS; function SINH(Z: in COMPLEX ) return COMPLEX is -- Description: @@ -981,7 +979,7 @@ package body MATH_COMPLEX is -- Get value for general case return COMPLEX'(SINH(Z.RE)*COS(Z.IM), COSH(Z.RE)*SIN(Z.IM)); - end SINH; + end function SINH; function SINH(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -1022,7 +1020,7 @@ package body MATH_COMPLEX is Z2 := COMPLEX'(SINH(Z1.RE)*COS(Z1.IM), COSH(Z1.RE)*SIN(Z1.IM)); ZOUT := COMPLEX_TO_POLAR(Z2); return ZOUT; - end SINH; + end function SINH; function COSH(Z: in COMPLEX ) return COMPLEX is @@ -1048,7 +1046,7 @@ package body MATH_COMPLEX is -- Get value for general case return COMPLEX'(COSH(Z.RE)*COS(Z.IM), SINH(Z.RE)*SIN(Z.IM)); - end COSH; + end function COSH; function COSH(Z: in COMPLEX_POLAR ) return COMPLEX_POLAR is -- Description: @@ -1089,7 +1087,7 @@ package body MATH_COMPLEX is Z2 := COMPLEX'(COSH(Z1.RE)*COS(Z1.IM), SINH(Z1.RE)*SIN(Z1.IM)); ZOUT := COMPLEX_TO_POLAR(Z2); return ZOUT; - end COSH; + end function COSH; -- @@ -1102,7 +1100,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L.RE + R.RE, L.IM + R.IM); - end "+"; + end function "+"; function "+" ( L: in REAL; R: in COMPLEX ) return COMPLEX is -- Description: @@ -1111,7 +1109,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L + R.RE, R.IM); - end "+"; + end function "+"; function "+" ( L: in COMPLEX; R: in REAL ) return COMPLEX is -- Description: @@ -1120,7 +1118,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L.RE + R, L.IM); - end "+"; + end function "+"; function "+" (L: in COMPLEX_POLAR; R: in COMPLEX_POLAR) return COMPLEX_POLAR is @@ -1153,7 +1151,7 @@ package body MATH_COMPLEX is ZR := POLAR_TO_COMPLEX( R ); ZOUT := COMPLEX_TO_POLAR(COMPLEX'(ZL.RE + ZR.RE, ZL.IM +ZR.IM)); return ZOUT; - end "+"; + end function "+"; function "+" ( L: in REAL; R: in COMPLEX_POLAR) return COMPLEX_POLAR is -- Description: @@ -1175,7 +1173,7 @@ package body MATH_COMPLEX is ZR := POLAR_TO_COMPLEX( R ); ZOUT := COMPLEX_TO_POLAR(COMPLEX'(L + ZR.RE, ZR.IM)); return ZOUT; - end "+"; + end function "+"; function "+" ( L: in COMPLEX_POLAR; R: in REAL) return COMPLEX_POLAR is -- Description: @@ -1198,7 +1196,7 @@ package body MATH_COMPLEX is ZL := POLAR_TO_COMPLEX( L ); ZOUT := COMPLEX_TO_POLAR(COMPLEX'(ZL.RE + R, ZL.IM)); return ZOUT; - end "+"; + end function "+"; function "-" ( L: in COMPLEX; R: in COMPLEX ) return COMPLEX is -- Description: @@ -1207,7 +1205,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L.RE - R.RE, L.IM - R.IM); - end "-"; + end function "-"; function "-" ( L: in REAL; R: in COMPLEX ) return COMPLEX is -- Description: @@ -1216,7 +1214,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L - R.RE, -1.0 * R.IM); - end "-"; + end function "-"; function "-" ( L: in COMPLEX; R: in REAL ) return COMPLEX is -- Description: @@ -1225,7 +1223,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L.RE - R, L.IM); - end "-"; + end function "-"; function "-" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR) return COMPLEX_POLAR is @@ -1256,7 +1254,7 @@ package body MATH_COMPLEX is ZR := POLAR_TO_COMPLEX( R ); ZOUT := COMPLEX_TO_POLAR(COMPLEX'(ZL.RE - ZR.RE, ZL.IM -ZR.IM)); return ZOUT; - end "-"; + end function "-"; function "-" ( L: in REAL; R: in COMPLEX_POLAR) return COMPLEX_POLAR is -- Description: @@ -1279,7 +1277,7 @@ package body MATH_COMPLEX is ZR := POLAR_TO_COMPLEX( R ); ZOUT := COMPLEX_TO_POLAR(COMPLEX'(L - ZR.RE, -1.0*ZR.IM)); return ZOUT; - end "-"; + end function "-"; function "-" ( L: in COMPLEX_POLAR; R: in REAL) return COMPLEX_POLAR is -- Description: @@ -1302,7 +1300,7 @@ package body MATH_COMPLEX is ZL := POLAR_TO_COMPLEX( L ); ZOUT := COMPLEX_TO_POLAR(COMPLEX'(ZL.RE - R, ZL.IM)); return ZOUT; - end "-"; + end function "-"; function "*" ( L: in COMPLEX; R: in COMPLEX ) return COMPLEX is @@ -1312,7 +1310,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L.RE * R.RE - L.IM * R.IM, L.RE * R.IM + L.IM * R.RE); - end "*"; + end function "*"; function "*" ( L: in REAL; R: in COMPLEX ) return COMPLEX is @@ -1322,7 +1320,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L * R.RE, L * R.IM); - end "*"; + end function "*"; function "*" ( L: in COMPLEX; R: in REAL ) return COMPLEX is -- Description: @@ -1331,7 +1329,7 @@ package body MATH_COMPLEX is -- None begin return COMPLEX'(L.RE * R, L.IM * R); - end "*"; + end function "*"; function "*" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR) return COMPLEX_POLAR is @@ -1362,7 +1360,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(L.ARG + R.ARG); return ZOUT; - end "*"; + end function "*"; function "*" ( L: in REAL; R: in COMPLEX_POLAR) return COMPLEX_POLAR is -- Description: @@ -1393,7 +1391,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(ZL.ARG + R.ARG); return ZOUT; - end "*"; + end function "*"; function "*" ( L: in COMPLEX_POLAR; R: in REAL) return COMPLEX_POLAR is -- Description: @@ -1424,7 +1422,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(L.ARG + ZR.ARG); return ZOUT; - end "*"; + end function "*"; function "/" ( L: in COMPLEX; R: in COMPLEX ) return COMPLEX is -- Description: @@ -1432,7 +1430,7 @@ package body MATH_COMPLEX is -- Notes: -- a) Returns COMPLEX'(REAL'HIGH, 0.0) on error -- - variable TEMP : REAL := R.RE*R.RE + R.IM*R.IM; + constant TEMP : REAL := R.RE*R.RE + R.IM*R.IM; begin -- Check validity of input arguments if (TEMP = 0.0) then @@ -1445,7 +1443,7 @@ package body MATH_COMPLEX is -- Get value return COMPLEX'( (L.RE * R.RE + L.IM * R.IM) / TEMP, (L.IM * R.RE - L.RE * R.IM) / TEMP); - end "/"; + end function "/"; function "/" ( L: in REAL; R: in COMPLEX ) return COMPLEX is -- Description: @@ -1466,7 +1464,7 @@ package body MATH_COMPLEX is -- Get value TEMP := L / TEMP; return COMPLEX'( TEMP * R.RE, -TEMP * R.IM ); - end "/"; + end function "/"; function "/" ( L: in COMPLEX; R: in REAL ) return COMPLEX is -- Description: @@ -1484,7 +1482,7 @@ package body MATH_COMPLEX is -- Get value return COMPLEX'(L.RE / R, L.IM / R); - end "/"; + end function "/"; function "/" ( L: in COMPLEX_POLAR; R: in COMPLEX_POLAR) @@ -1523,7 +1521,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(L.ARG - R.ARG); return ZOUT; - end "/"; + end function "/"; function "/" ( L: in COMPLEX_POLAR; R: in REAL) return COMPLEX_POLAR is -- Description: @@ -1561,7 +1559,7 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(L.ARG - ZR.ARG); return ZOUT; - end "/"; + end function "/"; function "/" ( L: in REAL; R: in COMPLEX_POLAR) return COMPLEX_POLAR is -- Description: @@ -1599,6 +1597,6 @@ package body MATH_COMPLEX is ZOUT.ARG := GET_PRINCIPAL_VALUE(ZL.ARG - R.ARG); return ZOUT; - end "/"; + end function "/"; -end MATH_COMPLEX; +end package body MATH_COMPLEX; |