Update repo
This commit is contained in:
1 parent
749dab5721
commit
ce65a0f59a
14950 files changed
+4408250
-1
No files matched your search
@@ -0,0 +1,275 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAacos.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA arccosine function
|
||||
;;
|
||||
;; Group: C2000
|
||||
;; Target Family: C28x+CLA
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;;
|
||||
;; Step(1): Calculate absolute of the input X
|
||||
;;
|
||||
;; Step(2): Use the upper 6-bits of input "X" value as an
|
||||
;; index into the table to obtain the coefficients
|
||||
;; for a second order equation:
|
||||
;;
|
||||
;; _CLAacosinTable:
|
||||
;; CoeffA0[0]
|
||||
;; CoeffA1[0]
|
||||
;; CoeffA2[0]
|
||||
;; .
|
||||
;; .
|
||||
;; CoeffA0[63]
|
||||
;; CoeffA1[63]
|
||||
;; CoeffA2[63]
|
||||
;;
|
||||
;; Step(3): Calculate the angle using the folowing equation:
|
||||
;;
|
||||
;; arccos(Ratio) = A0 + A1*Ratio + A2*Ratio*Ratio
|
||||
;; arccos(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
;;
|
||||
;; Step(4): The final angle is determined as follows:
|
||||
;;
|
||||
;; if( X < 0 )
|
||||
;; Angle = Pi - Angle
|
||||
;;
|
||||
;; Equation: y = acos(x)
|
||||
;;
|
||||
;; Regs Used: MR0, MR1, MR2, MR3 , MAR0,MAR1
|
||||
;;
|
||||
;; Input: x f32 value in memory
|
||||
;;
|
||||
;; Output: y f32 value in memory
|
||||
;; MR0 = y f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 27
|
||||
;; Instructions = 27
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+2)
|
||||
;; |_______|<- acos temporary variable (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
.def _CLAacos
|
||||
.sect "Cla1Prog:_CLAacos"
|
||||
.align 2
|
||||
.def __cla_CLAacos_sp
|
||||
__cla_CLAacos_sp .usect ".scratchpad:Cla1Prog:_CLAacos",4,0,1
|
||||
|
||||
_CLAacos:
|
||||
.asmfunc
|
||||
.asg __cla_CLAacos_sp + 0, _acos_tmp
|
||||
.asg __cla_CLAacos_sp + 2, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
|
||||
; MR0 = X(fVal) is stored in the scratchpad memory
|
||||
MMOV32 @_acos_tmp, MR0
|
||||
|
||||
; Perform Step (1):
|
||||
MABSF32 MR3,MR0 ; MR3 = abs(X)
|
||||
|
||||
; Perform Step (2):
|
||||
MMPYF32 MR2,MR3,#63.0 ; 64 = Elements In Table (indexed from 0)
|
||||
MF32TOUI16 MR2,MR2 ; MR2 = int(63*x)
|
||||
MADD32 MR2,MR2,MR2 ; MR2 = 2*MR2
|
||||
MADD32 MR1,MR2,MR2 ; MR1 = 4*MR2
|
||||
MADD32 MR2,MR2,MR1 ; MR2 = 6*MR2 this is the index value for the stored data array
|
||||
MMOV16 MAR0,MR2,#_CLAacosinTable+4 ; MAR0 points to A2, this will be used in step 4
|
||||
MMOVI16 MAR1,#_CLAacosinHalfPITable+2 ; MAR1 points to pi/2, this will be used in step 5
|
||||
MNOP
|
||||
MNOP
|
||||
; Perform Step (4):
|
||||
; arcsin(x) = A0 + x(A1 + A2*x)
|
||||
MMOV32 MR1,*MAR0[#-2]++ ; MR1 = A2
|
||||
MMPYF32 MR1,MR1,MR3 ; MR1 = A2*x
|
||||
|| MMOV32 MR2,*MAR0[#-2]++ ; MR2 = A1
|
||||
|
||||
MADDF32 MR2,MR2,MR1 ; MR2 = A1 + A2*x
|
||||
|| MMOV32 MR1,*MAR0 ; MR1 = A0
|
||||
MMPYF32 MR2,MR2,MR3 ; MR3 = x*(A1 + A2*x)
|
||||
|
||||
MADDF32 MR3,MR1,MR2 ; MR3 = A0 + x*(A1 + A2*x)=arccosin(x)
|
||||
|
||||
; Perform Step (5):
|
||||
MMOV32 MR1,*MAR1,UNC ; MR1 = pi (no flag change)
|
||||
MSUBF32 MR1,MR1,MR3 ; MR2= pi - arcos(x)
|
||||
|
||||
MMOV32 MR2,@_acos_tmp ; MR2 = x (set/clear NF,ZF)
|
||||
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MMOV32 MR3,MR1,LT
|
||||
MMOV32 MR0,MR3 ; Store Y = acos(X)
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _acos_tmp
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;; Use this variant when using the acos table in ROM for these devices:
|
||||
;; 1. F2805x (all revisions)
|
||||
;;
|
||||
;; There are 65 triplets in the lookup table on these devices
|
||||
;; and the routine must ignore the first triplet. This is done
|
||||
;; with the TABLESKIP factor.
|
||||
;;
|
||||
;; Step(1): Calculate absolute of the input X
|
||||
;;
|
||||
;; Step(2): Use the upper 6-bits of input "X" value as an
|
||||
;; index into the table to obtain the coefficients
|
||||
;; for a second order equation:
|
||||
;;
|
||||
;; _CLAacosinTable:
|
||||
;; CoeffA0[0]
|
||||
;; CoeffA1[0]
|
||||
;; CoeffA2[0]
|
||||
;; .
|
||||
;; .
|
||||
;; CoeffA0[63]
|
||||
;; CoeffA1[63]
|
||||
;; CoeffA2[63]
|
||||
;;
|
||||
;; Step(3): Calculate the angle using the folowing equation:
|
||||
;;
|
||||
;; arccos(Ratio) = A0 + A1*Ratio + A2*Ratio*Ratio
|
||||
;; arccos(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
;;
|
||||
;; Step(4): The final angle is determined as follows:
|
||||
;;
|
||||
;; if( X < 0 )
|
||||
;; Angle = Pi - Angle
|
||||
;;
|
||||
;; Equation: y = acos(x)
|
||||
;;
|
||||
;; Regs Used: MR0, MR1, MR2, MR3 , MAR0,MAR1
|
||||
;;
|
||||
;; Input: x f32 value in memory
|
||||
;;
|
||||
;; Output: y f32 value in memory
|
||||
;; MR0 = y f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 24
|
||||
;; Instructions = 24
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+2)
|
||||
;; |_______|<- acos temporary variable (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
.def _CLAacos_spc
|
||||
.sect "Cla1Prog:_CLAacos_spc"
|
||||
.align 2
|
||||
.def __cla_CLAacos_spc_sp
|
||||
__cla_CLAacos_spc_sp .usect ".scratchpad:Cla1Prog:_CLAacos_spc",4,0,1
|
||||
|
||||
TABLESKIP .set 6
|
||||
|
||||
_CLAacos_spc:
|
||||
.asmfunc
|
||||
.asg __cla_CLAacos_spc_sp + 0, _acos_tmp
|
||||
.asg __cla_CLAacos_spc_sp + 2, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
|
||||
; MR0 = X(fVal) is stored in the scratchpad memory
|
||||
MMOV32 @_acos_tmp, MR0
|
||||
|
||||
; Perform Step (1):
|
||||
MABSF32 MR3,MR0 ; MR3 = abs(X)
|
||||
|
||||
; Perform Step (2):
|
||||
MMPYF32 MR2,MR3,#63.0 ; 64 = Elements In Table (indexed from 0)
|
||||
MF32TOUI16 MR2,MR2 ; MR2 = int(63*x)
|
||||
MADD32 MR2,MR2,MR2 ; MR2 = 2*MR2
|
||||
MADD32 MR1,MR2,MR2 ; MR1 = 4*MR2
|
||||
MADD32 MR2,MR2,MR1 ; MR2 = 6*MR2 this is the index value for the stored data array
|
||||
MMOV16 MAR0,MR2,#_CLAacosinTable+4+TABLESKIP ; MAR0 points to A2, this will be used in step 4
|
||||
MMOVI16 MAR1,#_CLAacosinHalfPITable+2 ; MAR1 points to pi/2, this will be used in step 5
|
||||
MNOP
|
||||
MNOP
|
||||
; Perform Step (4):
|
||||
; arcsin(x) = A0 + x(A1 + A2*x)
|
||||
MMOV32 MR1,*MAR0[#-2]++ ; MR1 = A2
|
||||
MMPYF32 MR1,MR1,MR3 ; MR1 = A2*x
|
||||
|| MMOV32 MR2,*MAR0[#-2]++ ; MR2 = A1
|
||||
|
||||
MADDF32 MR2,MR2,MR1 ; MR2 = A1 + A2*x
|
||||
|| MMOV32 MR1,*MAR0 ; MR1 = A0
|
||||
MMPYF32 MR2,MR2,MR3 ; MR3 = x*(A1 + A2*x)
|
||||
|
||||
MADDF32 MR3,MR1,MR2 ; MR3 = A0 + x*(A1 + A2*x)=arccosin(x)
|
||||
|
||||
; Perform Step (5):
|
||||
MMOV32 MR1,*MAR1,UNC ; MR1 = pi (no flag change)
|
||||
MSUBF32 MR1,MR1,MR3 ; MR2= pi - arcos(x)
|
||||
|
||||
MMOV32 MR2,@_acos_tmp ; MR2 = x (set/clear NF,ZF)
|
||||
|
||||
; Context Restore and Final Operations
|
||||
|
||||
MRCNDD UNC
|
||||
MMOV32 MR3,@_save_MR3
|
||||
MMOV32 MR3,MR1,LT
|
||||
MMOV32 MR0,MR3 ; Store Y = acos(X)
|
||||
.unasg _acos_tmp
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
@@ -0,0 +1,263 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAacosineTable.asm
|
||||
;;
|
||||
;; DESCRIPTION: acosine Tables
|
||||
;;
|
||||
;; Group: C2000
|
||||
;; Target Family: C28x+CLA
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
.def _CLAacosinHalfPITable
|
||||
.def _CLAacosinTable
|
||||
.def _CLAacosinTableEnd
|
||||
|
||||
.sect "CLA1mathTables"
|
||||
|
||||
_CLAacosinHalfPITable:
|
||||
.float 2.0 ; 2.0
|
||||
.float 3.141592653589 ; PI
|
||||
|
||||
_CLAacosinTable:
|
||||
.float 1.570795690593 ;
|
||||
.float -0.999877862610 ;
|
||||
.float -0.007815361896 ;
|
||||
.float 1.570791227101 ;
|
||||
.float -0.999510644409 ;
|
||||
.float -0.015647916155 ;
|
||||
.float 1.570779058483 ;
|
||||
.float -0.998895919094 ;
|
||||
.float -0.023514960332 ;
|
||||
.float 1.570755205030 ;
|
||||
.float -0.998029615282 ;
|
||||
.float -0.031434003631 ;
|
||||
.float 1.570715532275 ;
|
||||
.float -0.996905974725 ;
|
||||
.float -0.039422875916 ;
|
||||
.float 1.570655695706 ;
|
||||
.float -0.995517492804 ;
|
||||
.float -0.047499840611 ;
|
||||
.float 1.570571082211 ;
|
||||
.float -0.993854840311 ;
|
||||
.float -0.055683712914 ;
|
||||
.float 1.570456747283 ;
|
||||
.float -0.991906765146 ;
|
||||
.float -0.063993984848 ;
|
||||
.float 1.570307346943 ;
|
||||
.float -0.989659972212 ;
|
||||
.float -0.072450958820 ;
|
||||
.float 1.570117063183 ;
|
||||
.float -0.987098979366 ;
|
||||
.float -0.081075891529 ;
|
||||
.float 1.569879521613 ;
|
||||
.float -0.984205946802 ;
|
||||
.float -0.089891150305 ;
|
||||
.float 1.569587699755 ;
|
||||
.float -0.980960476685 ;
|
||||
.float -0.098920384204 ;
|
||||
.float 1.569233824246 ;
|
||||
.float -0.977339379243 ;
|
||||
.float -0.108188712551 ;
|
||||
.float 1.568809254867 ;
|
||||
.float -0.973316400729 ;
|
||||
.float -0.117722933997 ;
|
||||
.float 1.568304353010 ;
|
||||
.float -0.968861907789 ;
|
||||
.float -0.127551759665 ;
|
||||
.float 1.567708331742 ;
|
||||
.float -0.963942521723 ;
|
||||
.float -0.137706074532 ;
|
||||
.float 1.567009084103 ;
|
||||
.float -0.958520694794 ;
|
||||
.float -0.148219231941 ;
|
||||
.float 1.566192985657 ;
|
||||
.float -0.952554219267 ;
|
||||
.float -0.159127386977 ;
|
||||
.float 1.565244666501 ;
|
||||
.float -0.945995657913 ;
|
||||
.float -0.170469875522 ;
|
||||
.float 1.564146746998 ;
|
||||
.float -0.938791682505 ;
|
||||
.float -0.182289647088 ;
|
||||
.float 1.562879530320 ;
|
||||
.float -0.930882303984 ;
|
||||
.float -0.194633761132 ;
|
||||
.float 1.561420643385 ;
|
||||
.float -0.922199974574 ;
|
||||
.float -0.207553958472 ;
|
||||
.float 1.559744615987 ;
|
||||
.float -0.912668537890 ;
|
||||
.float -0.221107321885 ;
|
||||
.float 1.557822385620 ;
|
||||
.float -0.902201997769 ;
|
||||
.float -0.235357042896 ;
|
||||
.float 1.555620712621 ;
|
||||
.float -0.890703070035 ;
|
||||
.float -0.250373315541 ;
|
||||
.float 1.553101486693 ;
|
||||
.float -0.878061473098 ;
|
||||
.float -0.266234382514 ;
|
||||
.float 1.550220901258 ;
|
||||
.float -0.864151902887 ;
|
||||
.float -0.283027765009 ;
|
||||
.float 1.546928466282 ;
|
||||
.float -0.848831624374 ;
|
||||
.float -0.300851714968 ;
|
||||
.float 1.543165822740 ;
|
||||
.float -0.831937595031 ;
|
||||
.float -0.319816937941 ;
|
||||
.float 1.538865312248 ;
|
||||
.float -0.813283013821 ;
|
||||
.float -0.340048646894 ;
|
||||
.float 1.533948242840 ;
|
||||
.float -0.792653161200 ;
|
||||
.float -0.361689022958 ;
|
||||
.float 1.528322775521 ;
|
||||
.float -0.769800358920 ;
|
||||
.float -0.384900179460 ;
|
||||
.float 1.521881334589 ;
|
||||
.float -0.744437830278 ;
|
||||
.float -0.409867752228 ;
|
||||
.float 1.514497416045 ;
|
||||
.float -0.716232177740 ;
|
||||
.float -0.436805274317 ;
|
||||
.float 1.506021630009 ;
|
||||
.float -0.684794109766 ;
|
||||
.float -0.465959540059 ;
|
||||
.float 1.496276761095 ;
|
||||
.float -0.649666934178 ;
|
||||
.float -0.497617226179 ;
|
||||
.float 1.485051559906 ;
|
||||
.float -0.610312179660 ;
|
||||
.float -0.532113122767 ;
|
||||
.float 1.472092881189 ;
|
||||
.float -0.566091493186 ;
|
||||
.float -0.569840443472 ;
|
||||
.float 1.457095648266 ;
|
||||
.float -0.516243664372 ;
|
||||
.float -0.611263845480 ;
|
||||
.float 1.439689931785 ;
|
||||
.float -0.459855210927 ;
|
||||
.float -0.656936015611 ;
|
||||
.float 1.419424157563 ;
|
||||
.float -0.395822366759 ;
|
||||
.float -0.707518998893 ;
|
||||
.float 1.395743063136 ;
|
||||
.float -0.322801460177 ;
|
||||
.float -0.763811905770 ;
|
||||
.float 1.367958442925 ;
|
||||
.float -0.239143420888 ;
|
||||
.float -0.826787304376 ;
|
||||
.float 1.335209858030 ;
|
||||
.float -0.142806299514 ;
|
||||
.float -0.897639596948 ;
|
||||
.float 1.296411176970 ;
|
||||
.float -0.031236880585 ;
|
||||
.float -0.977850174820 ;
|
||||
.float 1.250176790856 ;
|
||||
.float 0.098791845166 ;
|
||||
.float -1.069276441800 ;
|
||||
.float 1.194718157174 ;
|
||||
.float 0.251407364538 ;
|
||||
.float -1.174275392129 ;
|
||||
.float 1.127696183180 ;
|
||||
.float 0.431959397725 ;
|
||||
.float -1.295878193174 ;
|
||||
.float 1.046006454968 ;
|
||||
.float 0.647485610469 ;
|
||||
.float -1.438041695773 ;
|
||||
.float 0.945459855532 ;
|
||||
.float 0.907400624736 ;
|
||||
.float -1.606018804842 ;
|
||||
.float 0.820295736860 ;
|
||||
.float 1.224540947101 ;
|
||||
.float -1.806917563896 ;
|
||||
.float 0.662418669454 ;
|
||||
.float 1.616794995066 ;
|
||||
.float -2.050569262035 ;
|
||||
.float 0.460162432609 ;
|
||||
.float 2.109729648039 ;
|
||||
.float -2.350920816737 ;
|
||||
.float 0.196211605358 ;
|
||||
.float 2.740985157716 ;
|
||||
.float -2.728353889708 ;
|
||||
.float -0.156051915958 ;
|
||||
.float 3.567962877198 ;
|
||||
.float -3.213722960014 ;
|
||||
.float -0.639321234262 ;
|
||||
.float 4.682006534082 ;
|
||||
.float -3.855770086891 ;
|
||||
.float -1.325757685059 ;
|
||||
.float 6.236312386687 ;
|
||||
.float -4.735651038017 ;
|
||||
.float -2.345709388587 ;
|
||||
.float 8.505488022524 ;
|
||||
.float -5.997790945975 ;
|
||||
.float -3.956059541908 ;
|
||||
.float 12.026617159136 ;
|
||||
.float -7.922628470498 ;
|
||||
.float -6.727400789527 ;
|
||||
.float 17.983705080358 ;
|
||||
.float -11.123941286820;
|
||||
.float -12.170909745654;
|
||||
.float 29.488929624542 ;
|
||||
.float -17.203344479111;
|
||||
.float -25.631911490690;
|
||||
.float 57.466598393615 ;
|
||||
.float -31.741016484669;
|
||||
.float -81.587305009103;
|
||||
.float 171.803399517566;
|
||||
.float -90.149831709374;
|
||||
.float 0.0;
|
||||
.float 0.0;
|
||||
.float 0.0;
|
||||
_CLAacosinTableEnd:
|
||||
|
||||
;; End of File
|
||||
@@ -0,0 +1,157 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAasin.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA arcsine function
|
||||
;;
|
||||
;; Group: C2000
|
||||
;; Target Family: C28x+CLA
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;;
|
||||
;; Step(1): Calculate absolute of the input X
|
||||
;;
|
||||
;; Step(2): Use the upper 6-bits of input "X" value as an
|
||||
;; index into the table to obtain the coefficients
|
||||
;; for a second order equation:
|
||||
;;
|
||||
;; _CLAasinTable:
|
||||
;; CoeffA0[0]
|
||||
;; CoeffA1[0]
|
||||
;; CoeffA2[0]
|
||||
;; .
|
||||
;; .
|
||||
;; CoeffA0[63]
|
||||
;; CoeffA1[63]
|
||||
;; CoeffA2[63]
|
||||
;;
|
||||
;; Step(3): Calculate the angle using the folowing equation:
|
||||
;;
|
||||
;; arctan(Ratio) = A0 + A1*Ratio + A2*Ratio*Ratio
|
||||
;; arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
;;
|
||||
;; Step(4): The final angle is determined as follows:
|
||||
;;
|
||||
;; if( X < 0 )
|
||||
;; Angle = -Angle
|
||||
;;
|
||||
;; Equation: y = asin(x)
|
||||
;;
|
||||
;; Regs Used: MR0, MR1, MR2, MR3 , MAR0,MAR1
|
||||
;;
|
||||
;; Input: x f32 value in memory
|
||||
;;
|
||||
;; Output: y f32 value in memory
|
||||
;; MR0 = y f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 22
|
||||
;; Instructions = 22
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+2)
|
||||
;; |_______|<- asin temporary variable (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
.def _CLAasin
|
||||
.sect "Cla1Prog:_CLAasin"
|
||||
.align 2
|
||||
.def __cla_CLAasin_sp
|
||||
__cla_CLAasin_sp .usect ".scratchpad:Cla1Prog:_CLAasin",4,0,1
|
||||
|
||||
_CLAasin:
|
||||
.asmfunc
|
||||
.asg __cla_CLAasin_sp + 0, _asin_tmp
|
||||
.asg __cla_CLAasin_sp + 2, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
; MR0 = X(fVal) is stored in the scratchpad memory
|
||||
MMOV32 @_asin_tmp, MR0
|
||||
|
||||
; Perform Step (1):
|
||||
MABSF32 MR3,MR0 ; MR3 = abs(X)
|
||||
|
||||
; Perform Step (2):
|
||||
MMPYF32 MR2,MR3,#63.0 ; 64 = Elements In Table (indexed from 0)
|
||||
MF32TOUI16 MR2,MR2 ; MR2 = int(63*x)
|
||||
MADD32 MR2,MR2,MR2 ; MR2 = 2*MR2
|
||||
MADD32 MR1,MR2,MR2 ; MR1 = 4*MR2
|
||||
MADD32 MR2,MR2,MR1 ; MR2 = 6*MR2 this is the index value for the stored data array
|
||||
MMOV16 MAR0,MR2,#_CLAasinTable+4 ; MAR0 points to A2, this will be used in step 4
|
||||
MMOVI16 MAR1,#_CLAasinHalfPITable+2 ; MAR1 points to pi/2, this will be used in step 5
|
||||
MNOP
|
||||
MNOP
|
||||
; Perform Step (3):
|
||||
; arcsin(x) = A0 + x(A1 + A2*x)
|
||||
MMOV32 MR1,*MAR0[#-2]++ ; MR1 = A2
|
||||
MMPYF32 MR1,MR1,MR3 ; MR1 = A2*x
|
||||
|| MMOV32 MR2,*MAR0[#-2]++ ; MR2 = A1
|
||||
|
||||
MADDF32 MR2,MR2,MR1 ; MR2 = A1 + A2*x
|
||||
|| MMOV32 MR1,*MAR0 ; MR1 = A0
|
||||
MMPYF32 MR2,MR2,MR3 ; MR3 = x*(A1 + A2*x)
|
||||
|
||||
MADDF32 MR3,MR1,MR2 ; MR3 = A0 + x*(A1 + A2*x)
|
||||
; Perform Step (4):
|
||||
MMOV32 MR2,@_asin_tmp ; MR2 = x (set/clear NF,ZF)
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MNEGF32 MR3,MR3,LT ; if (X < 0) Angle = -Angle
|
||||
MMOV32 MR0,MR3 ; Store Y = asin(X)
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _asin_tmp
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
@@ -0,0 +1,266 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAasineTable.asm
|
||||
;;
|
||||
;; DESCRIPTION: asine Tables
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
.def _CLAasinHalfPITable
|
||||
.def _CLAasinTable
|
||||
.def _CLAasinTableEnd
|
||||
|
||||
.sect "CLA1mathTables"
|
||||
|
||||
_CLAasinHalfPITable:
|
||||
.float 2.0 ; 2.0
|
||||
.float 1.570796327 ; PI/2
|
||||
|
||||
_CLAasinTable:
|
||||
|
||||
.float 0.0
|
||||
.float 1.0
|
||||
.float 0.0
|
||||
.float 0.000000636202
|
||||
.float 0.999877862610
|
||||
.float 0.007815361896
|
||||
.float 0.000005099694
|
||||
.float 0.999510644409
|
||||
.float 0.015647916155
|
||||
.float 0.000017268312
|
||||
.float 0.998895919094
|
||||
.float 0.023514960332
|
||||
.float 0.000041121765
|
||||
.float 0.998029615282
|
||||
.float 0.031434003631
|
||||
.float 0.000080794520
|
||||
.float 0.996905974725
|
||||
.float 0.039422875916
|
||||
.float 0.000140631089
|
||||
.float 0.995517492804
|
||||
.float 0.047499840611
|
||||
.float 0.000225244584
|
||||
.float 0.993854840311
|
||||
.float 0.055683712914
|
||||
.float 0.000339579512
|
||||
.float 0.991906765146
|
||||
.float 0.063993984848
|
||||
.float 0.000488979852
|
||||
.float 0.989659972212
|
||||
.float 0.072450958820
|
||||
.float 0.000679263611
|
||||
.float 0.987098979366
|
||||
.float 0.081075891529
|
||||
.float 0.000916805182
|
||||
.float 0.984205946802
|
||||
.float 0.089891150305
|
||||
.float 0.001208627040
|
||||
.float 0.980960476685
|
||||
.float 0.098920384204
|
||||
.float 0.001562502549
|
||||
.float 0.977339379243
|
||||
.float 0.108188712551
|
||||
.float 0.001987071928
|
||||
.float 0.973316400729
|
||||
.float 0.117722933997
|
||||
.float 0.002491973784
|
||||
.float 0.968861907789
|
||||
.float 0.127551759665
|
||||
.float 0.003087995053
|
||||
.float 0.963942521723
|
||||
.float 0.137706074532
|
||||
.float 0.003787242692
|
||||
.float 0.958520694794
|
||||
.float 0.148219231941
|
||||
.float 0.004603341138
|
||||
.float 0.952554219267
|
||||
.float 0.159127386977
|
||||
.float 0.005551660294
|
||||
.float 0.945995657913
|
||||
.float 0.170469875522
|
||||
.float 0.006649579796
|
||||
.float 0.938791682505
|
||||
.float 0.182289647088
|
||||
.float 0.007916796475
|
||||
.float 0.930882303984
|
||||
.float 0.194633761132
|
||||
.float 0.009375683410
|
||||
.float 0.922199974574
|
||||
.float 0.207553958472
|
||||
.float 0.011051710808
|
||||
.float 0.912668537890
|
||||
.float 0.221107321885
|
||||
.float 0.012973941175
|
||||
.float 0.902201997769
|
||||
.float 0.235357042896
|
||||
.float 0.015175614174
|
||||
.float 0.890703070035
|
||||
.float 0.250373315541
|
||||
.float 0.017694840102
|
||||
.float 0.878061473098
|
||||
.float 0.266234382514
|
||||
.float 0.020575425537
|
||||
.float 0.864151902887
|
||||
.float 0.283027765009
|
||||
.float 0.023867860513
|
||||
.float 0.848831624374
|
||||
.float 0.300851714968
|
||||
.float 0.027630504055
|
||||
.float 0.831937595031
|
||||
.float 0.319816937941
|
||||
.float 0.031931014547
|
||||
.float 0.813283013821
|
||||
.float 0.340048646894
|
||||
.float 0.036848083955
|
||||
.float 0.792653161200
|
||||
.float 0.361689022958
|
||||
.float 0.042473551274
|
||||
.float 0.769800358920
|
||||
.float 0.384900179460
|
||||
.float 0.048914992206
|
||||
.float 0.744437830278
|
||||
.float 0.409867752228
|
||||
.float 0.056298910750
|
||||
.float 0.716232177740
|
||||
.float 0.436805274317
|
||||
.float 0.064774696786
|
||||
.float 0.684794109766
|
||||
.float 0.465959540059
|
||||
.float 0.074519565699
|
||||
.float 0.649666934178
|
||||
.float 0.497617226179
|
||||
.float 0.085744766889
|
||||
.float 0.610312179660
|
||||
.float 0.532113122767
|
||||
.float 0.098703445606
|
||||
.float 0.566091493186
|
||||
.float 0.569840443472
|
||||
.float 0.113700678529
|
||||
.float 0.516243664372
|
||||
.float 0.611263845480
|
||||
.float 0.131106395009
|
||||
.float 0.459855210927
|
||||
.float 0.656936015611
|
||||
.float 0.151372169232
|
||||
.float 0.395822366759
|
||||
.float 0.707518998893
|
||||
.float 0.175053263659
|
||||
.float 0.322801460177
|
||||
.float 0.763811905770
|
||||
.float 0.202837883870
|
||||
.float 0.239143420888
|
||||
.float 0.826787304376
|
||||
.float 0.235586468765
|
||||
.float 0.142806299514
|
||||
.float 0.897639596948
|
||||
.float 0.274385149825
|
||||
.float 0.031236880585
|
||||
.float 0.977850174820
|
||||
.float 0.320619535938
|
||||
.float -0.098791845166
|
||||
.float 1.069276441800
|
||||
.float 0.376078169620
|
||||
.float -0.251407364538
|
||||
.float 1.174275392129
|
||||
.float 0.443100143614
|
||||
.float -0.431959397725
|
||||
.float 1.295878193174
|
||||
.float 0.524789871827
|
||||
.float -0.647485610469
|
||||
.float 1.438041695773
|
||||
.float 0.625336471263
|
||||
.float -0.907400624736
|
||||
.float 1.606018804842
|
||||
.float 0.750500589935
|
||||
.float -1.224540947101
|
||||
.float 1.806917563896
|
||||
.float 0.908377657341
|
||||
.float -1.616794995066
|
||||
.float 2.050569262035
|
||||
.float 1.110633894185
|
||||
.float -2.109729648039
|
||||
.float 2.350920816737
|
||||
.float 1.374584721437
|
||||
.float -2.740985157716
|
||||
.float 2.728353889708
|
||||
.float 1.726848242753
|
||||
.float -3.567962877198
|
||||
.float 3.213722960014
|
||||
.float 2.210117561056
|
||||
.float -4.682006534082
|
||||
.float 3.855770086891
|
||||
.float 2.896554011854
|
||||
.float -6.236312386687
|
||||
.float 4.735651038017
|
||||
.float 3.916505715382
|
||||
.float -8.505488022524
|
||||
.float 5.997790945975
|
||||
.float 5.526855868703
|
||||
.float -12.026617159136
|
||||
.float 7.922628470498
|
||||
.float 8.298197116322
|
||||
.float -17.983705080358
|
||||
.float 11.123941286820
|
||||
.float 13.741706072449
|
||||
.float -29.488929624542
|
||||
.float 17.203344479111
|
||||
.float 27.202707817485
|
||||
.float -57.466598393615
|
||||
.float 31.741016484669
|
||||
.float 83.158101335898
|
||||
.float -171.803399517566
|
||||
.float 90.149831709374
|
||||
|
||||
.float 1.5707963267948966192313216916398
|
||||
.float 0
|
||||
.float 0
|
||||
|
||||
_CLAasinTableEnd:
|
||||
|
||||
;; End of File
|
||||
@@ -0,0 +1,184 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAatan.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA arctan function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;; Step(1): if( 1.0 >= abs(Y) )
|
||||
;; Numerator = abs(Y)
|
||||
;; Denominator = 1.0
|
||||
;; else
|
||||
;; Numerator = 1.0
|
||||
;; Denominator = abs(Y)
|
||||
;;
|
||||
;; Step(2): Ratio = Numerator/Denominator
|
||||
;;
|
||||
;; Note: Ratio range = 0.0 to 1.0
|
||||
;;
|
||||
;; Step(3): Use the upper 6-bits of the "Ratio" value as an
|
||||
;; index into the table to obtain the coefficients
|
||||
;; for a second order equation:
|
||||
;;
|
||||
;; _FPUatan2Table:
|
||||
;; CoeffA0[0]
|
||||
;; CoeffA1[0]
|
||||
;; CoeffA2[0]
|
||||
;; .
|
||||
;; .
|
||||
;; CoeffA0[63]
|
||||
;; CoeffA1[63]
|
||||
;; CoeffA2[63]
|
||||
;;
|
||||
;; Step(4): Calculate the angle using the folowing equation:
|
||||
;;
|
||||
;; arctan(Ratio) = A0 + A1*Ratio + A2*Ratio*Ratio
|
||||
;; arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
;;
|
||||
;; Step(5): The final angle is determined as follows:
|
||||
;;
|
||||
;; if( Y >= 0 and 1.0 >= abs(Y) )
|
||||
;; Angle = arctan(abs(Y)/1.0)
|
||||
;; if( Y >= 0 and 1.0 < abs(Y) )
|
||||
;; Angle = PI/2 - arctan(1.0/abs(Y))
|
||||
;; if( Y < 0 )
|
||||
;; Angle = -Angle
|
||||
;; Equation: y = atan(x)
|
||||
;;
|
||||
;; Regs Used: MR0, MR1, MR2, MR3 , MAR0,MAR1
|
||||
;;
|
||||
;; Input: x f32 value in memory
|
||||
;;
|
||||
;; Output: y f32 value in memory
|
||||
;; MR0 = y f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 41
|
||||
;; Instructions = 41
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+2)
|
||||
;; |_______|<- atan temporary variable (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAatan
|
||||
.sect "Cla1Prog:_CLAatan"
|
||||
.align 2
|
||||
.def __cla_CLAatan_sp
|
||||
__cla_CLAatan_sp .usect ".scratchpad:Cla1Prog:_CLAatan",4,0,1
|
||||
|
||||
_CLAatan:
|
||||
.asmfunc
|
||||
.asg __cla_CLAatan_sp + 0, _atan_tmp
|
||||
.asg __cla_CLAatan_sp + 2, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
; MR0 = X(fVal) is stored in the scratchpad memory
|
||||
MMOV32 @_atan_tmp, MR0
|
||||
; Perform Step (1):
|
||||
MABSF32 MR3,MR0 ; MR3 = abs(X)
|
||||
MMOVIZ MR1,#0x3f80 ; MR1 = 1.0 , 0x3f800000 = 1.0 in 32 bit Float
|
||||
MMOV32 MR2,MR3 ; Store abs(X) in MR2
|
||||
MMINF32 MR3,MR1 ; MR3 = numerator (A) = min(abs(X),1.0)
|
||||
MMOV32 MR1,MR2,GT ; MR1 = denominator (B) = max(abs(X),1.0)
|
||||
; Ratio = A/B
|
||||
; Perform Step (2):
|
||||
MEINVF32 MR2,MR1 ; MR2 = Ye = Estimate(1/Dinominator) i.e 1/B
|
||||
MTESTTF LEQ ; Set TF if 1.0 >= abs(X) , this will be used in step 5
|
||||
MMPYF32 MR0,MR2,MR1 ; MR0 = Ye*B
|
||||
MSUBF32 MR0,#2.0,MR0 ; MR0 = 2.0 - Ye*B
|
||||
MMPYF32 MR2,MR2,MR0 ; MR2 = Ye = Ye*(2.0 - Ye*B) (first estimate)
|
||||
MMPYF32 MR0,MR2,MR1 ; MR0 = Ye*B
|
||||
MSUBF32 MR0,#2.0,MR0 ; MR0 = 2.0 - Ye*B
|
||||
MMPYF32 MR2,MR2,MR0 ; MR2 = Ye = Ye*(2.0 - Ye*B) (second estimate)
|
||||
MMPYF32 MR0,MR2,MR3 ; MR0 = Ratio = A*Ye = A/B
|
||||
; Perform Step (3):
|
||||
MMPYF32 MR2,MR0,#64.0 ; 64 = Elements In Table
|
||||
MF32TOUI16 MR2,MR2 ; MR2 = int(64*ratio)
|
||||
MADD32 MR2,MR2,MR2 ; MR2 = 2*MR2
|
||||
MADD32 MR1,MR2,MR2 ; MR1 = 4*MR2
|
||||
MADD32 MR2,MR2,MR1 ; MR2 = 6*MR2 this is the index value for the stored data array
|
||||
MMOV16 MAR0,MR2,#_CLAatan2Table+4 ; MAR0 points to A2, this will be used in step 4
|
||||
MMOVI16 MAR1,#_CLAatan2HalfPITable+2 ; MAR1 points to pi/2, this will be used in step 5
|
||||
MNOP
|
||||
MNOP
|
||||
; Perform Step (4):
|
||||
; arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
MMOV32 MR1,*MAR0[#-2]++ ; MR1 = A2
|
||||
MMPYF32 MR1,MR1,MR0 ; MR1 = A2*Ratio
|
||||
|| MMOV32 MR3,*MAR0[#-2]++ ; MR3 = A1
|
||||
MADDF32 MR3,MR3,MR1 ; MR3 = A1 + A2*Ratio
|
||||
|| MMOV32 MR1,*MAR0 ; MR1 = A0
|
||||
MMPYF32 MR3,MR3,MR0 ; MR3 = Ratio*(A1 + A2*Ratio)
|
||||
MADDF32 MR3,MR1,MR3 ; MR3 = A0 + Ratio*(A1 + A2*Ratio)
|
||||
; Perform Step (5):
|
||||
MMOVIZ MR0,#0.0
|
||||
MMOV32 MR1,*MAR1 ; MR1 = pi/2
|
||||
MNEGF32 MR3, MR3, UNC ; MR3 = flip sign of atan(Ratio)
|
||||
MNEGF32 MR3, MR3, TF ; if (1.0 >= abs(Y)) flip sign of atan(Ratio)
|
||||
MMOV32 MR2,@_atan_tmp ; MR2 = Y (set/clear NF,ZF)
|
||||
MMOV32 MR0, MR1, NTF ; if(1.0 < abs(Y) MR0 = pi/2, else MR0 = 0.0
|
||||
MADDF32 MR3, MR3, MR0 ; MR3 = Angle
|
||||
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MNEGF32 MR3,MR3,LT ; if (Y < 0) Angle = -Angle
|
||||
MMOV32 MR0,MR3 ; Store Y = atan(X)
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _atan_tmp
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
@@ -0,0 +1,203 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAatan2.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA arctan2 function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;; The algorithm steps to calculate the "atan2" of the given
|
||||
;; input X and Y is as follows:
|
||||
;;
|
||||
;; Step(1): if( abs(X) >= abs(Y) )
|
||||
;; Numerator = abs(Y)
|
||||
;; Denominator = abs(X)
|
||||
;; else
|
||||
;; Numerator = abs(X)
|
||||
;; Denominator = abs(Y)
|
||||
;;
|
||||
;; Step(2): Ratio = Numerator/Denominator
|
||||
;;
|
||||
;; Note: Ratio range = 0.0 to 1.0
|
||||
;;
|
||||
;; Step(3): Use the upper 6-bits of the "Ratio" value as an
|
||||
;; index into the table to obtain the coefficients
|
||||
;; for a second order equation:
|
||||
;;
|
||||
;; _FPUatan2Table:
|
||||
;; CoeffA0[0]
|
||||
;; CoeffA1[0]
|
||||
;; CoeffA2[0]
|
||||
;; .
|
||||
;; .
|
||||
;; CoeffA0[63]
|
||||
;; CoeffA1[63]
|
||||
;; CoeffA2[63]
|
||||
;;
|
||||
;; Step(4): Calculate the angle using the folowing equation:
|
||||
;;
|
||||
;; arctan(Ratio) = A0 + A1*Ratio + A2*Ratio*Ratio
|
||||
;; arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
;;
|
||||
;; Step(5): The final angle is determined as follows:
|
||||
;;
|
||||
;; if( X >= 0 and Y >= 0 and abs(X) >= abs(Y) )
|
||||
;; Angle = arctan(abs(Y)/abs(X))
|
||||
;; if( X >= 0 and Y >= 0 and abs(X) < abs(Y) )
|
||||
;; Angle = PI/2 - arctan(abs(X)/abs(Y))
|
||||
;; if( X < 0 and Y >= 0 and abs(X) < abs(Y) )
|
||||
;; Angle = PI/2 + arctan(abs(X)/abs(Y))
|
||||
;; if( X < 0 and Y >= 0 and abs(X) >= abs(Y) )
|
||||
;; Angle = PI - arctan(abs(Y)/abs(X))
|
||||
;; if( Y < 0 )
|
||||
;; Angle = -Angle
|
||||
;; Equation: z = atan(y/x)
|
||||
;;
|
||||
;; Regs Used: MR0, MR1, MR2, MR3, MAR0,MAR1
|
||||
;;
|
||||
;; Input: x , y two f32 values in memory
|
||||
;;
|
||||
;; Output: z f32 value in memory
|
||||
;; MR0 = z f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 44
|
||||
;; Instructions = 44
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+4)
|
||||
;; |_______|<- atan2 temporary variable 2 (SP+2)
|
||||
;; |_______|<- atan2 temporary variable 1 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAatan2
|
||||
.sect "Cla1Prog:_CLAatan2"
|
||||
.align 2
|
||||
.def __cla_CLAatan2_sp
|
||||
__cla_CLAatan2_sp .usect ".scratchpad:Cla1Prog:_CLAatan2",6,0,1
|
||||
|
||||
_CLAatan2:
|
||||
.asmfunc
|
||||
.asg __cla_CLAatan2_sp + 0, _atan2_tmp1
|
||||
.asg __cla_CLAatan2_sp + 2, _atan2_tmp2
|
||||
.asg __cla_CLAatan2_sp + 4, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
; MR0 = Y(fVal1) and MR1 = X(fVal2) is stored in the
|
||||
; scratchpad memory
|
||||
MMOV32 @_atan2_tmp1,MR0 ;Y
|
||||
MMOV32 @_atan2_tmp2,MR1 ;X
|
||||
; Perform Step (1):
|
||||
MABSF32 MR3,MR0 ; MR3 = abs(Y)
|
||||
MMOV32 MR2,MR3 ; Store abs(Y) in MR2
|
||||
MABSF32 MR1,MR1 ; Store abs(X) in MR1
|
||||
MMINF32 MR3,MR1 ; MR3 = numerator (A) = min(abs(Y),abs(X))
|
||||
MMOV32 MR1,MR2,GT ; MR1 = denominator (B) = max(abs(Y),abs(X))
|
||||
; Ratio = A/B
|
||||
; Perform Step (2):
|
||||
MEINVF32 MR2,MR1 ; MR2 = Ye = Estimate(1/Denominator) i.e 1/B
|
||||
MTESTTF LEQ ; Set TF if 1.0 >= abs(X) , this will be used in step 5
|
||||
MMPYF32 MR0,MR2,MR1 ; MR0 = Ye*B
|
||||
MSUBF32 MR0,#2.0,MR0 ; MR0 = 2.0 - Ye*B
|
||||
MMPYF32 MR2,MR2,MR0 ; MR2 = Ye = Ye*(2.0 - Ye*B) (first estimate)
|
||||
MMPYF32 MR0,MR2,MR1 ; MR0 = Ye*B
|
||||
MSUBF32 MR0,#2.0,MR0 ; MR0 = 2.0 - Ye*B
|
||||
MMPYF32 MR2,MR2,MR0 ; MR2 = Ye = Ye*(2.0 - Ye*B) (second estimate)
|
||||
MMPYF32 MR0,MR2,MR3 ; MR0 = Ratio = A*Ye = A/B
|
||||
; Perform Step (3):
|
||||
MMPYF32 MR2,MR0,#64.0 ; 64 = Elements In Table
|
||||
MF32TOUI16 MR2,MR2 ; MR2 = int(64*ratio)
|
||||
MADD32 MR2,MR2,MR2 ; MR2 = 2*MR2
|
||||
MADD32 MR1,MR2,MR2 ; MR1 = 4*MR2
|
||||
MADD32 MR2,MR2,MR1 ; MR2 = 6*MR2 this is the index value for the stored data array
|
||||
MMOV16 MAR0,MR2,#_CLAatan2Table+4 ; MAR0 points to A2, this will be used in step 4
|
||||
MMOVI16 MAR1,#_CLAatan2HalfPITable+2 ; MAR1 points to pi/2, this will be used in step 5
|
||||
MNOP
|
||||
MNOP
|
||||
; Perform Step (4):
|
||||
; arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
MMOV32 MR1,*MAR0[#-2]++ ; MR1 = A2
|
||||
MMPYF32 MR1,MR1,MR0 ; MR1 = A2*Ratio
|
||||
|| MMOV32 MR3,*MAR0[#-2]++ ; MR3 = A1
|
||||
MADDF32 MR3,MR3,MR1 ; MR3 = A1 + A2*Ratio
|
||||
|| MMOV32 MR1,*MAR0 ; MR1 = A0
|
||||
MMPYF32 MR3,MR3,MR0 ; MR3 = Ratio*(A1 + A2*Ratio)
|
||||
MADDF32 MR3,MR1,MR3 ; MR3 = A0 + Ratio*(A1 + A2*Ratio)
|
||||
|| MMOV32 MR2,@_atan2_tmp2 ; MR2 = X (set/clear NF,ZF for use below)
|
||||
; Perform Step (5):
|
||||
MMOV32 MR1,*MAR1,UNC ; MR1 = pi/2 (no flag change)
|
||||
MNEGF32 MR0,MR1,UNC ; MR0 = -pi/2 (no flag change)
|
||||
MMOV32 MR3,MR2,EQ ; if (X == 0), MR3 = 0
|
||||
MNEGF32 MR3,MR3,GEQ ; if (X >= 0) MR3 flip sign of atan(Ratio)
|
||||
MNEGF32 MR3,MR3,TF ; if (abs(X) >= abs(Y)) flip sign of atan(Ratio)
|
||||
|
||||
MNEGF32 MR0,MR0,LT ; if (X < 0) MR0 = pi/2
|
||||
MADDF32 MR0,MR0,MR1 ; MR0 = MR0+pi/2
|
||||
; if(X < 0) MR0 = pi
|
||||
; if(X > 0) MR0 = 0
|
||||
|| MMOV32 MR2,@_atan2_tmp1 ; MR2 = Y (set/clear NF,ZF)
|
||||
MMOV32 MR0,MR1,NTF ; if(abs(X) < abs(Y) R3H = pi/2
|
||||
MADDF32 MR3,MR3,MR0 ; MR3 = Angle
|
||||
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MNEGF32 MR3,MR3,LT ; if (Y < 0) Angle = -Angle
|
||||
MMOV32 MR0,MR3 ; Store Y = atan2(X)
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _atan2_tmp1
|
||||
.unasg _atan2_tmp2
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
@@ -0,0 +1,209 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAatan2PU.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA arctan2 Per Unit function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;; The algorithm steps to calculate the "atan2" of the given
|
||||
;; input X and Y is as follows:
|
||||
;;
|
||||
;; Step(1): if( abs(X) >= abs(Y) )
|
||||
;; Numerator = abs(Y)
|
||||
;; Denominator = abs(X)
|
||||
;; else
|
||||
;; Numerator = abs(X)
|
||||
;; Denominator = abs(Y)
|
||||
;;
|
||||
;; Step(2): Ratio = Numerator/Denominator
|
||||
;;
|
||||
;; Note: Ratio range = 0.0 to 1.0
|
||||
;;
|
||||
;; Step(3): Use the upper 6-bits of the "Ratio" value as an
|
||||
;; index into the table to obtain the coefficients
|
||||
;; for a second order equation:
|
||||
;;
|
||||
;; _FPUatan2Table:
|
||||
;; CoeffA0[0]
|
||||
;; CoeffA1[0]
|
||||
;; CoeffA2[0]
|
||||
;; .
|
||||
;; .
|
||||
;; CoeffA0[63]
|
||||
;; CoeffA1[63]
|
||||
;; CoeffA2[63]
|
||||
;;
|
||||
;; Step(4): Calculate the angle using the folowing equation:
|
||||
;;
|
||||
;; arctan(Ratio) = A0 + A1*Ratio + A2*Ratio*Ratio
|
||||
;; arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
;;
|
||||
;; Step(5): The final angle is determined as follows:
|
||||
;;
|
||||
;; if( X >= 0 and Y >= 0 and abs(X) >= abs(Y) )
|
||||
;; Angle = arctan(abs(Y)/abs(X))
|
||||
;; if( X >= 0 and Y >= 0 and abs(X) < abs(Y) )
|
||||
;; Angle = PI/2 - arctan(abs(X)/abs(Y))
|
||||
;; if( X < 0 and Y >= 0 and abs(X) < abs(Y) )
|
||||
;; Angle = PI/2 + arctan(abs(X)/abs(Y))
|
||||
;; if( X < 0 and Y >= 0 and abs(X) >= abs(Y) )
|
||||
;; Angle = PI - arctan(abs(Y)/abs(X))
|
||||
;; if( Y < 0 )
|
||||
;; Angle = -Angle
|
||||
;;
|
||||
;; AnglePU =Angle/2pi
|
||||
;;
|
||||
;; Equation: z = { atan(y/x) } / 2pi
|
||||
;;
|
||||
;; Regs Used: MR0, MR1, MR2, MR3, MAR0,MAR1
|
||||
;;
|
||||
;; Input: x , y two f32 values in memory
|
||||
;;
|
||||
;; Output: z f32 value in memory
|
||||
;; MR0 = z f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 46
|
||||
;; Instructions = 46
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+4)
|
||||
;; |_______|<- atan2PU temporary variable 2 (SP+2)
|
||||
;; |_______|<- atan2PU temporary variable 1 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAatan2PU
|
||||
.sect "Cla1Prog:_CLAatan2PU"
|
||||
.align 2
|
||||
.def __cla_CLAatan2PU_sp
|
||||
__cla_CLAatan2PU_sp .usect ".scratchpad:Cla1Prog:_CLAatan2PU",6,0,1
|
||||
|
||||
_CLAatan2PU:
|
||||
.asmfunc
|
||||
.asg __cla_CLAatan2PU_sp + 0, _atan2PU_tmp1
|
||||
.asg __cla_CLAatan2PU_sp + 2, _atan2PU_tmp2
|
||||
.asg __cla_CLAatan2PU_sp + 4, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
; MR0 = Y(fVal1) and MR1 = X(fVal2) is stored in the
|
||||
; scratchpad memory
|
||||
MMOV32 @_atan2PU_tmp1,MR0 ;Y
|
||||
MMOV32 @_atan2PU_tmp2,MR1 ;X
|
||||
; Perform Step (1):
|
||||
MABSF32 MR3,MR0 ; MR3 = abs(Y)
|
||||
MMOV32 MR2,MR3 ; Store abs(Y) in MR2
|
||||
MABSF32 MR1,MR1 ; Store abs(X) in MR1
|
||||
MMINF32 MR3,MR1 ; MR3 = numerator (A) = min(abs(Y),abs(X))
|
||||
MMOV32 MR1,MR2,GT ; MR1 = denominator (B) = max(abs(Y),abs(X))
|
||||
; Ratio = A/B
|
||||
; Perform Step (2):
|
||||
MEINVF32 MR2,MR1 ; MR2 = Ye = Estimate(1/Denominator) i.e 1/B
|
||||
MTESTTF LEQ ; Set TF if 1.0 >= abs(X) , this will be used in step 5
|
||||
MMPYF32 MR0,MR2,MR1 ; MR0 = Ye*B
|
||||
MSUBF32 MR0,#2.0,MR0 ; MR0 = 2.0 - Ye*B
|
||||
MMPYF32 MR2,MR2,MR0 ; MR2 = Ye = Ye*(2.0 - Ye*B) (first estimate)
|
||||
MMPYF32 MR0,MR2,MR1 ; MR0 = Ye*B
|
||||
MSUBF32 MR0,#2.0,MR0 ; MR0 = 2.0 - Ye*B
|
||||
MMPYF32 MR2,MR2,MR0 ; MR2 = Ye = Ye*(2.0 - Ye*B) (second estimate)
|
||||
MMPYF32 MR0,MR2,MR3 ; MR0 = Ratio = A*Ye = A/B
|
||||
; Perform Step (3):
|
||||
MMPYF32 MR2,MR0,#64.0 ; 64 = Elements In Table
|
||||
MF32TOUI16 MR2,MR2 ; MR2 = int(64*ratio)
|
||||
MADD32 MR2,MR2,MR2 ; MR2 = 2*MR2
|
||||
MADD32 MR1,MR2,MR2 ; MR1 = 4*MR2
|
||||
MADD32 MR2,MR2,MR1 ; MR2 = 6*MR2 this is the index value for the stored data array
|
||||
MMOV16 MAR0,MR2,#_CLAatan2Table+4 ; MAR0 points to A2, this will be used in step 4
|
||||
MMOVI16 MAR1,#_CLAatan2HalfPITable+2 ; MAR1 points to pi/2, this will be used in step 5
|
||||
MNOP
|
||||
MNOP
|
||||
; Perform Step (4):
|
||||
; arctan(Ratio) = A0 + Ratio(A1 + A2*Ratio)
|
||||
MMOV32 MR1,*MAR0[#-2]++ ; MR1 = A2
|
||||
MMPYF32 MR1,MR1,MR0 ; MR1 = A2*Ratio
|
||||
|| MMOV32 MR3,*MAR0[#-2]++ ; MR3 = A1
|
||||
MADDF32 MR3,MR3,MR1 ; MR3 = A1 + A2*Ratio
|
||||
|| MMOV32 MR1,*MAR0 ; MR1 = A0
|
||||
MMPYF32 MR3,MR3,MR0 ; MR3 = Ratio*(A1 + A2*Ratio)
|
||||
MADDF32 MR3,MR1,MR3 ; MR3 = A0 + Ratio*(A1 + A2*Ratio)
|
||||
|| MMOV32 MR2,@_atan2PU_tmp2 ; MR2 = X (set/clear NF,ZF for use below)
|
||||
; Perform Step (5):
|
||||
MMOV32 MR1,*MAR1,UNC ; MR1 = pi/2 (no flag change)
|
||||
MNEGF32 MR0,MR1,UNC ; MR0 = -pi/2 (no flag change)
|
||||
MMOV32 MR3,MR2,EQ ; if (X == 0), MR3 = 0
|
||||
MNEGF32 MR3,MR3,GEQ ; if (X >= 0) MR3 flip sign of atan(Ratio)
|
||||
MNEGF32 MR3,MR3,TF ; if (abs(X) >= abs(Y)) flip sign of atan(Ratio)
|
||||
|
||||
MNEGF32 MR0,MR0,LT ; if (X < 0) MR0 = pi/2
|
||||
MADDF32 MR0,MR0,MR1 ; MR0 = MR0+pi/2
|
||||
; if(X < 0) MR0 = pi
|
||||
; if(X > 0) MR0 = 0
|
||||
|| MMOV32 MR2,@_atan2PU_tmp1 ; MR2 = Y (set/clear NF,ZF)
|
||||
MMOV32 MR0,MR1,NTF ; if(abs(X) < abs(Y) R3H = pi/2
|
||||
MADDF32 MR3,MR3,MR0 ; MR3 = Angle
|
||||
MNEGF32 MR3,MR3,LT ; if (Y < 0) Angle = -Angle
|
||||
|
||||
MMOV32 MR1,@_CLAINV2PI ; MR1 = 1/pi*2, this will be used in step 5
|
||||
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MMPYF32 MR3,MR3,MR1 ; MR3= Angle*(1/pi*2)
|
||||
MMOV32 MR0,MR3 ; Store Y = atan2PU(X)
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _atan2PU_tmp1
|
||||
.unasg _atan2PU_tmp2
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
@@ -0,0 +1,273 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAatanTable.asm
|
||||
;;
|
||||
;; DESCRIPTION: atan Tables
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
.def _CLAatan2HalfPITable
|
||||
.def _CLAINV2PI
|
||||
.def _CLAatan2Table
|
||||
.def _CLAatan2TableEnd
|
||||
|
||||
.sect "CLA1mathTables"
|
||||
|
||||
_CLAatan2HalfPITable:
|
||||
.float 2.0 ; 2.0
|
||||
.float 1.570796327 ; PI/2
|
||||
_CLAINV2PI:
|
||||
.float 0.159154943 ;1 / {2*PI}
|
||||
|
||||
_CLAatan2Table:
|
||||
.float 0.000000000000 ; 0 x0 = 0.000000000000 -> a0 = 0.000000000000
|
||||
.float 1.000040679675 ; 0 x1 = 0.007812500000 -> a1 = 1.000040679675
|
||||
.float -0.007811069750 ; 0 x2 = 0.015625000000 -> a2 = -0.007811069750
|
||||
|
||||
.float -0.000003807022 ; 1 x0 = 0.015625000000 -> a0 = -0.000003807022
|
||||
.float 1.000528067772 ; 1 x1 = 0.023437500000 -> a1 = 1.000528067772
|
||||
.float -0.023410345493 ; 1 x2 = 0.031250000000 -> a2 = -0.023410345493
|
||||
|
||||
.float -0.000018968310 ; 2 x0 = 0.031250000000 -> a0 = -0.000018968310
|
||||
.float 1.001498568106 ; 2 x1 = 0.039062500000 -> a1 = 1.001498568106
|
||||
.float -0.038941197075 ; 2 x2 = 0.046875000000 -> a2 = -0.038941197075
|
||||
|
||||
.float -0.000052831927 ; 3 x0 = 0.046875000000 -> a0 = -0.000052831927
|
||||
.float 1.002943680965 ; 3 x1 = 0.054687500000 -> a1 = 1.002943680965
|
||||
.float -0.054358563160 ; 3 x2 = 0.062500000000 -> a2 = -0.054358563160
|
||||
|
||||
.float -0.000112417996 ; 4 x0 = 0.062500000000 -> a0 = -0.000112417996
|
||||
.float 1.004850785788 ; 4 x1 = 0.070312500000 -> a1 = 1.004850785788
|
||||
.float -0.069618206649 ; 4 x2 = 0.078125000000 -> a2 = -0.069618206649
|
||||
|
||||
.float -0.000204295885 ; 5 x0 = 0.078125000000 -> a0 = -0.000204295885
|
||||
.float 1.007203293243 ; 5 x1 = 0.085937500000 -> a1 = 1.007203293243
|
||||
.float -0.084677028723 ; 5 x2 = 0.093750000000 -> a2 = -0.084677028723
|
||||
.float -0.000334469493 ; 6 x0 = 0.093750000000 -> a0 = -0.000334469493
|
||||
.float 1.009980843501 ; 6 x1 = 0.101562500000 -> a1 = 1.009980843501
|
||||
.float -0.099493367628 ; 6 x2 = 0.109375000000 -> a2 = -0.099493367628
|
||||
.float -0.000508272606 ; 7 x0 = 0.109375000000 -> a0 = -0.000508272606
|
||||
.float 1.013159547023 ; 7 x1 = 0.117187500000 -> a1 = 1.013159547023
|
||||
.float -0.114027278430 ; 7 x2 = 0.125000000000 -> a2 = -0.114027278430
|
||||
.float -0.000730276035 ; 8 x0 = 0.125000000000 -> a0 = -0.000730276035
|
||||
.float 1.016712263449 ; 8 x1 = 0.132812500000 -> a1 = 1.016712263449
|
||||
.float -0.128240790343 ; 8 x2 = 0.140625000000 -> a2 = -0.128240790343
|
||||
.float -0.001004207980 ; 9 x0 = 0.140625000000 -> a0 = -0.001004207980
|
||||
.float 1.020608913557 ; 9 x1 = 0.148437500000 -> a1 = 1.020608913557
|
||||
.float -0.142098138715 ; 9 x2 = 0.156250000000 -> a2 = -0.142098138715
|
||||
.float -0.001332888717 ; 10 x0 = 0.156250000000 -> a0 = -0.001332888717
|
||||
.float 1.024816818801 ; 10 x1 = 0.164062500000 -> a1 = 1.024816818801
|
||||
.float -0.155565969259 ; 10 x2 = 0.171875000000 -> a2 = -0.155565969259
|
||||
.float -0.001718180431 ; 11 x0 = 0.171875000000 -> a0 = -0.001718180431
|
||||
.float 1.029301062569 ; 11 x1 = 0.179687500000 -> a1 = 1.029301062569
|
||||
.float -0.168613512667 ; 11 x2 = 0.187500000000 -> a2 = -0.168613512667
|
||||
.float -0.002160952612 ; 12 x0 = 0.187500000000 -> a0 = -0.002160952612
|
||||
.float 1.034024867135 ; 12 x1 = 0.195312500000 -> a1 = 1.034024867135
|
||||
.float -0.181212728329 ; 12 x2 = 0.203125000000 -> a2 = -0.181212728329
|
||||
.float -0.002661063159 ; 13 x0 = 0.203125000000 -> a0 = -0.002661063159
|
||||
.float 1.038949980222 ; 13 x1 = 0.210937500000 -> a1 = 1.038949980222
|
||||
.float -0.193338416410 ; 13 x2 = 0.218750000000 -> a2 = -0.193338416410
|
||||
.float -0.003217354977 ; 14 x0 = 0.218750000000 -> a0 = -0.003217354977
|
||||
.float 1.044037065160 ; 14 x1 = 0.226562500000 -> a1 = 1.044037065160
|
||||
.float -0.204968298146 ; 14 x2 = 0.234375000000 -> a2 = -0.204968298146
|
||||
.float -0.003827667546 ; 15 x0 = 0.234375000000 -> a0 = -0.003827667546
|
||||
.float 1.049246088868 ; 15 x1 = 0.242187500000 -> a1 = 1.049246088868
|
||||
.float -0.216083064706 ; 15 x2 = 0.250000000000 -> a2 = -0.216083064706
|
||||
.float -0.004488862702 ; 16 x0 = 0.250000000000 -> a0 = -0.004488862702
|
||||
.float 1.054536702192 ; 16 x1 = 0.257812500000 -> a1 = 1.054536702192
|
||||
.float -0.226666395507 ; 16 x2 = 0.265625000000 -> a2 = -0.226666395507
|
||||
.float -0.005196863579 ; 17 x0 = 0.265625000000 -> a0 = -0.005196863579
|
||||
.float 1.059868607573 ; 17 x1 = 0.273437500000 -> a1 = 1.059868607573
|
||||
.float -0.236704947279 ; 17 x2 = 0.281250000000 -> a2 = -0.236704947279
|
||||
.float -0.005946705500 ; 18 x0 = 0.281250000000 -> a0 = -0.005946705500
|
||||
.float 1.065201909527 ; 18 x1 = 0.289062500000 -> a1 = 1.065201909527
|
||||
.float -0.246188315613 ; 18 x2 = 0.296875000000 -> a2 = -0.246188315613
|
||||
.float -0.006732597422 ; 19 x0 = 0.296875000000 -> a0 = -0.006732597422
|
||||
.float 1.070497443994 ; 19 x1 = 0.304687500000 -> a1 = 1.070497443994
|
||||
.float -0.255108971022 ; 19 x2 = 0.312500000000 -> a2 = -0.255108971022
|
||||
.float -0.007547992413 ; 20 x0 = 0.312500000000 -> a0 = -0.007547992413
|
||||
.float 1.075717083222 ; 20 x1 = 0.320312500000 -> a1 = 1.075717083222
|
||||
.float -0.263462171840 ; 20 x2 = 0.328125000000 -> a2 = -0.263462171840
|
||||
.float -0.008385665599 ; 21 x0 = 0.328125000000 -> a0 = -0.008385665599
|
||||
.float 1.080824013499 ; 21 x1 = 0.335937500000 -> a1 = 1.080824013499
|
||||
.float -0.271245856476 ; 21 x2 = 0.343750000000 -> a2 = -0.271245856476
|
||||
.float -0.009237797924 ; 22 x0 = 0.343750000000 -> a0 = -0.009237797924
|
||||
.float 1.085782983693 ; 22 x1 = 0.351562500000 -> a1 = 1.085782983693
|
||||
.float -0.278460517693 ; 22 x2 = 0.359375000000 -> a2 = -0.278460517693
|
||||
.float -0.010096064139 ; 23 x0 = 0.359375000000 -> a0 = -0.010096064139
|
||||
.float 1.090560523211 ; 23 x1 = 0.367187500000 -> a1 = 1.090560523211
|
||||
.float -0.285109061650 ; 23 x2 = 0.375000000000 -> a2 = -0.285109061650
|
||||
.float -0.010951723407 ; 24 x0 = 0.375000000000 -> a0 = -0.010951723407
|
||||
.float 1.095125128557 ; 24 x1 = 0.382812500000 -> a1 = 1.095125128557
|
||||
.float -0.291196654447 ; 24 x2 = 0.390625000000 -> a2 = -0.291196654447
|
||||
.float -0.011795711029 ; 25 x0 = 0.390625000000 -> a0 = -0.011795711029
|
||||
.float 1.099447418304 ; 25 x1 = 0.398437500000 -> a1 = 1.099447418304
|
||||
.float -0.296730558920 ; 25 x2 = 0.406250000000 -> a2 = -0.296730558920
|
||||
.float -0.012618729873 ; 26 x0 = 0.406250000000 -> a0 = -0.012618729873
|
||||
.float 1.103500256784 ; 26 x1 = 0.414062500000 -> a1 = 1.103500256784
|
||||
.float -0.301719964310 ; 26 x2 = 0.421875000000 -> a2 = -0.301719964310
|
||||
.float -0.013411340199 ; 27 x0 = 0.421875000000 -> a0 = -0.013411340199
|
||||
.float 1.107258847274 ; 27 x1 = 0.429687500000 -> a1 = 1.107258847274
|
||||
.float -0.306175811325 ; 27 x2 = 0.437500000000 -> a2 = -0.306175811325
|
||||
.float -0.014164046711 ; 28 x0 = 0.437500000000 -> a0 = -0.014164046711
|
||||
.float 1.110700795887 ; 28 x1 = 0.445312500000 -> a1 = 1.110700795887
|
||||
.float -0.310110614947 ; 28 x2 = 0.453125000000 -> a2 = -0.310110614947
|
||||
.float -0.014867381831 ; 29 x0 = 0.453125000000 -> a0 = -0.014867381831
|
||||
.float 1.113806147717 ; 29 x1 = 0.460937500000 -> a1 = 1.113806147717
|
||||
.float -0.313538287176 ; 29 x2 = 0.468750000000 -> a2 = -0.313538287176
|
||||
.float -0.015511984298 ; 30 x0 = 0.468750000000 -> a0 = -0.015511984298
|
||||
.float 1.116557397059 ; 30 x1 = 0.476562500000 -> a1 = 1.116557397059
|
||||
.float -0.316473961655 ; 30 x2 = 0.484375000000 -> a2 = -0.316473961655
|
||||
.float -0.016088672395 ; 31 x0 = 0.484375000000 -> a0 = -0.016088672395
|
||||
.float 1.118939473766 ; 31 x1 = 0.492187500000 -> a1 = 1.118939473766
|
||||
.float -0.318933821948 ; 31 x2 = 0.500000000000 -> a2 = -0.318933821948
|
||||
.float -0.016588511229 ; 32 x0 = 0.500000000000 -> a0 = -0.016588511229
|
||||
.float 1.120939707956 ; 32 x1 = 0.507812500000 -> a1 = 1.120939707956
|
||||
.float -0.320934934991 ; 32 x2 = 0.515625000000 -> a2 = -0.320934934991
|
||||
.float -0.017002873645 ; 33 x0 = 0.515625000000 -> a0 = -0.017002873645
|
||||
.float 1.122547775367 ; 33 x1 = 0.523437500000 -> a1 = 1.122547775367
|
||||
.float -0.322495091022 ; 33 x2 = 0.531250000000 -> a2 = -0.322495091022
|
||||
.float -0.017323494499 ; 34 x0 = 0.531250000000 -> a0 = -0.017323494499
|
||||
.float 1.123755625749 ; 34 x1 = 0.539062500000 -> a1 = 1.123755625749
|
||||
.float -0.323632651068 ; 34 x2 = 0.546875000000 -> a2 = -0.323632651068
|
||||
.float -0.017542518140 ; 35 x0 = 0.546875000000 -> a0 = -0.017542518140
|
||||
.float 1.124557396633 ; 35 x1 = 0.554687500000 -> a1 = 1.124557396633
|
||||
.float -0.324366402860 ; 35 x2 = 0.562500000000 -> a2 = -0.324366402860
|
||||
.float -0.017652539065 ; 36 x0 = 0.562500000000 -> a0 = -0.017652539065
|
||||
.float 1.124949314810 ; 36 x1 = 0.570312500000 -> a1 = 1.124949314810
|
||||
.float -0.324715425833 ; 36 x2 = 0.578125000000 -> a2 = -0.324715425833
|
||||
.float -0.017646635823 ; 37 x0 = 0.578125000000 -> a0 = -0.017646635823
|
||||
.float 1.124929587773 ; 37 x1 = 0.585937500000 -> a1 = 1.124929587773
|
||||
.float -0.324698965683 ; 37 x2 = 0.593750000000 -> a2 = -0.324698965683
|
||||
.float -0.017518398344 ; 38 x0 = 0.593750000000 -> a0 = -0.017518398344
|
||||
.float 1.124498287266 ; 38 x1 = 0.601562500000 -> a1 = 1.124498287266
|
||||
.float -0.324336318787 ; 38 x2 = 0.609375000000 -> a2 = -0.324336318787
|
||||
.float -0.017261948920 ; 39 x0 = 0.609375000000 -> a0 = -0.017261948920
|
||||
.float 1.123657226955 ; 39 x1 = 0.617187500000 -> a1 = 1.123657226955
|
||||
.float -0.323646726613 ; 39 x2 = 0.625000000000 -> a2 = -0.323646726613
|
||||
.float -0.016871957164 ; 40 x0 = 0.625000000000 -> a0 = -0.016871957164
|
||||
.float 1.122409836098 ; 40 x1 = 0.632812500000 -> a1 = 1.122409836098
|
||||
.float -0.322649280139 ; 40 x2 = 0.640625000000 -> a2 = -0.322649280139
|
||||
.float -0.016343649294 ; 41 x0 = 0.640625000000 -> a0 = -0.016343649294
|
||||
.float 1.120761030918 ; 41 x1 = 0.648437500000 -> a1 = 1.120761030918
|
||||
.float -0.321362834119 ; 41 x2 = 0.656250000000 -> a2 = -0.321362834119
|
||||
.float -0.015672812166 ; 42 x0 = 0.656250000000 -> a0 = -0.015672812166
|
||||
.float 1.118717085258 ; 42 x1 = 0.664062500000 -> a1 = 1.118717085258
|
||||
.float -0.319805931024 ; 42 x2 = 0.671875000000 -> a2 = -0.319805931024
|
||||
.float -0.014855792451 ; 43 x0 = 0.671875000000 -> a0 = -0.014855792451
|
||||
.float 1.116285501852 ; 43 x1 = 0.679687500000 -> a1 = 1.116285501852
|
||||
.float -0.317996734279 ; 43 x2 = 0.687500000000 -> a2 = -0.317996734279
|
||||
.float -0.013889491441 ; 44 x0 = 0.687500000000 -> a0 = -0.013889491441
|
||||
.float 1.113474885484 ; 44 x1 = 0.695312500000 -> a1 = 1.113474885484
|
||||
.float -0.315952970460 ; 44 x2 = 0.703125000000 -> a2 = -0.315952970460
|
||||
.float -0.012771355912 ; 45 x0 = 0.703125000000 -> a0 = -0.012771355912
|
||||
.float 1.110294819035 ; 45 x1 = 0.710937500000 -> a1 = 1.110294819035
|
||||
.float -0.313691879968 ; 45 x2 = 0.718750000000 -> a2 = -0.313691879968
|
||||
.float -0.011499365513 ; 46 x0 = 0.718750000000 -> a0 = -0.011499365513
|
||||
.float 1.106755743329 ; 46 x1 = 0.726562500000 -> a1 = 1.106755743329
|
||||
.float -0.311230175714 ; 46 x2 = 0.734375000000 -> a2 = -0.311230175714
|
||||
.float -0.010072017131 ; 47 x0 = 0.734375000000 -> a0 = -0.010072017131
|
||||
.float 1.102868841531 ; 47 x1 = 0.742187500000 -> a1 = 1.102868841531
|
||||
.float -0.308584009287 ; 47 x2 = 0.750000000000 -> a2 = -0.308584009287
|
||||
.float -0.008488306656 ; 48 x0 = 0.750000000000 -> a0 = -0.008488306656
|
||||
.float 1.098645928648 ; 48 x1 = 0.757812500000 -> a1 = 1.098645928648
|
||||
.float -0.305768944066 ; 48 x2 = 0.765625000000 -> a2 = -0.305768944066
|
||||
.float -0.006747708579 ; 49 x0 = 0.765625000000 -> a0 = -0.006747708579
|
||||
.float 1.094099346648 ; 49 x1 = 0.773437500000 -> a1 = 1.094099346648
|
||||
.float -0.302799934724 ; 49 x2 = 0.781250000000 -> a2 = -0.302799934724
|
||||
.float -0.004850153815 ; 50 x0 = 0.781250000000 -> a0 = -0.004850153815
|
||||
.float 1.089241865523 ; 50 x1 = 0.789062500000 -> a1 = 1.089241865523
|
||||
.float -0.299691312610 ; 50 x2 = 0.796875000000 -> a2 = -0.299691312610
|
||||
.float -0.002796006119 ; 51 x0 = 0.796875000000 -> a0 = -0.002796006119
|
||||
.float 1.084086590517 ; 51 x1 = 0.804687500000 -> a1 = 1.084086590517
|
||||
.float -0.296456776409 ; 51 x2 = 0.812500000000 -> a2 = -0.296456776409
|
||||
.float -0.000586037441 ; 52 x0 = 0.812500000000 -> a0 = -0.000586037441
|
||||
.float 1.078646875666 ; 52 x1 = 0.820312500000 -> a1 = 1.078646875666
|
||||
.float -0.293109387609 ; 52 x2 = 0.828125000000 -> a2 = -0.293109387609
|
||||
.float 0.001778597452 ; 53 x0 = 0.828125000000 -> a0 = 0.001778597452
|
||||
.float 1.072936243727 ; 53 x1 = 0.835937500000 -> a1 = 1.072936243727
|
||||
.float -0.289661570229 ; 53 x2 = 0.843750000000 -> a2 = -0.289661570229
|
||||
.float 0.004296386804 ; 54 x0 = 0.843750000000 -> a0 = 0.004296386804
|
||||
.float 1.066968312440 ; 54 x1 = 0.851562500000 -> a1 = 1.066968312440
|
||||
.float -0.286125114351 ; 54 x2 = 0.859375000000 -> a2 = -0.286125114351
|
||||
.float 0.006965487894 ; 55 x0 = 0.859375000000 -> a0 = 0.006965487894
|
||||
.float 1.060756727064 ; 55 x1 = 0.867187500000 -> a1 = 1.060756727064
|
||||
.float -0.282511182960 ; 55 x2 = 0.875000000000 -> a2 = -0.282511182960
|
||||
.float 0.009783753017 ; 56 x0 = 0.875000000000 -> a0 = 0.009783753017
|
||||
.float 1.054315099009 ; 56 x1 = 0.882812500000 -> a1 = 1.054315099009
|
||||
.float -0.278830321668 ; 56 x2 = 0.890625000000 -> a2 = -0.278830321668
|
||||
.float 0.012748755207 ; 57 x0 = 0.890625000000 -> a0 = 0.012748755207
|
||||
.float 1.047656950440 ; 57 x1 = 0.898437500000 -> a1 = 1.047656950440
|
||||
.float -0.275092470943 ; 57 x2 = 0.906250000000 -> a2 = -0.275092470943
|
||||
.float 0.015857813546 ; 58 x0 = 0.906250000000 -> a0 = 0.015857813546
|
||||
.float 1.040795664582 ; 58 x1 = 0.914062500000 -> a1 = 1.040795664582
|
||||
.float -0.271306980411 ; 58 x2 = 0.921875000000 -> a2 = -0.271306980411
|
||||
.float 0.019108017893 ; 59 x0 = 0.921875000000 -> a0 = 0.019108017893
|
||||
.float 1.033744441476 ; 59 x1 = 0.929687500000 -> a1 = 1.033744441476
|
||||
.float -0.267482624928 ; 59 x2 = 0.937500000000 -> a2 = -0.267482624928
|
||||
.float 0.022496252887 ; 60 x0 = 0.937500000000 -> a0 = 0.022496252887
|
||||
.float 1.026516258989 ; 60 x1 = 0.945312500000 -> a1 = 1.026516258989
|
||||
.float -0.263627622089 ; 60 x2 = 0.953125000000 -> a2 = -0.263627622089
|
||||
.float 0.026019221162 ; 61 x0 = 0.953125000000 -> a0 = 0.026019221162
|
||||
.float 1.019123838651 ; 61 x1 = 0.960937500000 -> a1 = 1.019123838651
|
||||
.float -0.259749650860 ; 61 x2 = 0.968750000000 -> a2 = -0.259749650860
|
||||
.float 0.029673465636 ; 62 x0 = 0.968750000000 -> a0 = 0.029673465636
|
||||
.float 1.011579616186 ; 62 x1 = 0.976562500000 -> a1 = 1.011579616186
|
||||
.float -0.255855871106 ; 62 x2 = 0.984375000000 -> a2 = -0.255855871106
|
||||
|
||||
.float 0.033455390838 ; 63 x0 = 0.984375000000 -> a0 = 0.033455390838
|
||||
.float 1.003895716322 ; 63 x1 = 0.992187500000 -> a1 = 1.003895716322
|
||||
.float -0.251952943763 ; 63 x2 = 1.000000000000 -> a2 = -0.251952943763
|
||||
|
||||
.float 0.037361283212 ; 64 x0 = 1.000000000000 -> a0 = 0.037361283212
|
||||
.float 0.996083931611 ; 64 x1 = 1.007812500000 -> a1 = 0.996083931611
|
||||
.float -0.248047051426 ; 64 x2 = 1.015625000000 -> a2 = -0.248047051426
|
||||
_CLAatan2TableEnd:
|
||||
|
||||
;; End of File
|
||||
@@ -0,0 +1,237 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAcos.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA cosine function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description: Implement cosine using taylor series expansion:
|
||||
;;
|
||||
;; rad = K + X
|
||||
;;
|
||||
;; Cos(rad) = Cos(K) - Sin(K)*X
|
||||
;; - Cos(K)*X^2/2!
|
||||
;; + Sin(K)*X^3/3!
|
||||
;; + Cos(K)*X^4/4!
|
||||
;; - Sin(K)*X^5/5!
|
||||
;;
|
||||
;; = Cos(K) + X*(-1.0*Sin(K)
|
||||
;; + X*(-0.5*Cos(K)
|
||||
;; + X*(0.166666*Sin(K)
|
||||
;; + X*(0.04166666*Cos(K)
|
||||
;; + X*(-0.00833333*Sin(K))))))
|
||||
;;
|
||||
;; = Cos(K) + X*(-Sin(K)
|
||||
;; + X*(Coef0*Cos(K)
|
||||
;; + X*(Coef1_pos*Sin(K)
|
||||
;; + X*(Coef2*Cos(K)
|
||||
;; + X*(Coef3_neg*Sin(K))))))
|
||||
;;
|
||||
;;
|
||||
;; Equation: y = Cos(rad)
|
||||
;;
|
||||
;; Regs Used: MR0, MR1, MR2
|
||||
;;
|
||||
;; Input: rad f32 value in memory
|
||||
;;
|
||||
;; // TABLE_SIZE = 128
|
||||
;; CLAsincosTable.Sin0 = 0.0; // sin( 0 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin1 = 0.04906767432742; // sin( 1 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin31 = 0.9987954562052; // sin( 31 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos0 = 1.0; // sin( 32 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin33 = 0.9987954562052; // sin( 33 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin63 = 0.04906767432742; // sin( 63 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin64 = 0.0; // sin( 64 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin65 = -0.04906767432742; // sin( 65 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin95 = -0.9987954562052; // sin( 95 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin96 = -1.0; // sin( 96 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin97 = -0.9987954562052; // sin( 97 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin127 = -0.04906767432742; // sin(127 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos96 = 0.0; // sin( 0 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos97 = 0.04906767432742; // sin( 1 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Cos127 = 0.9987954562052; // sin( 31 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos128 = 1.0; // sin( 32 * 2*pi/TABLE_SIZE)
|
||||
;;
|
||||
;; // TABLE_SIZE/Pi
|
||||
;; // 2*Pi/TABLE_SIZE
|
||||
;; // TABLE_MASK = (TABLE_SIZE*2 - 1) & 0xFFFFFFFE;;
|
||||
;;
|
||||
;; CLAsincosTable.TABLE_SIZEDivPi = 40.74366543152;
|
||||
;; CLAsincosTable.TwoPiDivTABLE_SIZE = 0.04908738521234;
|
||||
;; CLAsincosTable.TABLE_MASK = 0x000000FE;
|
||||
;; CLAsincosTable.Coef0 = -0.5;
|
||||
;; CLAsincosTable.Coef1 = -0.1666666666666;
|
||||
;; CLAsincosTable.Coef1_pos = 0.1666666666666;
|
||||
;; CLAsincosTable.Coef2 = 4.1666666666666e-2;
|
||||
;; CLAsincosTable.Coef3 = 8.3333333333333e-3;
|
||||
;; CLAsincosTable.Coef3_neg = -8.3333333333333e-3;
|
||||
;;
|
||||
;; Output: y f32 value in memory
|
||||
;; MR0 = y f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 28
|
||||
;; Instructions = 28
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAcos
|
||||
.sect "Cla1Prog:_CLAcos"
|
||||
.align 2
|
||||
.def __cla_CLAcos_sp
|
||||
__cla_CLAcos_sp .usect ".scratchpad:Cla1Prog:_CLAcos",2,0,1
|
||||
|
||||
_CLAcos:
|
||||
.asmfunc
|
||||
.asg __cla_CLAcos_sp + 0, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
|
||||
; MR0 = rad(fAngleRad)
|
||||
; MR1 = TABLE_SIZE/(2*Pi)
|
||||
; MR1 = rad*TABLE_SIZE/(2*Pi)
|
||||
; MR2 = TABLE_MASK
|
||||
MMOV32 MR1,@_CLAsincosTable_TABLE_SIZEDivTwoPi
|
||||
MMPYF32 MR1,MR0,MR1
|
||||
|| MMOV32 MR2,@_CLAsincosTable_TABLE_MASK
|
||||
|
||||
; MR3 = K = integer(rad*TABLE_SIZE/(2*Pi))
|
||||
; MR3 = K & TABLE_MASK
|
||||
; MR3 = K * 2
|
||||
; MAR0 = address of Sin(K)
|
||||
; MR1 = frac(TABLE_SIZE*rad/2*Pi)
|
||||
; MR0 = 2*Pi/TABLE_SIZE
|
||||
; MR1 = X = frac(TABLE_SIZE*rad/2*Pi) * (2*Pi/TABLE_SIZE)
|
||||
; MR0 = Coef3_neg
|
||||
MF32TOI32 MR3,MR1
|
||||
MAND32 MR3,MR3,MR2
|
||||
MLSL32 MR3,#1
|
||||
MMOV16 MAR0,MR3,#_CLAsincosTable_Sin0
|
||||
MFRACF32 MR1,MR1
|
||||
MMOV32 MR0,@_CLAsincosTable_TwoPiDivTABLE_SIZE
|
||||
MMPYF32 MR1,MR1,MR0
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef3_neg
|
||||
|
||||
; MR2 = Sin(K)
|
||||
; MR3 = Coef3_neg*Sin(K)
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = X*Coef3_neg*Sin(K)
|
||||
MMOV32 MR2,*MAR0[#+64]++
|
||||
MMPYF32 MR3,MR0,MR2
|
||||
|| MMOV32 MR2,*MAR0[#-64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef2
|
||||
|
||||
; MR2 = Coef2*Cos(K)
|
||||
; MR3 = Coef2*Cos(K) + X*Coef3_neg*Sin(K)
|
||||
; MR2 = Sin(K)
|
||||
; MR3 = X*Coef2*Cos(K) + X^2*Coef3_neg*Sin(K)
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#+64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef1_pos
|
||||
|
||||
; MR2 = Coef1_pos*Sin(K)
|
||||
; MR3 = Coef1_pos*Sin(K) + X*Coef2*Cos(K) + X^2*Coef3_neg*Sin(K)
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = X*Coef1_pos*Sin(K) + X^2*Coef2*Cos(K) + X^3*Coef3_neg*Sin(K)
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#-64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef0
|
||||
|
||||
; MR2 = Coef0*Cos(K)
|
||||
; MR3 = Coef0*Cos(K) + X*Coef1_pos*Sin(K) + X^2*Coef2*Cos(K)
|
||||
; + X^3*Coef3_neg*Sin(K)
|
||||
;
|
||||
; MR2 = Sin(K)
|
||||
; MR3 = X*Coef0*Cos(K) + X^2*Coef1_pos*Sin(K)
|
||||
; + X^3*Coef2*Cos(K) + X^4*Coef3_neg*Sin(K)
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#+64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|
||||
; MR3 = -Sin(K) + X^1*Coef0*Cos(K) + X^2*Coef1_pos*Sin(K)
|
||||
; + X^3*Coef2*Cos(K) + X^4*Coef3_neg*Sin(K)
|
||||
;
|
||||
; MR3 = -X*Sin(K) + X^2*Coef0*Cos(K) + X^3*Coef1_pos*Sin(K)
|
||||
; + X^4*Coef2*Cos(K) + X^5*Coef3_neg*Sin(K)
|
||||
;
|
||||
; MR2 = Cos(K)
|
||||
MSUBF32 MR3,MR3,MR2
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR2,*MAR0[#0]++
|
||||
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
; MR3 = Cos(K) - X*Sin(K) + X^2*Coef0*Cos(K) + X^3*Coef1_pos*Sin(K)
|
||||
; + X^4*Coef2*Cos(K) + X^5*Coef3_neg*Sin(K)
|
||||
; Store Y = Cos(rad)
|
||||
MADDF32 MR3,MR2,MR3
|
||||
MMOV32 MR0,MR3
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
@@ -0,0 +1,241 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAcosPU.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA cosine Per Unit function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description: Implement Cosine using taylor series expansion:
|
||||
;;
|
||||
;; radPU = K + X
|
||||
;;
|
||||
;; rad=radPU * 2 PI
|
||||
;;
|
||||
;; Cos(rad) = Cos(K) - Sin(K)*X
|
||||
;; - Cos(K)*X^2/2!
|
||||
;; + Sin(K)*X^3/3!
|
||||
;; + Cos(K)*X^4/4!
|
||||
;; - Sin(K)*X^5/5!
|
||||
;;
|
||||
;; = Cos(K) + X*(-1.0*Sin(K)
|
||||
;; + X*(-0.5*Cos(K)
|
||||
;; + X*(0.166666*Sin(K)
|
||||
;; + X*(0.04166666*Cos(K)
|
||||
;; + X*(-0.00833333*Sin(K))))))
|
||||
;;
|
||||
;; = Cos(K) + X*(-Sin(K)
|
||||
;; + X*(Coef0*Cos(K)
|
||||
;; + X*(Coef1_pos*Sin(K)
|
||||
;; + X*(Coef2*Cos(K)
|
||||
;; + X*(Coef3_neg*Sin(K))))))
|
||||
;;
|
||||
;;
|
||||
;; Equation: y = Cos(rad)
|
||||
;;
|
||||
;; Regs Used: MR0, MR1, MR2
|
||||
;;
|
||||
;; Input: rad f32 value in memory
|
||||
;;
|
||||
;; // TABLE_SIZE = 128
|
||||
;; CLAsincosTable.Sin0 = 0.0; // sin( 0 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin1 = 0.04906767432742; // sin( 1 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin31 = 0.9987954562052; // sin( 31 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos0 = 1.0; // sin( 32 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin33 = 0.9987954562052; // sin( 33 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin63 = 0.04906767432742; // sin( 63 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin64 = 0.0; // sin( 64 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin65 = -0.04906767432742; // sin( 65 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin95 = -0.9987954562052; // sin( 95 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin96 = -1.0; // sin( 96 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin97 = -0.9987954562052; // sin( 97 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin127 = -0.04906767432742; // sin(127 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos96 = 0.0; // sin( 0 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos97 = 0.04906767432742; // sin( 1 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Cos127 = 0.9987954562052; // sin( 31 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos128 = 1.0; // sin( 32 * 2*pi/TABLE_SIZE)
|
||||
;;
|
||||
;; // TABLE_SIZE/Pi
|
||||
;; // 2*Pi/TABLE_SIZE
|
||||
;; // TABLE_MASK = (TABLE_SIZE*2 - 1) & 0xFFFFFFFE;;
|
||||
;;
|
||||
;; CLAsincosTable.TABLE_SIZE = 128.0;
|
||||
;; CLAsincosTable.TwoPiDivTABLE_SIZE = 0.04908738521234;
|
||||
;; CLAsincosTable.TABLE_MASK = 0x000000FE;
|
||||
;; CLAsincosTable.Coef0 = -0.5;
|
||||
;; CLAsincosTable.Coef1 = -0.1666666666666;
|
||||
;; CLAsincosTable.Coef1_pos = 0.1666666666666;
|
||||
;; CLAsincosTable.Coef2 = 4.1666666666666e-2;
|
||||
;; CLAsincosTable.Coef3 = 8.3333333333333e-3;
|
||||
;; CLAsincosTable.Coef3_neg = -8.3333333333333e-3;
|
||||
;;
|
||||
;; Output: y f32 value in memory
|
||||
;; MR0 = y f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 28
|
||||
;; Instructions = 28
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAcosPU
|
||||
.sect "Cla1Prog:_CLAcosPU"
|
||||
.align 2
|
||||
.def __cla_CLAcosPU_sp
|
||||
__cla_CLAcosPU_sp .usect ".scratchpad:Cla1Prog:_CLAcosPU",2,0,1
|
||||
|
||||
_CLAcosPU:
|
||||
.asmfunc
|
||||
.asg __cla_CLAcosPU_sp + 0, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
|
||||
; MR0 = radPU
|
||||
; MR0=MR0*MR3
|
||||
; MR1 = TABLE_SIZE*Pi/(2*Pi)
|
||||
; MR1 = radPU*TABLE_SIZE*Pi/(2*Pi)
|
||||
; MR2 = TABLE_MASK
|
||||
MMOV32 MR1,@_CLAsincosTable_TABLE_SIZE
|
||||
MMPYF32 MR1,MR0,MR1
|
||||
|| MMOV32 MR2,@_CLAsincosTable_TABLE_MASK
|
||||
|
||||
; MR3 = K = integer(radPU*TABLE_SIZE*Pi/(2*Pi))
|
||||
; MR3 = K & TABLE_MASK
|
||||
; MR3 = K * 2
|
||||
; MAR0 = address of Sin(K)
|
||||
; MR1 = frac(TABLE_SIZE*radPU*Pi/2*Pi)
|
||||
; MR0 = 2*Pi/TABLE_SIZE
|
||||
; MR1 = X = frac(TABLE_SIZE*radPU*Pi/2*Pi) * (2*Pi/TABLE_SIZE)
|
||||
; MR0 = Coef3_neg
|
||||
MF32TOI32 MR3,MR1
|
||||
MAND32 MR3,MR3,MR2
|
||||
MLSL32 MR3,#1
|
||||
MMOV16 MAR0,MR3,#_CLAsincosTable_Sin0
|
||||
MFRACF32 MR1,MR1
|
||||
MMOV32 MR0,@_CLAsincosTable_TwoPiDivTABLE_SIZE
|
||||
MMPYF32 MR1,MR1,MR0
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef3_neg
|
||||
|
||||
; MR2 = Sin(K)
|
||||
; MR3 = Coef3_neg*Sin(K)
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = X*Coef3_neg*Sin(K)
|
||||
MMOV32 MR2,*MAR0[#+64]++
|
||||
MMPYF32 MR3,MR0,MR2
|
||||
|| MMOV32 MR2,*MAR0[#-64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef2
|
||||
|
||||
; MR2 = Coef2*Cos(K)
|
||||
; MR3 = Coef2*Cos(K) + X*Coef3_neg*Sin(K)
|
||||
; MR2 = Sin(K)
|
||||
; MR3 = X*Coef2*Cos(K) + X^2*Coef3_neg*Sin(K)
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#+64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef1_pos
|
||||
|
||||
; MR2 = Coef1_pos*Sin(K)
|
||||
; MR3 = Coef1_pos*Sin(K) + X*Coef2*Cos(K) + X^2*Coef3_neg*Sin(K)
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = X*Coef1_pos*Sin(K) + X^2*Coef2*Cos(K) + X^3*Coef3_neg*Sin(K)
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#-64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef0
|
||||
|
||||
; MR2 = Coef0*Cos(K)
|
||||
; MR3 = Coef0*Cos(K) + X*Coef1_pos*Sin(K) + X^2*Coef2*Cos(K)
|
||||
; + X^3*Coef3_neg*Sin(K)
|
||||
;
|
||||
; MR2 = Sin(K)
|
||||
; MR3 = X*Coef0*Cos(K) + X^2*Coef1_pos*Sin(K)
|
||||
; + X^3*Coef2*Cos(K) + X^4*Coef3_neg*Sin(K)
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#+64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|
||||
; MR3 = -Sin(K) + X^1*Coef0*Cos(K) + X^2*Coef1_pos*Sin(K)
|
||||
; + X^3*Coef2*Cos(K) + X^4*Coef3_neg*Sin(K)
|
||||
;
|
||||
; MR3 = -X*Sin(K) + X^2*Coef0*Cos(K) + X^3*Coef1_pos*Sin(K)
|
||||
; + X^4*Coef2*Cos(K) + X^5*Coef3_neg*Sin(K)
|
||||
;
|
||||
; MR2 = Cos(K)
|
||||
MSUBF32 MR3,MR3,MR2
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR2,*MAR0[#0]++
|
||||
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
; MR3 = Cos(K) - X*Sin(K) + X^2*Coef0*Cos(K) + X^3*Coef1_pos*Sin(K)
|
||||
; + X^4*Coef2*Cos(K) + X^5*Coef3_neg*Sin(K)
|
||||
; Store Y = CosPU(radPU)
|
||||
MADDF32 MR3,MR2,MR3
|
||||
MMOV32 MR0,MR3
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,115 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAdiv.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA divide function using Newton Raphson Approximation
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description: Implement division using Newton-Raphson Method
|
||||
;;
|
||||
;; Equation: Dest = Num/Den
|
||||
;;
|
||||
;; Regs Used: MR0, MR1, MR2, MR3
|
||||
;;
|
||||
;; Input: Num f32 value in memory
|
||||
;; Den f32 value in memory
|
||||
;;
|
||||
;; Output: Dest f32 value in memory
|
||||
;; MR0 = Dest f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 13
|
||||
;; Instructions = 13
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR1 (SP+2)
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAdiv
|
||||
.sect "Cla1Prog:_CLAdiv"
|
||||
.align 2
|
||||
.def __cla_CLAdiv_sp
|
||||
__cla_CLAdiv_sp .usect ".scratchpad:Cla1Prog:_CLAdiv",4,0,1
|
||||
|
||||
_CLAdiv:
|
||||
.asmfunc
|
||||
.asg __cla_CLAdiv_sp + 0, _save_MR3
|
||||
.asg __cla_CLAdiv_sp + 2, _save_MR1
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
|
||||
; MR0 = Numerator
|
||||
; MR1 = Denominator
|
||||
MEINVF32 MR2,MR1 ; MR2 = Ye = Estimate(1/Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
|| MMOV32 @_save_MR1, MR1 ; save off denominator
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
|| MMOV32 MR1, @_save_MR1 ; Reload denominator to set sign
|
||||
MNEGF32 MR0,MR0,EQ ; Optional: if(Den == 0.0) Change Sign Of Num
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MMPYF32 MR0,MR2,MR0 ; MR0 = Y = Ye*Num
|
||||
MMOV32 MR0,MR0 ; Optional: Set/Clear MSTF NF and ZF flags
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.unasg _save_MR1
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,288 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAeabi.asm
|
||||
;;
|
||||
;; DESCRIPTION: This holds the .asg for EABI
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.if __TI_EABI__
|
||||
;
|
||||
; CLAacos
|
||||
;
|
||||
.asg CLAacos,_CLAacos
|
||||
.asg __claCLAacos_sp,__cla_CLAacos_sp
|
||||
.asg __claCLAacos_spc_sp,__cla_CLAacos_spc_sp
|
||||
|
||||
;
|
||||
; CLAacosineTable
|
||||
;
|
||||
.asg CLAacosinTable,_CLAacosinTable
|
||||
.asg CLAacosinTableEnd,_CLAacosinTableEnd
|
||||
.asg CLAacosinHalfPITable,_CLAacosinHalfPITable
|
||||
|
||||
;
|
||||
; CLAasin
|
||||
;
|
||||
.asg CLAasin,_CLAasin
|
||||
.asg __claCLAasin_sp,__cla_CLAsin_sp
|
||||
|
||||
;
|
||||
; CLAasineTable
|
||||
;
|
||||
.asg CLAasinTable, _CLAasinTable
|
||||
.asg CLAasinTableEnd,_CLAasinTableEnd
|
||||
.asg CLAasinHalfPITable, _CLAasinHalfPITable
|
||||
|
||||
;
|
||||
; CLAatan
|
||||
;
|
||||
.asg CLAatan,_CLAatan
|
||||
.asg __claCLAatan_sp,__cla_CLAatan_sp
|
||||
|
||||
;
|
||||
; CLAatan2
|
||||
;
|
||||
.asg CLAatan2,_CLAatan2
|
||||
.asg __claCLAatan2_sp,__cla_CLAatan2_sp
|
||||
|
||||
;
|
||||
; CLAatanPU
|
||||
;
|
||||
|
||||
.asg CLAatan2PU,_CLAatan2PU
|
||||
.asg __claCLAatan2PU_sp,__cla_CLAatan2PU_sp
|
||||
|
||||
;
|
||||
; CLAatanTable
|
||||
;
|
||||
.asg CLAatan2Table, _CLAatan2Table
|
||||
.asg CLAatan2TableEnd,_CLAatan2TableEnd
|
||||
.asg CLAatan2HalfPITable, _CLAatan2HalfPITable
|
||||
.asg CLAINV2PI, _CLAINV2PI
|
||||
|
||||
;
|
||||
; CLAcos
|
||||
;
|
||||
.asg CLAcos,_CLAcos
|
||||
.asg __claCLAcos_sp,__cla_CLAcos_sp
|
||||
|
||||
;
|
||||
; CLAcosPU
|
||||
;
|
||||
.asg CLAcosPU,_CLAcosPU
|
||||
.asg __claCLAcosPU_sp,__cla_CLAcosPU_sp
|
||||
|
||||
;
|
||||
; CLAdiv
|
||||
;
|
||||
.asg CLAdiv,_CLAdiv
|
||||
.asg __claCLAdiv_sp,__cla_CLAdiv_sp
|
||||
|
||||
;
|
||||
; CLAexp
|
||||
;
|
||||
.asg CLAexp,_CLAexp
|
||||
.asg __claCLAexp_sp,__cla_CLAexp_sp
|
||||
|
||||
;
|
||||
; CLAexp2
|
||||
;
|
||||
.asg CLAexp2,_CLAexp2
|
||||
.asg __claCLAexp2_sp,__cla_CLAexp2_sp
|
||||
|
||||
;
|
||||
; CLAexp10
|
||||
;
|
||||
.asg CLAexp10,_CLAexp10
|
||||
.asg __claCLAexp10_sp,__cla_CLAexp10_sp
|
||||
|
||||
;
|
||||
; CLAexpN
|
||||
;
|
||||
.asg CLAexpN,_CLAexpN
|
||||
.asg __claCLAexpN_sp,__cla_CLAexpN_sp
|
||||
|
||||
;
|
||||
; CLAexpTable
|
||||
;
|
||||
.asg CLAExpTable, _CLAExpTable
|
||||
.asg CLAExpTableEnd,_CLAExpTableEnd
|
||||
.asg CLAINV1,_CLAINV1
|
||||
.asg CLAINV2,_CLAINV2
|
||||
.asg CLAINV3,_CLAINV3
|
||||
.asg CLAINV4,_CLAINV4
|
||||
.asg CLAINV5,_CLAINV5
|
||||
.asg CLAINV6,_CLAINV6
|
||||
.asg CLAINV7,_CLAINV7
|
||||
.asg CLALOG10,_CLALOG10
|
||||
|
||||
;
|
||||
; CLAisqrt
|
||||
;
|
||||
.asg CLAisqrt,_CLAisqrt
|
||||
.asg __claCLAisqrt_sp,__cla_CLAisqrt_sp
|
||||
|
||||
;
|
||||
; CLAln
|
||||
;
|
||||
.asg CLAln,_CLAln
|
||||
.asg __claCLAln_sp,__cla_CLAln_sp
|
||||
|
||||
;
|
||||
; CLAlnTable
|
||||
;
|
||||
.asg CLALNV2,_CLALNV2
|
||||
.asg CLALNVe,_CLALNVe
|
||||
.asg CLALNV10,_CLALNV10
|
||||
.asg CLABIAS,_CLABIAS
|
||||
.asg CLALN_TABLE_MASK1,_CLALN_TABLE_MASK1
|
||||
.asg CLALN_TABLE_MASK2,_CLALN_TABLE_MASK2
|
||||
.asg CLALnTable,_CLALnTable
|
||||
.asg CLALnTableEnd,_CLALnTableEnd
|
||||
|
||||
;
|
||||
; CLAlog10
|
||||
;
|
||||
.asg CLAlog10,_CLAlog10
|
||||
.asg __claCLAlog10_sp,__cla_CLAlog10_sp
|
||||
|
||||
;
|
||||
; CLAlogN
|
||||
;
|
||||
.asg CLAlogN,_CLAlogN
|
||||
.asg __claCLAlogN_sp,__cla_CLAlogN_sp
|
||||
|
||||
;
|
||||
; CLAsin
|
||||
;
|
||||
.asg CLAsin,_CLAsin
|
||||
.asg __claCLAsin_sp,__cla_CLAsin_sp
|
||||
|
||||
;
|
||||
; CLAsincos
|
||||
;
|
||||
.asg CLAsincos,_CLAsincos
|
||||
.asg __claCLAsincos_sp,__cla_CLAsincos_sp
|
||||
|
||||
;
|
||||
; CLAsincosTable
|
||||
;
|
||||
.asg CLAsincosTable,_CLAsincosTable
|
||||
.asg CLAsinTable,_CLAsinTable
|
||||
.asg CLAsincosTable_Sin0,_CLAsincosTable_Sin0
|
||||
.asg CLAcosTable,_CLAcosTable
|
||||
.asg CLAsincosTable_Cos0,_CLAsincosTable_Cos0
|
||||
.asg CLAsinTableEnd,_CLAsinTableEnd
|
||||
.asg CLAcosTableEnd,_CLAcosTableEnd
|
||||
.asg CLAsincosTable_TABLE_SIZE,_CLAsincosTable_TABLE_SIZE
|
||||
.asg CLAsincosTable_TABLE_SIZEDivTwoPi,_CLAsincosTable_TABLE_SIZEDivTwoPi
|
||||
.asg CLAsincosTable_TwoPiDivTABLE_SIZE,_CLAsincosTable_TwoPiDivTABLE_SIZE
|
||||
.asg CLAsincosTable_TABLE_MASK,_CLAsincosTable_TABLE_MASK
|
||||
.asg CLAsincosTable_Coef0,_CLAsincosTable_Coef0
|
||||
.asg CLAsincosTable_Coef1,_CLAsincosTable_Coef1
|
||||
.asg CLAsincosTable_Coef1_pos,_CLAsincosTable_Coef1_pos
|
||||
.asg CLAsincosTable_Coef2,_CLAsincosTable_Coef2
|
||||
.asg CLAsincosTable_Coef3,_CLAsincosTable_Coef3
|
||||
.asg CLAsincosTable_Coef3_neg,_CLAsincosTable_Coef3_neg
|
||||
.asg CLAsincosTableEnd,_CLAsincosTableEnd
|
||||
|
||||
;
|
||||
; CLAsinPU
|
||||
;
|
||||
.asg CLAsinPU,_CLAsinPU
|
||||
.asg __claCLAsinPU_sp,__cla_CLAsinPU_sp
|
||||
|
||||
;
|
||||
; CLAsqrt
|
||||
;
|
||||
.asg CLAsqrt,_CLAsqrt
|
||||
.asg __claCLAsqrt_sp,__cla_CLAsqrt_sp
|
||||
|
||||
;
|
||||
; FFT
|
||||
;
|
||||
.asg CLA_CFFT_run256Pt, _CLA_CFFT_run256Pt
|
||||
.asg CLA_CFFT_run1024Pt, _CLA_CFFT_run1024Pt
|
||||
.asg CLA_CFFT_run512Pt, _CLA_CFFT_run512Pt
|
||||
.asg CLA_CFFT_unpack256Pt, _CLA_CFFT_unpack256Pt
|
||||
.asg CLA_CFFT_unpack512Pt, _CLA_CFFT_unpack512Pt
|
||||
.asg cla_twiddleFactors, _cla_twiddleFactors
|
||||
.asg cla_bitReversalTable, _cla_bitReversalTable
|
||||
.asg IOBuffer, _IOBuffer
|
||||
.asg IOBuffer2, _IOBuffer2
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.endif
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAexp.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA Exponent function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;; Step(1): Calculate absolute of x
|
||||
;;
|
||||
;; Step(2): Identify the integer and mantissa of the input
|
||||
;;
|
||||
;; Step(3): Obtain the e^integer(x) from the table
|
||||
;;
|
||||
;; Step(4): Calculate the value of e^(mantissa)by using the
|
||||
;; polynomial approx = 1 + x*(1+x*0.5(1+(x/3)(1+x/4(1+x/5*(1+x/6*(1+x/7))))))
|
||||
;;
|
||||
;; Step(5): The value of e^x is the product of results from (3)&(4)
|
||||
;;
|
||||
;;
|
||||
;; Benchmark: Cycles = 41
|
||||
;; Instructions = 41
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- exponent temporary variable (SP+2)
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAexp
|
||||
.sect "Cla1Prog:_CLAexp"
|
||||
.align 2
|
||||
.def __cla_CLAexp_sp
|
||||
__cla_CLAexp_sp .usect ".scratchpad:Cla1Prog:_CLAexp",4,0,1
|
||||
|
||||
_CLAexp:
|
||||
.asmfunc
|
||||
.asg __cla_CLAexp_sp + 0, _save_MR3
|
||||
.asg __cla_CLAexp_sp + 2, _exp_tmp
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
; The input argument fVal is refered to as X
|
||||
; save input argument on scratchpad
|
||||
MMOV32 @_exp_tmp,MR0
|
||||
; Step 1
|
||||
MMOV32 MR3,MR0 ; Load argument into MR3
|
||||
MABSF32 MR3,MR3 ; LOAD |X| TO MR3
|
||||
|
||||
; Step 2
|
||||
MF32TOI32 MR0,MR3 ; MR0 = INTEGER(X)
|
||||
MFRACF32 MR1,MR3 ; MR1 = MANTISSA(X)
|
||||
; Step 3
|
||||
MADD32 MR2,MR0,MR0
|
||||
MMOV16 MAR1,MR2,#_CLAExpTable
|
||||
|
||||
; Step 3
|
||||
MMOV32 MR2,@_CLAINV7 ; MR2 = 1/7
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Xm/7
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 =(1+Xm/7)
|
||||
MMOV32 MR2,@_CLAINV6 ; MR2 = 1/6
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+Xm/7)
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+Xm/7)/6
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/6)*(1+Xm/7)
|
||||
|| MMOV32 MR0,*MAR1 ; MR0 = e^(INTEGER(X))
|
||||
MMOV32 MR2,@_CLAINV5 ; MR2 = .2
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+Xm/6*(1+Xm/7))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+Xm/6*(1+Xm/7))/5
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/5)*(1+Xm/6*(1+Xm/7))
|
||||
MMOV32 MR2,@_CLAINV4 ; MR2 = .25
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+Xm/5*(1+Xm/6*(1+Xm/7)))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+Xm/5*(1+Xm/6*(1+Xm/7)))/4
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))
|
||||
MMOV32 MR2,@_CLAINV3 ; MR2 = .3333333
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+(Xm/4)*(1+Xm/5)*(1+Xm/6*(1+Xm/7)))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+(Xm/4)*(1+Xm/5)*(1+Xm/6*(1+Xm/7)))*0.333333
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7))))
|
||||
MMOV32 MR2,@_CLAINV2 ; MR2 = .5
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))*0.5
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))Xm/2
|
||||
MMPYF32 MR3,MR3,MR1 ; MR3 = Xm(1+(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))Xm/2)
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = e^(MANTISSA)= 1+Xm(1+(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6)*(1+Xm/7))))Xm/2)
|
||||
; Step 4
|
||||
MMPYF32 MR3,MR3,MR0 ; MR3 = e^(MANTISSA) x e^(INTEGER(X))
|
||||
MMOV32 MR1,MR3,UNC
|
||||
; Calculation of e^-x
|
||||
MEINVF32 MR2,MR1 ; MR2 = Ye = Estimate(1/Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
|| MMOV32 MR0,@_exp_tmp ; MR2 = X (set/clear NF,ZF)
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MMOV32 MR1,MR2,LT ; update e^X with inverse value
|
||||
MMOV32 MR0,MR1 ; Store result in MR0
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.unasg _exp_tmp
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAexp10.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA Base 10 Exponent function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;; Step(1): Calculate absolute of x/LOG10(e) (or x*LN(10))
|
||||
;;
|
||||
;; Step(2): Identify the integer and mantissa of the input
|
||||
;;
|
||||
;; Step(3): Obtain the e^integer(x) from the table
|
||||
;;
|
||||
;; Step(4): Calculate the value of e^(mantissa)by using the polynomial
|
||||
;; approxiamation,
|
||||
;; 1 + x*(1+x*0.5(1+(x/3)(1+x/4*(1+Xm/5*(1+Xm/6*(1+Xm/7))))))
|
||||
;;
|
||||
;; Step(5): The value of e^x is the product of results from (3)&(4)
|
||||
;;
|
||||
;;
|
||||
;; Benchmark: Cycles = 43
|
||||
;; Instructions = 43
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- exponent10 temporary variable (SP+2)
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAexp10
|
||||
.sect "Cla1Prog:_CLAexp10"
|
||||
.align 2
|
||||
.def __cla_CLAexp10_sp
|
||||
__cla_CLAexp10_sp .usect ".scratchpad:Cla1Prog:_CLAexp10",4,0,1
|
||||
|
||||
_CLAexp10:
|
||||
.asmfunc
|
||||
.asg __cla_CLAexp10_sp + 0, _save_MR3
|
||||
.asg __cla_CLAexp10_sp + 2, _exp10_tmp
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
; The input argument fVal is refered to as X
|
||||
; save input argument on scratchpad
|
||||
MMOV32 @_exp10_tmp,MR0
|
||||
; Step 1
|
||||
MMOV32 MR3,MR0 ;
|
||||
MMOV32 MR1,@_CLALOG10 ;
|
||||
MMPYF32 MR3,MR3,MR1 ; X = INPUT/LOG10(e) or INPUT*LN(10)
|
||||
MABSF32 MR3,MR3 ; LOAD |X| TO MR3
|
||||
; Step 2
|
||||
MF32TOI32 MR0,MR3 ; MR0 = INTEGER(X)
|
||||
MFRACF32 MR1,MR3 ; MR1 = MANTISSA(X)
|
||||
; Step 3
|
||||
MADD32 MR2,MR0,MR0
|
||||
MMOV16 MAR1,MR2,#_CLAExpTable
|
||||
|
||||
; Step 4
|
||||
MMOV32 MR2,@_CLAINV7 ; MR2 = 1/7
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Xm/7
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 =(1+Xm/7)
|
||||
MMOV32 MR2,@_CLAINV6 ; MR2 = 1/6
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+Xm/7)
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+Xm/7)/6
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/6)*(1+Xm/7)
|
||||
|| MMOV32 MR0,*MAR1 ; MR0 = e^(INTEGER(X))
|
||||
MMOV32 MR2,@_CLAINV5 ; MR2 = .2
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+Xm/6*(1+Xm/7))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+Xm/6*(1+Xm/7))/5
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/5)*(1+Xm/6*(1+Xm/7))
|
||||
MMOV32 MR2,@_CLAINV4 ; MR2 = .25
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+Xm/5*(1+Xm/6*(1+Xm/7)))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+Xm/5*(1+Xm/6*(1+Xm/7)))/4
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))
|
||||
MMOV32 MR2,@_CLAINV3 ; MR2 = .3333333
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+(Xm/4)*(1+Xm/5)*(1+Xm/6*(1+Xm/7)))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+(Xm/4)*(1+Xm/5)*(1+Xm/6*(1+Xm/7)))/3
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7))))
|
||||
MMOV32 MR2,@_CLAINV2 ; MR2 = .5
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))*0.5
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))Xm/2
|
||||
MMPYF32 MR3,MR3,MR1 ; MR3 = Xm(1+(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))Xm/2)
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = e^(Xm)= 1+Xm(1+(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))Xm/2)
|
||||
; Step 5
|
||||
MMPYF32 MR3,MR3,MR0 ; MR3 = e^(MANTISSA) x e^(INTEGER(X))
|
||||
MMOV32 MR1,MR3,UNC
|
||||
; Calculation of e^-x
|
||||
MEINVF32 MR2,MR1 ; MR2 = Ye = Estimate(1/Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
|| MMOV32 MR0,@_exp10_tmp ; MR2 = X (set/clear NF,ZF)
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MMOV32 MR1,MR2,LT ; update e^X with inverse value
|
||||
MMOV32 MR0,MR1 ; Store Y = e^(X)
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.unasg _exp10_tmp
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAexp2.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA Exponential of Ratio function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;; Step(1): Calculate absolute of x=A/B
|
||||
;;
|
||||
;; Step(2): Identify the integer and mantissa of the input
|
||||
;;
|
||||
;; Step(3): Obtain the e^integer(x) from the table
|
||||
;;
|
||||
;; Step(4): Calculate the value of e^(mantissa)by using the polynomial
|
||||
;; approximation,
|
||||
;; 1 + x*(1+x*0.5(1+(x/3)(1+x/4(1+X/5*(1+Xm/6*(1+Xm/7))))))
|
||||
;;
|
||||
;; Step(5): The value of e^x is the product of results from (3)&(4)
|
||||
;;
|
||||
;;
|
||||
;; Benchmark: Cycles = 53
|
||||
;; Instructions = 53
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- exponent temporary variable 2 (SP+4)
|
||||
;; |_______|<- exponent temporary variable 1 (SP+2)
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAexp2
|
||||
.sect "Cla1Prog:_CLAexp2"
|
||||
.align 2
|
||||
.def __cla_CLAexp2_sp
|
||||
__cla_CLAexp2_sp .usect ".scratchpad:Cla1Prog:_CLAexp2",6,0,1
|
||||
|
||||
_CLAexp2:
|
||||
.asmfunc
|
||||
.asg __cla_CLAexp2_sp + 4, _exp2_tmp2
|
||||
.asg __cla_CLAexp2_sp + 2, _exp2_tmp1
|
||||
.asg __cla_CLAexp2_sp + 0, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
; The input arguments fVal1,fVal2 referred to as A,B repectively
|
||||
; save input argument on scratchpad
|
||||
MMOV32 @_exp2_tmp1,MR0
|
||||
MMOV32 @_exp2_tmp2,MR1
|
||||
; Step 1
|
||||
MEINVF32 MR2,MR1 ; MR2 = Ye = Estimate(1/Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
|| MMOV32 MR0,@_exp2_tmp1 ; MR0 = Num
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
|| MMOV32 MR1,@_exp2_tmp2 ; Optional: Reload Den To Set Sign
|
||||
MNEGF32 MR0,MR0,EQ ; Optional: if(Den == 0.0) Change Sign Of Num
|
||||
MMPYF32 MR0,MR2,MR0 ; MR0 = X = Ye*Num
|
||||
MMOV32 MR0,MR0 ; Optional: Set/Clear MSTF NF and ZF flags
|
||||
|
||||
MABSF32 MR3,MR0 ; LOAD |X| TO MR3
|
||||
; Step 2
|
||||
MF32TOI32 MR0,MR3 ; MR0 = INTEGER(X)
|
||||
MFRACF32 MR1,MR3 ; MR1 = MANTISSA(X)
|
||||
; Step 3
|
||||
MADD32 MR2,MR0,MR0
|
||||
MMOV16 MAR1,MR2,#_CLAExpTable
|
||||
|
||||
; Step 4
|
||||
MMOV32 MR2,@_CLAINV7 ; MR2 = 1/7
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Xm/7
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 =(1+Xm/7)
|
||||
MMOV32 MR2,@_CLAINV6 ; MR2 = .2
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+Xm/7)
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+Xm/7)/6
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/6)*(1+Xm/7)
|
||||
|| MMOV32 MR0,*MAR1 ; MR0 = e^(INTEGER(X))
|
||||
MMOV32 MR2,@_CLAINV5 ; MR2 = .2
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+Xm/6*(1+Xm/7))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+Xm/6*(1+Xm/7))/5
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/5)*(1+Xm/6*(1+Xm/7))
|
||||
MMOV32 MR2,@_CLAINV4 ; MR2 = .25
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+Xm/5*(1+Xm/6*(1+Xm/7)))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+Xm/5*(1+Xm/6*(1+Xm/7)))/4
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))
|
||||
MMOV32 MR2,@_CLAINV3 ; MR2 = .3333333
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+(Xm/4)*(1+Xm/5)*(1+Xm/6*(1+Xm/7)))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+(Xm/4)*(1+Xm/5)*(1+Xm/6*(1+Xm/7)))/3
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7))))
|
||||
MMOV32 MR2,@_CLAINV2 ; MR2 = .5
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))*0.5
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))Xm/2
|
||||
MMPYF32 MR3,MR3,MR1 ; MR3 = Xm(1+(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))Xm/2)
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = e^(Xm)= 1+Xm(1+(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))Xm/2)
|
||||
; Step 5
|
||||
MMPYF32 MR3,MR3,MR0 ; MR3 = e^(MANTISSA) x e^(INTEGER(X))
|
||||
MMOV32 MR1,MR3,UNC
|
||||
; Calculation of e^-x
|
||||
MEINVF32 MR2,MR1 ; MR2 = Ye = Estimate(1/Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
|| MMOV32 MR0,@_exp2_tmp1 ; MR0 = X (set/clear NF,ZF)
|
||||
MMOV32 MR3,@_exp2_tmp2 ; MR3 = X (set/clear NF,ZF)
|
||||
MXOR32 MR0,MR0,MR3 ;
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MMOV32 MR1,MR2,LT ; update e^X with inverse value
|
||||
MMOV32 MR0,MR1 ; Store result in MR0
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _exp2_tmp2
|
||||
.unasg _exp2_tmp1
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAexpN.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA Base N Exponent function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;; Step(1): Calculate ln(Num)
|
||||
;;
|
||||
;; Step(2): x*ln(Num)
|
||||
;;
|
||||
;; Step(3): N^x = e^(x*ln(Num))
|
||||
;;
|
||||
;; Input : fVal (or x), the power of N - MR0
|
||||
;; N, the base - MR1
|
||||
;;
|
||||
;; Benchmark: Cycles = 68
|
||||
;; Instructions = 68
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- exponent temporary variable (SP+4)
|
||||
;; |_______|<- exponentN temporary variable (SP+2)
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAexpN
|
||||
.sect "Cla1Prog:_CLAexpN"
|
||||
.align 2
|
||||
.def __cla_CLAexpN_sp
|
||||
__cla_CLAexpN_sp .usect ".scratchpad:Cla1Prog:_CLAexpN",6,0,1
|
||||
|
||||
_CLAexpN:
|
||||
.asmfunc
|
||||
.asg __cla_CLAexpN_sp + 0, _save_MR3
|
||||
.asg __cla_CLAexpN_sp + 2, _expN_tmp
|
||||
.asg __cla_CLAexpN_sp + 2, _exp_tmp
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Step 1: Calculate ln(Num)
|
||||
;;----------------------------------------------------------------------------
|
||||
MMOV32 @_expN_tmp, MR0 ; Save fVal (or Num)
|
||||
|
||||
; Step 1
|
||||
MMOV32 MR3, MR1 ; MR3 = N
|
||||
MMOV32 MR2, MR3 ; LOAD N TO MR2
|
||||
|
||||
; Step 2
|
||||
MLSR32 MR2, #23 ; MR2 = EXPONENT(X)
|
||||
MI32TOF32 MR2,MR2
|
||||
; Step 3
|
||||
MMOV32 MR1,@_CLALN_TABLE_MASK1 ; MR1 = 0x3FFFFFFF
|
||||
MAND32 MR3, MR1, MR3 ;
|
||||
MMOV32 MR1,@_CLALN_TABLE_MASK2 ; MR1 = 0x3F800000
|
||||
MOR32 MR3, MR1, MR3 ; MR3 = X/2^(EXPONENT)
|
||||
|
||||
MFRACF32 MR3,MR3 ; MR3 = MANTISSA
|
||||
; Step 4
|
||||
; || MMOV32 MR1,@_CLABIAS
|
||||
; MSUBF32 MR2,MR2,MR1 ; MR2 = EXPONENT - BIAS
|
||||
;
|
||||
; ||MMOV32 MR1,@_CLALNV2
|
||||
; MMPYF32 MR2,MR2,MR1 ; MR2 = (Exponent-127)*(Ln(2))
|
||||
|
||||
MMPYF32 MR0,MR3,#32.0 ; 32 = Elements In Table
|
||||
MF32TOUI16 MR0,MR0 ; MR0 = int(32*Xm)
|
||||
MADD32 MR0,MR0,MR0 ; MR0 = 2*MR0
|
||||
MADD32 MR1,MR0,MR0 ; MR1 = 4*MR0
|
||||
MADD32 MR0,MR0,MR1 ; MR0 = 6*MR0 this is the index value for
|
||||
; the stored data array
|
||||
|
||||
MMOV16 MAR1,MR0,#_CLALnTable+4
|
||||
|
||||
MMOV32 MR1,@_CLABIAS
|
||||
MSUBF32 MR2,MR2,MR1 ; MR2 = EXPONENT - BIAS
|
||||
|| MMOV32 MR1,@_CLALNV2
|
||||
MMPYF32 MR2,MR2,MR1 ; MR2 = (Exponent-127)*(Ln(2))
|
||||
; Step 5
|
||||
|
||||
; Ln(X) = A0 + Xm(A1 + A2*Xm)
|
||||
MMOV32 MR1,*MAR1[#-2]++ ; MR1 = A2
|
||||
MMPYF32 MR1,MR3,MR1 ; MR1 = A2*Xm
|
||||
|| MMOV32 MR0,*MAR1[#-2]++ ; MR0 = A1
|
||||
MADDF32 MR1,MR0,MR1 ; MR1 = A1 + A2*Xm
|
||||
MMPYF32 MR0,MR3,MR1 ; MR0 = Xm*(A1 + A2*Xm)
|
||||
|| MMOV32 MR1,*MAR1[#-2]++ ; MR1 = A0
|
||||
MADDF32 MR3,MR1,MR0 ; MR3 = A0 + Xm*(A1 + A2*Xm) = Ln(1+mantissa)
|
||||
MADDF32 MR3,MR3,MR2 ; Y = Ln(1+mantissa) + (Exponent-127)*(Ln(2))
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Step 2: x*ln(Num)
|
||||
;;----------------------------------------------------------------------------
|
||||
MMOV32 MR1, @_expN_tmp
|
||||
MMPYF32 MR0, MR1, MR3 ; MR0 = x*Ln(Num)
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Step 3: N^x = e^(x*ln(Num))
|
||||
;;----------------------------------------------------------------------------
|
||||
; The input argument fVal is refered to as X
|
||||
; save input argument on scratchpad
|
||||
MMOV32 @_exp_tmp,MR0
|
||||
; Step 1
|
||||
MMOV32 MR3,MR0 ; Load argument into MR3
|
||||
MABSF32 MR3,MR3 ; LOAD |X| TO MR3
|
||||
|
||||
; Step 2
|
||||
MF32TOI32 MR0,MR3 ; MR0 = INTEGER(X)
|
||||
MFRACF32 MR1,MR3 ; MR1 = MANTISSA(X)
|
||||
; Step 3
|
||||
MADD32 MR2,MR0,MR0
|
||||
MMOV16 MAR1,MR2,#_CLAExpTable
|
||||
|
||||
; Step 3
|
||||
MMOV32 MR2,@_CLAINV7 ; MR2 = 1/7
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Xm/7
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 =(1+Xm/7)
|
||||
MMOV32 MR2,@_CLAINV6 ; MR2 = 1/6
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+Xm/7)
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+Xm/7)/6
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/6)*(1+Xm/7)
|
||||
|| MMOV32 MR0,*MAR1 ; MR0 = e^(INTEGER(X))
|
||||
MMOV32 MR2,@_CLAINV5 ; MR2 = .2
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+Xm/6*(1+Xm/7))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+Xm/6*(1+Xm/7))/5
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/5)*(1+Xm/6*(1+Xm/7))
|
||||
MMOV32 MR2,@_CLAINV4 ; MR2 = .25
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+Xm/5*(1+Xm/6*(1+Xm/7)))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+Xm/5*(1+Xm/6*(1+Xm/7)))/4
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))
|
||||
MMOV32 MR2,@_CLAINV3 ; MR2 = .3333333
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+(Xm/4)*(1+Xm/5)*(1+Xm/6*(1+Xm/7)))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+(Xm/4)*(1+Xm/5)*(1+Xm/6*(1+Xm/7)))*0.333333
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7))))
|
||||
MMOV32 MR2,@_CLAINV2 ; MR2 = .5
|
||||
|| MMPYF32 MR3,MR1,MR3 ; MR3 = Xm(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))
|
||||
MMPYF32 MR3,MR3,MR2 ; MR3 = Xm(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))*0.5
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = 1+(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))Xm/2
|
||||
MMPYF32 MR3,MR3,MR1 ; MR3 = Xm(1+(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6*(1+Xm/7)))))Xm/2)
|
||||
|| MMOV32 MR2,@_CLAINV1 ; MR2 = 1
|
||||
MADDF32 MR3,MR3,MR2 ; MR3 = e^(MANTISSA)= 1+Xm(1+(1+(Xm/3)*(1+(Xm/4)*(1+Xm/5*(1+Xm/6)*(1+Xm/7))))Xm/2)
|
||||
; Step 4
|
||||
MMPYF32 MR3,MR3,MR0 ; MR3 = e^(MANTISSA) x e^(INTEGER(X))
|
||||
MMOV32 MR1,MR3,UNC
|
||||
; Calculation of e^-x
|
||||
MEINVF32 MR2,MR1 ; MR2 = Ye = Estimate(1/Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
|| MMOV32 MR0,@_exp_tmp ; MR2 = X (set/clear NF,ZF)
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MMOV32 MR1,MR2,LT ; update e^X with inverse value
|
||||
MMOV32 MR0,MR1 ; Store result in MR0
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.unasg _expN_tmp
|
||||
.unasg _exp_tmp
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,171 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAexpTable.asm
|
||||
;;
|
||||
;; DESCRIPTION: Exponential Tables
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
;;#############################################################################
|
||||
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
.def _CLAINV1
|
||||
.def _CLAINV2
|
||||
.def _CLAINV3
|
||||
.def _CLAINV4
|
||||
.def _CLAINV5
|
||||
.def _CLAINV6
|
||||
.def _CLAINV7
|
||||
.def _CLALOG10
|
||||
.def _CLAExpTable
|
||||
.def _CLAExpTableEnd
|
||||
|
||||
.sect "CLA1mathTables"
|
||||
_CLAINV1 .float 1
|
||||
_CLAINV2 .float 0.5 ; 1/2
|
||||
_CLAINV3 .float 0.333333333333333333 ; 1/3
|
||||
_CLAINV4 .float 0.25 ; 1/4
|
||||
_CLAINV5 .float 0.20 ; 1/5
|
||||
_CLAINV6 .float 0.166666666666666666 ; 1/6
|
||||
_CLAINV7 .float 0.142857142857142857 ; 1/7
|
||||
|
||||
_CLALOG10 .float 2.302585092 ; LOG10(e)
|
||||
|
||||
_CLAExpTable:
|
||||
.float 1.0 ; exp(0)
|
||||
.float 2.7182818285e+0 ; exp(1)
|
||||
.float 7.3890560989e+0 ; exp(2)
|
||||
.float 2.0085536923e+1 ; exp(3)
|
||||
.float 5.4598150033e+1 ; exp(4)
|
||||
.float 1.484131591e+2 ; exp(5)
|
||||
.float 4.0342879349e+2 ; exp(6)
|
||||
.float 1.0966331584e+3 ; exp(7)
|
||||
.float 2.980957987e+3 ; exp(8)
|
||||
.float 8.1030839276e+3 ; exp(9)
|
||||
.float 2.2026465795e+4 ; exp(10)
|
||||
.float 5.9874141715e+4 ; exp(11)
|
||||
.float 1.6275479142e+5 ; exp(12)
|
||||
.float 4.4241339201e+5 ; exp(13)
|
||||
.float 1.2026042842e+6 ; exp(14)
|
||||
.float 3.2690173725e+6 ; exp(15)
|
||||
.float 8.8861105205e+6 ; exp(16)
|
||||
.float 2.4154952754e+7 ; exp(17)
|
||||
.float 6.5659969137e+7 ; exp(18)
|
||||
.float 1.7848230096e+8 ; exp(19)
|
||||
.float 4.8516519541e+8 ; exp(20)
|
||||
.float 1.3188157345e+9 ; exp(21)
|
||||
.float 3.5849128461e+9 ; exp(22)
|
||||
.float 9.7448034462e+9 ; exp(23)
|
||||
.float 2.648912213e+10 ; exp(24)
|
||||
.float 7.2004899337e+10 ; exp(25)
|
||||
.float 1.9572960943e+11 ; exp(26)
|
||||
.float 5.320482406e+11 ; exp(27)
|
||||
.float 1.4462570643e+12 ; exp(28)
|
||||
.float 3.9313342971e+12 ; exp(29)
|
||||
.float 1.0686474582e+13 ; exp(30)
|
||||
.float 2.9048849665e+13 ; exp(31)
|
||||
.float 7.8962960183e+13 ; exp(32)
|
||||
.float 2.1464357979e+14 ; exp(33)
|
||||
.float 5.8346174253e+14 ; exp(34)
|
||||
.float 1.5860134523e+15 ; exp(35)
|
||||
.float 4.3112315471e+15 ; exp(36)
|
||||
.float 1.1719142373e+16 ; exp(37)
|
||||
.float 3.1855931757e+16 ; exp(38)
|
||||
.float 8.6593400424e+16 ; exp(39)
|
||||
.float 2.3538526684e+17 ; exp(40)
|
||||
.float 6.3984349353e+17 ; exp(41)
|
||||
.float 1.7392749415e+18 ; exp(42)
|
||||
.float 4.7278394682e+18 ; exp(43)
|
||||
.float 1.2851600114e+19 ; exp(44)
|
||||
.float 3.4934271057e+19 ; exp(45)
|
||||
.float 9.4961194206e+19 ; exp(46)
|
||||
.float 2.5813128862e+20 ; exp(47)
|
||||
.float 7.0167359121e+20 ; exp(48)
|
||||
.float 1.9073465725e+21 ; exp(49)
|
||||
.float 5.1847055286e+21 ; exp(50)
|
||||
.float 1.4093490824e+22 ; exp(51)
|
||||
.float 3.8310080007e+22 ; exp(52)
|
||||
.float 1.0413759433e+23 ; exp(53)
|
||||
.float 2.8307533033e+23 ; exp(54)
|
||||
.float 7.6947852651e+23 ; exp(55)
|
||||
.float 2.091659496e+24 ; exp(56)
|
||||
.float 5.6857199993e+24 ; exp(57)
|
||||
.float 1.5455389356e+25 ; exp(58)
|
||||
.float 4.2012104038e+25 ; exp(59)
|
||||
.float 1.1420073898e+26 ; exp(60)
|
||||
.float 3.1042979357e+26 ; exp(61)
|
||||
.float 8.4383566687e+26 ; exp(62)
|
||||
.float 2.2937831595e+27 ; exp(63)
|
||||
.float 6.2351490808e+27 ; exp(64)
|
||||
.float 1.6948892444e+28 ; exp(65)
|
||||
.float 4.6071866343e+28 ; exp(66)
|
||||
.float 1.2523631708e+29 ; exp(67)
|
||||
.float 3.4042760499e+29 ; exp(68)
|
||||
.float 9.2537817256e+29 ; exp(69)
|
||||
.float 2.5154386709e+30 ; exp(70)
|
||||
.float 6.8376712298e+30 ; exp(71)
|
||||
.float 1.8586717453e+31 ; exp(72)
|
||||
.float 5.0523936303e+31 ; exp(73)
|
||||
.float 1.3733829795e+32 ; exp(74)
|
||||
.float 3.7332419968e+32 ; exp(75)
|
||||
.float 1.0148003881e+33 ; exp(76)
|
||||
.float 2.7585134545e+33 ; exp(77)
|
||||
.float 7.498416997e+33 ; exp(78)
|
||||
.float 2.0382810665e+34 ; exp(79)
|
||||
.float 5.5406223844e+34 ; exp(80)
|
||||
.float 1.5060973146e+35 ; exp(81)
|
||||
.float 4.0939969621e+35 ; exp(82)
|
||||
.float 1.1128637548e+36 ; exp(83)
|
||||
.float 3.0250773222e+36 ; exp(84)
|
||||
.float 8.2230127146e+36 ; exp(85)
|
||||
.float 2.2352466037e+37 ; exp(86)
|
||||
.float 6.0760302251e+37 ; exp(87)
|
||||
.float 1.651636255e+38 ; exp(88)
|
||||
|
||||
_CLAExpTableEnd:
|
||||
|
||||
;; End of File
|
||||
@@ -0,0 +1,109 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAisqrt.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA inverse square root function using Newton Raphson
|
||||
;; Approximation
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description: Implement 1/(square root) using Newton-Raphson Method
|
||||
;;
|
||||
;; Equation: y = 1/(sqrt(x))
|
||||
;;
|
||||
;; Regs Used: MR0, MR1, MR2, MR3
|
||||
;;
|
||||
;; Input: x f32 value in memory
|
||||
;;
|
||||
;; Output: y f32 value in memory
|
||||
;; MR0 = y f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 14
|
||||
;; Instructions = 14
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAisqrt
|
||||
.sect "Cla1Prog:_CLAisqrt"
|
||||
.align 2
|
||||
.def __cla_CLAisqrt_sp
|
||||
__cla_CLAisqrt_sp .usect ".scratchpad:Cla1Prog:_CLAisqrt",2,0,1
|
||||
|
||||
_CLAisqrt:
|
||||
.asmfunc
|
||||
.asg __cla_CLAisqrt_sp + 0, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
; MR0 = Number
|
||||
MEISQRTF32 MR1, MR0 ; MR1 = Ye = Estimate(1/sqrt(X))
|
||||
MMPYF32 MR2, MR0, #0.5 ; MR2 = X*0.5
|
||||
MMPYF32 MR3, MR1, MR1 ; MR3 = Ye*Ye
|
||||
MMPYF32 MR3, MR3, MR2 ; MR3 = Ye*Ye*X*0.5
|
||||
MSUBF32 MR3, #1.5,MR3 ; MR3 = 1.5 - Ye*Ye*X*0.5
|
||||
MMPYF32 MR1, MR1, MR3 ; MR1 = Ye = Ye*(1.5 - Ye*Ye*X*0.5)
|
||||
MMPYF32 MR3, MR1, MR2 ; MR3 = Ye*X*0.5
|
||||
MMPYF32 MR3, MR1, MR3 ; MR3 = Ye*Ye*X*0.5
|
||||
MSUBF32 MR3, #1.5,MR3 ; MR3 = 1.5 - Ye*Ye*X*0.5
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MMPYF32 MR0, MR1, MR3 ; MR0 = Ye = Ye*(1.5 - Ye*Ye*X*0.5)
|
||||
MMOV32 MR0, MR0 ; Optional: set MSTF NF and ZF flags
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAln.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA Natural Logarithm Function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;; Step(1): Calculate absolute of x
|
||||
;;
|
||||
;; Step(2): Identify the exponent of the input, store it float.
|
||||
;;
|
||||
;; Step(3): Identify the mantissa{Xm}.
|
||||
;;
|
||||
;; Step(4): Subtract the bias from the exponent and multiply it by Ln(2)
|
||||
;;
|
||||
;; Step(5): Calculate the value of Ln(1+mantissa)by using the
|
||||
;; polynomial approx = a0 + Xm*(a1 + Xm*a2)
|
||||
;;
|
||||
;; Step(6): Result = Ln(1+mantissa) + (Exponent-127)*(Ln(2))
|
||||
;;
|
||||
;;
|
||||
;; Benchmark: Cycles = 28
|
||||
;; Instructions = 28
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAln
|
||||
.sect "Cla1Prog:_CLAln"
|
||||
.align 2
|
||||
.def __cla_CLAln_sp
|
||||
__cla_CLAln_sp .usect ".scratchpad:Cla1Prog:_CLAln",2,0,1
|
||||
|
||||
_CLAln:
|
||||
.asmfunc
|
||||
.asg __cla_CLAln_sp + 0, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
; Step 1
|
||||
MMOV32 MR3,MR0
|
||||
; MABSF32 MR3,MR3 ; LOAD |X| TO MR3
|
||||
MMOV32 MR2, MR3 ; LOAD |X| TO MR2
|
||||
|
||||
; Step 2
|
||||
MLSR32 MR2, #23 ; MR2 = EXPONENT(X)
|
||||
MI32TOF32 MR2,MR2
|
||||
; Step 3
|
||||
MMOV32 MR1,@_CLALN_TABLE_MASK1 ; MR1 = 0x3FFFFFFF
|
||||
MAND32 MR3, MR1, MR3 ;
|
||||
MMOV32 MR1,@_CLALN_TABLE_MASK2 ; MR1 = 0x3F800000
|
||||
MOR32 MR3, MR1, MR3 ; MR3 = X/2^(EXPONENT)
|
||||
|
||||
MFRACF32 MR3,MR3 ; MR3 = MANTISSA
|
||||
; Step 4
|
||||
; || MMOV32 MR1,@_CLABIAS
|
||||
; MSUBF32 MR2,MR2,MR1 ; MR2 = EXPONENT - BIAS
|
||||
;
|
||||
; ||MMOV32 MR1,@_CLALNV2
|
||||
; MMPYF32 MR2,MR2,MR1 ; MR2 = (Exponent-127)*(Ln(2))
|
||||
|
||||
MMPYF32 MR0,MR3,#32.0 ; 32 = Elements In Table
|
||||
MF32TOUI16 MR0,MR0 ; MR0 = int(32*Xm)
|
||||
MADD32 MR0,MR0,MR0 ; MR0 = 2*MR0
|
||||
MADD32 MR1,MR0,MR0 ; MR1 = 4*MR0
|
||||
MADD32 MR0,MR0,MR1 ; MR0 = 6*MR0 this is the index value for
|
||||
; the stored data array
|
||||
|
||||
MMOV16 MAR1,MR0,#_CLALnTable+4
|
||||
|
||||
MMOV32 MR1,@_CLABIAS
|
||||
MSUBF32 MR2,MR2,MR1 ; MR2 = EXPONENT - BIAS
|
||||
|| MMOV32 MR1,@_CLALNV2
|
||||
MMPYF32 MR2,MR2,MR1 ; MR2 = (Exponent-127)*(Ln(2))
|
||||
; Step 5
|
||||
|
||||
; Ln(X) = A0 + Xm(A1 + A2*Xm)
|
||||
MMOV32 MR1,*MAR1[#-2]++ ; MR1 = A2
|
||||
MMPYF32 MR1,MR3,MR1 ; MR1 = A2*Xm
|
||||
|| MMOV32 MR0,*MAR1[#-2]++ ; MR0 = A1
|
||||
MADDF32 MR1,MR0,MR1 ; MR1 = A1 + A2*Xm
|
||||
MMPYF32 MR0,MR3,MR1 ; MR0 = Xm*(A1 + A2*Xm)
|
||||
|| MMOV32 MR1,*MAR1[#-2]++ ; MR1 = A0
|
||||
MADDF32 MR3,MR1,MR0 ; MR3 = A0 + Xm*(A1 + A2*Xm) = Ln(1+mantissa)
|
||||
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MADDF32 MR3,MR3,MR2
|
||||
MMOV32 MR0,MR3 ; Y = Ln(1+mantissa) + (Exponent-127)*(Ln(2))
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,177 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAlnTable.asm
|
||||
;;
|
||||
;; DESCRIPTION: Natural Logarithm Tables
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
.def _CLALNV2
|
||||
.def _CLALNVe
|
||||
.def _CLALNV10
|
||||
.def _CLABIAS
|
||||
.def _CLALN_TABLE_MASK1
|
||||
.def _CLALN_TABLE_MASK2
|
||||
.def _CLALnTable
|
||||
.def _CLALnTableEnd
|
||||
|
||||
.sect "CLA1mathTables"
|
||||
|
||||
_CLALNV2 .float 0.693147180559 ;
|
||||
_CLALNVe .float 1.0 ;
|
||||
_CLALNV10 .float 0.4342944819032;
|
||||
_CLABIAS .float 127.0 ;
|
||||
_CLALN_TABLE_MASK1 .long 0x3FFFFFFF ;
|
||||
_CLALN_TABLE_MASK2 .long 0x3F800000 ;
|
||||
|
||||
|
||||
_CLALnTable:
|
||||
.float 0 ;
|
||||
.float 1 ;
|
||||
.float -0.5 ;
|
||||
.float 9.49154e-06 ;
|
||||
.float 0.999081726 ;
|
||||
.float -0.470156107 ;
|
||||
.float 7.09886e-05 ;
|
||||
.float 0.996539792 ;
|
||||
.float -0.442906574 ;
|
||||
.float 0.000224404 ;
|
||||
.float 0.992653061 ;
|
||||
.float -0.417959184 ;
|
||||
.float 0.000499085 ;
|
||||
.float 0.987654321 ;
|
||||
.float -0.395061728 ;
|
||||
.float 0.000916122 ;
|
||||
.float 0.981738495 ;
|
||||
.float -0.373995617 ;
|
||||
.float 0.001490146 ;
|
||||
.float 0.975069252 ;
|
||||
.float -0.354570637 ;
|
||||
.float 0.00223074 ;
|
||||
.float 0.967784352 ;
|
||||
.float -0.336620644 ;
|
||||
.float 0.003143551 ;
|
||||
.float 0.96 ;
|
||||
.float -0.32 ;
|
||||
.float 0.004231167 ;
|
||||
.float 0.951814396 ;
|
||||
.float -0.304580607 ;
|
||||
.float 0.005493806 ;
|
||||
.float 0.943310658 ;
|
||||
.float -0.290249433 ;
|
||||
.float 0.00692987 ;
|
||||
.float 0.934559221 ;
|
||||
.float -0.276906436 ;
|
||||
.float 0.008536376 ;
|
||||
.float 0.925619835 ;
|
||||
.float -0.26446281 ;
|
||||
.float 0.010309303 ;
|
||||
.float 0.91654321 ;
|
||||
.float -0.252839506 ;
|
||||
.float 0.012243868 ;
|
||||
.float 0.907372401 ;
|
||||
.float -0.241965974 ;
|
||||
.float 0.014334741 ;
|
||||
.float 0.898143957 ;
|
||||
.float -0.231779086 ;
|
||||
.float 0.016576219 ;
|
||||
.float 0.888888889 ;
|
||||
.float -0.222222222 ;
|
||||
.float 0.018962363 ;
|
||||
.float 0.879633486 ;
|
||||
.float -0.213244481 ;
|
||||
.float 0.021487103 ;
|
||||
.float 0.8704 ;
|
||||
.float -0.2048 ;
|
||||
.float 0.024144324 ;
|
||||
.float 0.861207228 ;
|
||||
.float -0.196847366 ;
|
||||
.float 0.026927934 ;
|
||||
.float 0.852071006 ;
|
||||
.float -0.189349112 ;
|
||||
.float 0.02983191 ;
|
||||
.float 0.843004628 ;
|
||||
.float -0.182271271 ;
|
||||
.float 0.032850339 ;
|
||||
.float 0.834019204 ;
|
||||
.float -0.17558299 ;
|
||||
.float 0.035977448 ;
|
||||
.float 0.825123967 ;
|
||||
.float -0.169256198 ;
|
||||
.float 0.039207625 ;
|
||||
.float 0.816326531 ;
|
||||
.float -0.163265306 ;
|
||||
.float 0.042535433 ;
|
||||
.float 0.807633118 ;
|
||||
.float -0.15758695 ;
|
||||
.float 0.045955621 ;
|
||||
.float 0.799048751 ;
|
||||
.float -0.152199762 ;
|
||||
.float 0.049463133 ;
|
||||
.float 0.79057742 ;
|
||||
.float -0.147084171 ;
|
||||
.float 0.053053104 ;
|
||||
.float 0.782222222 ;
|
||||
.float -0.142222222 ;
|
||||
.float 0.056720869 ;
|
||||
.float 0.773985488 ;
|
||||
.float -0.13759742 ;
|
||||
.float 0.060461958 ;
|
||||
.float 0.765868887 ;
|
||||
.float -0.133194589 ;
|
||||
.float 0.064272091 ;
|
||||
.float 0.75787352 ;
|
||||
.float -0.128999748 ;
|
||||
.float 0.068147181 ;
|
||||
.float 0.75 ;
|
||||
.float -0.125 ;
|
||||
|
||||
_CLALnTableEnd:
|
||||
|
||||
;; End of File
|
||||
@@ -0,0 +1,148 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAlog10.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA Base 10 Logarithmic Function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;; Step(1): Calculate absolute of x
|
||||
;;
|
||||
;; Step(2): Identify the exponent of the input, store it float.
|
||||
;;
|
||||
;; Step(3): Identify the mantissa{Xm}.
|
||||
;;
|
||||
;; Step(4): Subtract the bias from the exponent and multiply it by Ln(2)
|
||||
;;
|
||||
;; Step(5): Calculate the value of Ln(1+mantissa)by using the
|
||||
;; polynomial approx = a0 + Xm*(a1 + Xm*a2)
|
||||
;;
|
||||
;; Step(6): Result = {Ln(1+mantissa) + (Exponent-127)*(Ln(2))}/Ln(10)
|
||||
;;
|
||||
;;
|
||||
;; Benchmark: Cycles = 29
|
||||
;; Instructions = 29
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAlog10
|
||||
.sect "Cla1Prog:_CLAlog10"
|
||||
.align 2
|
||||
.def __cla_CLAlog10_sp
|
||||
__cla_CLAlog10_sp .usect ".scratchpad:Cla1Prog:_CLAlog10",2,0,1
|
||||
|
||||
_CLAlog10:
|
||||
.asmfunc
|
||||
.asg __cla_CLAlog10_sp + 0, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
; Step 1
|
||||
MMOV32 MR3,MR0
|
||||
; MABSF32 MR3,MR3 ; LOAD |X| TO MR3
|
||||
MMOV32 MR2, MR3 ; LOAD |X| TO MR2
|
||||
; Step 2
|
||||
MLSR32 MR2, #23 ; MR2 = EXPONENT(X)
|
||||
MI32TOF32 MR2,MR2
|
||||
; Step 3
|
||||
MMOV32 MR1,@_CLALN_TABLE_MASK1 ; MR1 = 0x3FFFFFFF
|
||||
MAND32 MR3, MR1, MR3
|
||||
MMOV32 MR1,@_CLALN_TABLE_MASK2 ; MR1 = 0x3F800000
|
||||
MOR32 MR3, MR1, MR3 ; MR3 =X/2^(EXPONENT)
|
||||
MFRACF32 MR3,MR3 ; MR3 = MANTISSA
|
||||
; Step 4
|
||||
; || MMOV32 MR1,@_CLABIAS
|
||||
; MSUBF32 MR2,MR2,MR1 ; MR2 = EXPONENT - BIAS
|
||||
;
|
||||
; || MMOV32 MR1,@_CLALNV2
|
||||
; MMPYF32 MR2,MR2,MR1 ; MR2 = (Exponent-127)*(Ln(2))
|
||||
|
||||
MMPYF32 MR0,MR3,#32.0 ; 32 = Elements In Table
|
||||
MF32TOUI16 MR0,MR0 ; MR0 = int(32*x)
|
||||
MADD32 MR0,MR0,MR0 ; MR0 = 2*MR0
|
||||
MADD32 MR1,MR0,MR0 ; MR1 = 4*MR0
|
||||
MADD32 MR0,MR0,MR1 ; MR0 = 6*MR0 this is the index value
|
||||
; for the stored data array
|
||||
; MAR1 points to A2, this will be used later
|
||||
MMOV16 MAR1,MR0,#_CLALnTable+4
|
||||
|
||||
MMOV32 MR1,@_CLABIAS
|
||||
MSUBF32 MR2,MR2,MR1 ; MR2 = EXPONENT - BIAS
|
||||
|| MMOV32 MR1,@_CLALNV2 ;
|
||||
MMPYF32 MR2,MR2,MR1 ; MR2 = (Exponent-127)*(Ln(2))
|
||||
; Step 5
|
||||
; Ln(X) = A0 + Xm(A1 + A2*Xm)
|
||||
MMOV32 MR1,*MAR1[#-2]++ ; MR1 = A2
|
||||
MMPYF32 MR1,MR3,MR1 ; MR1 = A2*Xm
|
||||
|| MMOV32 MR0,*MAR1[#-2]++ ; MR0 = A1
|
||||
MADDF32 MR1,MR0,MR1 ; MR1 = A1 + A2*Xm
|
||||
MMPYF32 MR0,MR3,MR1 ; MR0 = Xm*(A1 + A2*Xm)
|
||||
|| MMOV32 MR1,*MAR1[#-2]++ ; MR1 = A0
|
||||
MADDF32 MR3,MR1,MR0 ; MR3 = A0 + Ratio*(A1 + A2*Ratio) = Ln(1+mantissa)
|
||||
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR1,@_CLALNV10
|
||||
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
MMOV32 MR0,MR3 ; Y= (Ln(1+mantissa) + (Exponent-127)*(Ln(2)))/Ln(10)
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,213 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAlogN.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA Base N Logarithmic Function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description:
|
||||
;; Step(1): Calculate natural logarithm of fVal (or x)
|
||||
;;
|
||||
;; Step(2): Calculate natural logarithm of N
|
||||
;;
|
||||
;; Step(3): log_N(x) = log_e(x)/log_e(N)
|
||||
;;
|
||||
;; Benchmark: Cycles = 67
|
||||
;; Instructions = 67
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- temporary logN variable (SP+2)
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAlogN
|
||||
.sect "Cla1Prog:_CLAlogN"
|
||||
.align 2
|
||||
.def __cla_CLAlogN_sp
|
||||
__cla_CLAlogN_sp .usect ".scratchpad:Cla1Prog:_CLAlogN",4,0,1
|
||||
|
||||
_CLAlogN:
|
||||
.asmfunc
|
||||
.asg __cla_CLAlogN_sp + 0, _save_MR3
|
||||
.asg __cla_CLAlogN_sp + 2, _logN_tmp
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
MMOV32 @_logN_tmp, MR1 ; Save N to scratchpad
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Step(1): Calculate natural logarithm of fVal (or x)
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
; Step 1
|
||||
MMOV32 MR3,MR0
|
||||
MMOV32 MR2, MR3 ; LOAD X TO MR2
|
||||
; Step 2
|
||||
MLSR32 MR2, #23 ; MR2 = EXPONENT(X)
|
||||
MI32TOF32 MR2,MR2
|
||||
; Step 3
|
||||
MMOV32 MR1,@_CLALN_TABLE_MASK1 ; MR1 = 0x3FFFFFFF
|
||||
MAND32 MR3, MR1, MR3
|
||||
MMOV32 MR1,@_CLALN_TABLE_MASK2 ; MR1 = 0x3F800000
|
||||
MOR32 MR3, MR1, MR3 ; MR3 =X/2^(EXPONENT)
|
||||
MFRACF32 MR3,MR3 ; MR3 = MANTISSA
|
||||
; Step 4
|
||||
; || MMOV32 MR1,@_CLABIAS
|
||||
; MSUBF32 MR2,MR2,MR1 ; MR2 = EXPONENT - BIAS
|
||||
;
|
||||
; || MMOV32 MR1,@_CLALNV2
|
||||
; MMPYF32 MR2,MR2,MR1 ; MR2 = (Exponent-127)*(Ln(2))
|
||||
|
||||
MMPYF32 MR0,MR3,#32.0 ; 32 = Elements In Table
|
||||
MF32TOUI16 MR0,MR0 ; MR0 = int(32*x)
|
||||
MADD32 MR0,MR0,MR0 ; MR0 = 2*MR0
|
||||
MADD32 MR1,MR0,MR0 ; MR1 = 4*MR0
|
||||
MADD32 MR0,MR0,MR1 ; MR0 = 6*MR0 this is the index value
|
||||
; for the stored data array
|
||||
; MAR1 points to A2, this will be used later
|
||||
MMOV16 MAR1,MR0,#_CLALnTable+4
|
||||
|
||||
MMOV32 MR1,@_CLABIAS
|
||||
MSUBF32 MR2,MR2,MR1 ; MR2 = EXPONENT - BIAS
|
||||
|| MMOV32 MR1,@_CLALNV2 ;
|
||||
MMPYF32 MR2,MR2,MR1 ; MR2 = (Exponent-127)*(Ln(2))
|
||||
; Step 5
|
||||
; Ln(X) = A0 + Xm(A1 + A2*Xm)
|
||||
MMOV32 MR1,*MAR1[#-2]++ ; MR1 = A2
|
||||
MMPYF32 MR1,MR3,MR1 ; MR1 = A2*Xm
|
||||
|| MMOV32 MR0,*MAR1[#-2]++ ; MR0 = A1
|
||||
MADDF32 MR1,MR0,MR1 ; MR1 = A1 + A2*Xm
|
||||
MMPYF32 MR0,MR3,MR1 ; MR0 = Xm*(A1 + A2*Xm)
|
||||
|| MMOV32 MR1,*MAR1[#-2]++ ; MR1 = A0
|
||||
MADDF32 MR3,MR1,MR0 ; MR3 = A0 + Ratio*(A1 + A2*Ratio) = Ln(1+mantissa)
|
||||
MMOV32 MR0, @_logN_tmp ; MR0 = N
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR1,@_CLALNV10
|
||||
MMPYF32 MR3,MR3,MR1 ; Y= (Ln(1+mantissa) + (Exponent-127)*(Ln(2)))/Ln(10)
|
||||
MMOV32 @_logN_tmp, MR3 ; Save Ln(x) to scratchpad
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Step(2): Calculate natural logarithm of N
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
; Step 1
|
||||
MMOV32 MR3,MR0
|
||||
MMOV32 MR2, MR3 ; LOAD X (N) TO MR2
|
||||
; Step 2
|
||||
MLSR32 MR2, #23 ; MR2 = EXPONENT(X)
|
||||
MI32TOF32 MR2,MR2
|
||||
; Step 3
|
||||
MMOV32 MR1,@_CLALN_TABLE_MASK1 ; MR1 = 0x3FFFFFFF
|
||||
MAND32 MR3, MR1, MR3
|
||||
MMOV32 MR1,@_CLALN_TABLE_MASK2 ; MR1 = 0x3F800000
|
||||
MOR32 MR3, MR1, MR3 ; MR3 =X/2^(EXPONENT)
|
||||
MFRACF32 MR3,MR3 ; MR3 = MANTISSA
|
||||
; Step 4
|
||||
; || MMOV32 MR1,@_CLABIAS
|
||||
; MSUBF32 MR2,MR2,MR1 ; MR2 = EXPONENT - BIAS
|
||||
;
|
||||
; || MMOV32 MR1,@_CLALNV2
|
||||
; MMPYF32 MR2,MR2,MR1 ; MR2 = (Exponent-127)*(Ln(2))
|
||||
|
||||
MMPYF32 MR0,MR3,#32.0 ; 32 = Elements In Table
|
||||
MF32TOUI16 MR0,MR0 ; MR0 = int(32*x)
|
||||
MADD32 MR0,MR0,MR0 ; MR0 = 2*MR0
|
||||
MADD32 MR1,MR0,MR0 ; MR1 = 4*MR0
|
||||
MADD32 MR0,MR0,MR1 ; MR0 = 6*MR0 this is the index value
|
||||
; for the stored data array
|
||||
; MAR1 points to A2, this will be used later
|
||||
MMOV16 MAR1,MR0,#_CLALnTable+4
|
||||
|
||||
MMOV32 MR1,@_CLABIAS
|
||||
MSUBF32 MR2,MR2,MR1 ; MR2 = EXPONENT - BIAS
|
||||
|| MMOV32 MR1,@_CLALNV2 ;
|
||||
MMPYF32 MR2,MR2,MR1 ; MR2 = (Exponent-127)*(Ln(2))
|
||||
; Step 5
|
||||
; Ln(X) = A0 + Xm(A1 + A2*Xm)
|
||||
MMOV32 MR1,*MAR1[#-2]++ ; MR1 = A2
|
||||
MMPYF32 MR1,MR3,MR1 ; MR1 = A2*Xm
|
||||
|| MMOV32 MR0,*MAR1[#-2]++ ; MR0 = A1
|
||||
MADDF32 MR1,MR0,MR1 ; MR1 = A1 + A2*Xm
|
||||
MMPYF32 MR0,MR3,MR1 ; MR0 = Xm*(A1 + A2*Xm)
|
||||
|| MMOV32 MR1,*MAR1[#-2]++ ; MR1 = A0
|
||||
MADDF32 MR3,MR1,MR0 ; MR3 = A0 + Ratio*(A1 + A2*Ratio) = Ln(1+mantissa)
|
||||
MMOV32 MR0, @_logN_tmp ; MR0 = log_e(x)
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR1,@_CLALNV10
|
||||
|
||||
MMPYF32 MR1,MR3,MR1 ; Y= (Ln(1+mantissa) + (Exponent-127)*(Ln(2)))/Ln(10)
|
||||
; MR1 = log_e(N)
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Step(3): log_N(x) = log_e(x)/log_e(N)
|
||||
;;----------------------------------------------------------------------------
|
||||
MEINVF32 MR2,MR1 ; MR2 = Ye = Estimate(1/Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
|| MMOV32 @_logN_tmp, MR1 ; save off denominator
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
MMPYF32 MR3,MR2,MR1 ; MR3 = Ye*Den
|
||||
MSUBF32 MR3,#2.0,MR3 ; MR3 = 2.0 - Ye*Den
|
||||
MMPYF32 MR2,MR2,MR3 ; MR2 = Ye = Ye*(2.0 - Ye*Den)
|
||||
|| MMOV32 MR1, @_logN_tmp ; Reload denominator to set sign
|
||||
MNEGF32 MR0,MR0,EQ ; Optional: if(Den == 0.0) Change Sign Of Num
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MMPYF32 MR0,MR2,MR0 ; MR0 = Y = Ye*Num
|
||||
MMOV32 MR0,MR0 ; Optional: Set/Clear MSTF NF and ZF flags
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.unasg _logN_tmp
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,230 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAsin.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA sine function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description: Implement sine using taylor series expansion:
|
||||
;;
|
||||
;; rad = K + X
|
||||
;;
|
||||
;; Sin(rad) = Sin(K) + Cos(K)*X
|
||||
;; - Sin(K)*X^2/2!
|
||||
;; - Cos(K)*X^3/3!
|
||||
;; + Sin(K)*X^4/4!
|
||||
;; + Cos(K)*X^5/5!
|
||||
;;
|
||||
;; = Sin(K) + X*(Cos(K)
|
||||
;; + X*(-0.5*Sin(K)
|
||||
;; + X*(-0.166666*Cos(K)
|
||||
;; + X*(0.04166666*Sin(K)
|
||||
;; + X*(0.00833333*Cos(K))))))
|
||||
;;
|
||||
;; = Sin(K) + X*(Cos(K)
|
||||
;; + X*(Coef0*Sin(K)
|
||||
;; + X*(Coef1*Cos(K)
|
||||
;; + X*(Coef2*Sin(K)
|
||||
;; + X*(Coef3*Cos(K))))))
|
||||
;;
|
||||
;;
|
||||
;; Equation: y = Sin(rad)
|
||||
;; Regs Used: MAR0, MR0, MR1, MR2, MR3
|
||||
;; Input: rad f32 value in memory
|
||||
;;
|
||||
;; // TABLE_SIZE = 128
|
||||
;; CLAsincosTable.Sin0 = 0.0; // sin( 0 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin1 = 0.04906767432742; // sin( 1 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin31 = 0.9987954562052; // sin( 31 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos0 = 1.0; // sin( 32 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin33 = 0.9987954562052; // sin( 33 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin63 = 0.04906767432742; // sin( 63 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin64 = 0.0; // sin( 64 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin65 = -0.04906767432742; // sin( 65 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin95 = -0.9987954562052; // sin( 95 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin96 = -1.0; // sin( 96 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin97 = -0.9987954562052; // sin( 97 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin127 = -0.04906767432742; // sin(127 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos96 = 0.0; // sin( 0 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos97 = 0.04906767432742; // sin( 1 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Cos127 = 0.9987954562052; // sin( 31 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos128 = 1.0; // sin( 32 * 2*pi/TABLE_SIZE)
|
||||
;;
|
||||
;; CLAsincosTable.TABLE_SIZEDivPi = 40.74366543152;
|
||||
;; CLAsincosTable.TwoPiDivTABLE_SIZE = 0.04908738521234;
|
||||
;; CLAsincosTable.TABLE_MASK = 0x000000FE;
|
||||
;;
|
||||
;; CLAsincosTable.Coef0 = -0.5;
|
||||
;; CLAsincosTable.Coef1 = -0.1666666666666;
|
||||
;; CLAsincosTable.Coef1_pos = 0.1666666666666;
|
||||
;; CLAsincosTable.Coef2 = 4.1666666666666e-2;
|
||||
;; CLAsincosTable.Coef3 = 8.3333333333333e-3;
|
||||
;; CLAsincosTable.Coef3_neg = -8.3333333333333e-3;
|
||||
;;
|
||||
;; Output: y f32 value in memory
|
||||
;; MR0 = y f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 28
|
||||
;; Instructions = 28
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAsin
|
||||
.sect "Cla1Prog:_CLAsin"
|
||||
.align 2
|
||||
.def __cla_CLAsin_sp
|
||||
__cla_CLAsin_sp .usect ".scratchpad:Cla1Prog:_CLAsin",2,0,1
|
||||
|
||||
_CLAsin:
|
||||
.asmfunc
|
||||
.asg __cla_CLAsin_sp + 0, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
|
||||
; MR0 = rad(fAngleRad)
|
||||
; MR1 = TABLE_SIZE/(2*Pi)
|
||||
; MR1 = rad*TABLE_SIZE/(2*Pi)
|
||||
; MR2 = TABLE_MASK
|
||||
MMOV32 MR1,@_CLAsincosTable_TABLE_SIZEDivTwoPi
|
||||
MMPYF32 MR1,MR0,MR1
|
||||
|| MMOV32 MR2,@_CLAsincosTable_TABLE_MASK
|
||||
|
||||
; MR3 = K = integer(rad*TABLE_SIZE/(2*Pi))
|
||||
; MR3 = K & TABLE_MASK
|
||||
; MR3 = K * 2
|
||||
; MAR0 = address of Cos(K)
|
||||
MF32TOI32 MR3,MR1
|
||||
MAND32 MR3,MR3,MR2
|
||||
MLSL32 MR3,#1
|
||||
MMOV16 MAR0,MR3,#_CLAsincosTable_Cos0
|
||||
|
||||
; MR1 = frac(TABLE_SIZE*rad/2*Pi)
|
||||
; MR0 = 2*Pi/TABLE_SIZE
|
||||
; MR1 = X = frac(TABLE_SIZE*rad/2*Pi) * (2*Pi/TABLE_SIZE)
|
||||
; MR0 = Coef3
|
||||
MFRACF32 MR1,MR1
|
||||
MMOV32 MR0,@_CLAsincosTable_TwoPiDivTABLE_SIZE
|
||||
MMPYF32 MR1,MR1,MR0
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef3
|
||||
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = Coef3*Cos(K)
|
||||
; MR2 = Sin(K)
|
||||
; MR3 = X*Coef3*Cos(K)
|
||||
MMOV32 MR2,*MAR0[#-64]++
|
||||
MMPYF32 MR3,MR0,MR2
|
||||
|| MMOV32 MR2,*MAR0[#+64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef2
|
||||
|
||||
; MR2 = Coef2*Sin(K)
|
||||
; MR3 = Coef2*Sin(K) + X*Coef3*Cos(K)
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = X*Coef2*Sin(K) + X^2*Coef3*Cos(K)
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#-64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef1
|
||||
|
||||
; MR2 = Coef1*Cos(K)
|
||||
; MR3 = Coef1*Cos(K) + X*Coef2*Sin(K) + X^2*Coef3*Cos(K)
|
||||
; MR2 = Sin(K)
|
||||
; MR3 = X*Coef1*Cos(K) + X^2*Coef2*Sin(K) + X^3*Coef3*Cos(K)
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#+64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef0
|
||||
|
||||
; MR2 = Coef0*Sin(K)
|
||||
; MR3 = Coef0*Sin(K) + X*Coef1*Cos(K) + X^2*Coef2*Sin(K) + X^3*Coef3*Cos(K)
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = X*Coef0*Sin(K) + X^2*Coef1*Cos(K) + X^3*Coef2*Sin(K) + X^4*Coef3*Cos(K)
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#-64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|
||||
; MR3 = Cos(K) + X^1*Coef0*Sin(K) + X^2*Coef1*Cos(K)
|
||||
; + X^3*Coef2*Sin(K) + X^4*Coef3*Cos(K)
|
||||
;
|
||||
; MR3 = X*Cos(K) + X^2*Coef0*Sin(K) + X^3*Coef1*Cos(K)
|
||||
; + X^4*Coef2*Sin(K) + X^5*Coef3*Cos(K)
|
||||
;
|
||||
; MR2 = Sin(K)
|
||||
;
|
||||
; MR3 = Sin(K) + X*Cos(K) + X^2*Coef0*Sin(K) + X^3*Coef1*Cos(K)
|
||||
; + X^4*Coef2*Sin(K) + X^5*Coef3*Cos(K)
|
||||
MADDF32 MR3,MR3,MR2
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR2,*MAR0[#0]++
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MADDF32 MR3,MR2,MR3
|
||||
MMOV32 MR0,MR3 ; Store Y = Sin(rad)
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,232 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAsinPU.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA sine Per Unit function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description: Implement sine using taylor series expansion:
|
||||
;;
|
||||
;; radPU = K + X
|
||||
;;
|
||||
;; rad = radPU * PI
|
||||
;;
|
||||
;; Sin(rad) = Sin(K) + Cos(K)*X
|
||||
;; - Sin(K)*X^2/2!
|
||||
;; - Cos(K)*X^3/3!
|
||||
;; + Sin(K)*X^4/4!
|
||||
;; + Cos(K)*X^5/5!
|
||||
;;
|
||||
;; = Sin(K) + X*(Cos(K)
|
||||
;; + X*(-0.5*Sin(K)
|
||||
;; + X*(-0.166666*Cos(K)
|
||||
;; + X*(0.04166666*Sin(K)
|
||||
;; + X*(0.00833333*Cos(K))))))
|
||||
;;
|
||||
;; = Sin(K) + X*(Cos(K)
|
||||
;; + X*(Coef0*Sin(K)
|
||||
;; + X*(Coef1*Cos(K)
|
||||
;; + X*(Coef2*Sin(K)
|
||||
;; + X*(Coef3*Cos(K))))))
|
||||
;;
|
||||
;;
|
||||
;; Equation: y = Sin(rad)
|
||||
;; Regs Used: MAR0, MR0, MR1, MR2, MR3
|
||||
;; Input: rad f32 value in memory
|
||||
;;
|
||||
;; // TABLE_SIZE = 128
|
||||
;; CLAsincosTable.Sin0 = 0.0; // sin( 0 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin1 = 0.04906767432742; // sin( 1 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin31 = 0.9987954562052; // sin( 31 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos0 = 1.0; // sin( 32 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin33 = 0.9987954562052; // sin( 33 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin63 = 0.04906767432742; // sin( 63 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin64 = 0.0; // sin( 64 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin65 = -0.04906767432742; // sin( 65 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin95 = -0.9987954562052; // sin( 95 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin96 = -1.0; // sin( 96 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin97 = -0.9987954562052; // sin( 97 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin127 = -0.04906767432742; // sin(127 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos96 = 0.0; // sin( 0 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos97 = 0.04906767432742; // sin( 1 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Cos127 = 0.9987954562052; // sin( 31 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos128 = 1.0; // sin( 32 * 2*pi/TABLE_SIZE)
|
||||
;;
|
||||
;; CLAsincosTable.TwoPiDivTABLE_SIZE = 0.04908738521234;
|
||||
;; CLAsincosTable.TABLE_MASK = 0x000000FE;
|
||||
;;
|
||||
;; CLAsincosTable.Coef0 = -0.5;
|
||||
;; CLAsincosTable.Coef1 = -0.1666666666666;
|
||||
;; CLAsincosTable.Coef1_pos = 0.1666666666666;
|
||||
;; CLAsincosTable.Coef2 = 4.1666666666666e-2;
|
||||
;; CLAsincosTable.Coef3 = 8.3333333333333e-3;
|
||||
;; CLAsincosTable.Coef3_neg = -8.3333333333333e-3;
|
||||
;;
|
||||
;; Output: y f32 value in memory
|
||||
;; MR0 = y f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 28
|
||||
;; Instructions = 28
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAsinPU
|
||||
.sect "Cla1Prog:_CLAsinPU"
|
||||
.align 2
|
||||
.def __cla_CLAsinPU_sp
|
||||
__cla_CLAsinPU_sp .usect ".scratchpad:Cla1Prog:_CLAsinPU",2,0,1
|
||||
|
||||
_CLAsinPU:
|
||||
.asmfunc
|
||||
.asg __cla_CLAsinPU_sp + 0, _save_MR3
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
|
||||
; MR0 = radPU
|
||||
; MR1 = TABLE_SIZE*2Pi/(2*Pi)
|
||||
; MR1 = rad*TABLE_SIZE*2Pi/(2*Pi)
|
||||
; MR2 = TABLE_MASK
|
||||
MMOV32 MR1,@_CLAsincosTable_TABLE_SIZE
|
||||
MMPYF32 MR1,MR0,MR1
|
||||
|| MMOV32 MR2,@_CLAsincosTable_TABLE_MASK
|
||||
|
||||
; MR3 = K = integer(rad*TABLE_SIZE*Pi/(2*Pi))
|
||||
; MR3 = K & TABLE_MASK
|
||||
; MR3 = K * 2
|
||||
; MAR0 = address of Cos(K)
|
||||
MF32TOI32 MR3,MR1
|
||||
MAND32 MR3,MR3,MR2
|
||||
MLSL32 MR3,#1
|
||||
MMOV16 MAR0,MR3,#_CLAsincosTable_Cos0
|
||||
|
||||
; MR1 = frac(TABLE_SIZE*radPU*2Pi/2*Pi)
|
||||
; MR0 = 2*Pi/TABLE_SIZE
|
||||
; MR1 = X = frac(TABLE_SIZE*radPU*2Pi/2*Pi) * (2*Pi/TABLE_SIZE)
|
||||
; MR0 = Coef3
|
||||
MFRACF32 MR1,MR1
|
||||
MMOV32 MR0,@_CLAsincosTable_TwoPiDivTABLE_SIZE
|
||||
MMPYF32 MR1,MR1,MR0
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef3
|
||||
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = Coef3*Cos(K)
|
||||
; MR2 = Sin(K)
|
||||
; MR3 = X*Coef3*Cos(K)
|
||||
MMOV32 MR2,*MAR0[#-64]++
|
||||
MMPYF32 MR3,MR0,MR2
|
||||
|| MMOV32 MR2,*MAR0[#+64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef2
|
||||
|
||||
; MR2 = Coef2*Sin(K)
|
||||
; MR3 = Coef2*Sin(K) + X*Coef3*Cos(K)
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = X*Coef2*Sin(K) + X^2*Coef3*Cos(K)
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#-64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef1
|
||||
|
||||
; MR2 = Coef1*Cos(K)
|
||||
; MR3 = Coef1*Cos(K) + X*Coef2*Sin(K) + X^2*Coef3*Cos(K)
|
||||
; MR2 = Sin(K)
|
||||
; MR3 = X*Coef1*Cos(K) + X^2*Coef2*Sin(K) + X^3*Coef3*Cos(K)
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#+64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef0
|
||||
|
||||
; MR2 = Coef0*Sin(K)
|
||||
; MR3 = Coef0*Sin(K) + X*Coef1*Cos(K) + X^2*Coef2*Sin(K) + X^3*Coef3*Cos(K)
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = X*Coef0*Sin(K) + X^2*Coef1*Cos(K) + X^3*Coef2*Sin(K) + X^4*Coef3*Cos(K)
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#-64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|
||||
; MR3 = Cos(K) + X^1*Coef0*Sin(K) + X^2*Coef1*Cos(K)
|
||||
; + X^3*Coef2*Sin(K) + X^4*Coef3*Cos(K)
|
||||
;
|
||||
; MR3 = X*Cos(K) + X^2*Coef0*Sin(K) + X^3*Coef1*Cos(K)
|
||||
; + X^4*Coef2*Sin(K) + X^5*Coef3*Cos(K)
|
||||
;
|
||||
; MR2 = Sin(K)
|
||||
;
|
||||
; MR3 = Sin(K) + X*Cos(K) + X^2*Coef0*Sin(K) + X^3*Coef1*Cos(K)
|
||||
; + X^4*Coef2*Sin(K) + X^5*Coef3*Cos(K)
|
||||
MADDF32 MR3,MR3,MR2
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR2,*MAR0[#0]++
|
||||
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MADDF32 MR3,MR2,MR3
|
||||
MMOV32 MR0,MR3 ; Store Y = SinPU(radPU)
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,350 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAsincos.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA sincos function
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description: Implement sine + cosine using taylor series expansion:
|
||||
;;
|
||||
;; rad = K + X
|
||||
;;
|
||||
;; Cos(rad) = Cos(K) - Sin(K)*X
|
||||
;; - Cos(K)*X^2/2!
|
||||
;; + Sin(K)*X^3/3!
|
||||
;; + Cos(K)*X^4/4!
|
||||
;; - Sin(K)*X^5/5!
|
||||
;;
|
||||
;; = Cos(K) + X*(-1.0*Sin(K)
|
||||
;; + X*(-0.5*Cos(K)
|
||||
;; + X*(0.166666*Sin(K)
|
||||
;; + X*(0.04166666*Cos(K)
|
||||
;; + X*(-0.00833333*Sin(K))))))
|
||||
;;
|
||||
;; = Cos(K) + X*(-Sin(K)
|
||||
;; + X*(Coef0*Cos(K)
|
||||
;; + X*(Coef1_pos*Sin(K)
|
||||
;; + X*(Coef2*Cos(K)
|
||||
;; + X*(Coef3_neg*Sin(K))))))
|
||||
;;
|
||||
;;
|
||||
;; Sin(rad) = Sin(K) + Cos(K)*X
|
||||
;; - Sin(K)*X^2/2!
|
||||
;; - Cos(K)*X^3/3!
|
||||
;; + Sin(K)*X^4/4!
|
||||
;; + Cos(K)*X^5/5!
|
||||
;;
|
||||
;; = Sin(K) + X*(Cos(K)
|
||||
;; + X*(-0.5*Sin(K)
|
||||
;; + X*(-0.166666*Cos(K)
|
||||
;; + X*(0.04166666*Sin(K)
|
||||
;; + X*(0.00833333*Cos(K))))))
|
||||
;;
|
||||
;; = Sin(K) + X*(Cos(K)
|
||||
;; + X*(Coef0*Sin(K)
|
||||
;; + X*(Coef1*Cos(K)
|
||||
;; + X*(Coef2*Sin(K)
|
||||
;; + X*(Coef3*Cos(K))))))
|
||||
;;
|
||||
;; Equation: y1 = sin(rad)
|
||||
;; y2 = cos(rad)
|
||||
;;
|
||||
;; Regs Used: MR0, MR1, MR2, MR3, MAR0, MAR1
|
||||
;;
|
||||
;; Inputs : rad (MR0), *y1 (MAR0), *y2 (MAR1)
|
||||
;;
|
||||
;; // TABLE_SIZE = 128
|
||||
;; CLAsincosTable.Sin0 = 0.0; // sin( 0 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin1 = 0.04906767432742; // sin( 1 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin31 = 0.9987954562052; // sin( 31 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos0 = 1.0; // sin( 32 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin33 = 0.9987954562052; // sin( 33 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin63 = 0.04906767432742; // sin( 63 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin64 = 0.0; // sin( 64 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin65 = -0.04906767432742; // sin( 65 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin95 = -0.9987954562052; // sin( 95 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin96 = -1.0; // sin( 96 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Sin97 = -0.9987954562052; // sin( 97 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Sin127 = -0.04906767432742; // sin(127 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos96 = 0.0; // sin( 0 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos97 = 0.04906767432742; // sin( 1 * 2*pi/TABLE_SIZE)
|
||||
;; ...
|
||||
;; CLAsincosTable.Cos127 = 0.9987954562052; // sin( 31 * 2*pi/TABLE_SIZE)
|
||||
;; CLAsincosTable.Cos128 = 1.0; // sin( 32 * 2*pi/TABLE_SIZE)
|
||||
;;
|
||||
;; CLAsincosTable.TABLE_SIZEDivPi = 40.74366543152;
|
||||
;; CLAsincosTable.TwoPiDivTABLE_SIZE = 0.04908738521234;
|
||||
;; CLAsincosTable.TABLE_MASK = 0x000000FE;
|
||||
;;
|
||||
;; CLAsincosTable.Coef0 = -0.5;
|
||||
;; CLAsincosTable.Coef1 = -0.1666666666666;
|
||||
;; CLAsincosTable.Coef1_pos = 0.1666666666666;
|
||||
;; CLAsincosTable.Coef2 = 4.1666666666666e-2;
|
||||
;; CLAsincosTable.Coef3 = 8.3333333333333e-3;
|
||||
;; CLAsincosTable.Coef3_neg = -8.3333333333333e-3;
|
||||
;;
|
||||
;; Output: y1 (y_sin) and y2 (y_cos) f32 value in memory
|
||||
;;
|
||||
;; Benchmark: Cycles = 43
|
||||
;; Instructions = 43
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- sincos temporary variable 2 (SP+6)
|
||||
;; |_______|<- sincos temporary variable 1 (SP+4)
|
||||
;; |_______|<- *y2 (SP+3)
|
||||
;; |_______|<- *y1 (SP+2)
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
.def _CLAsincos
|
||||
.sect "Cla1Prog:_CLAsincos"
|
||||
.align 2
|
||||
.def __cla_CLAsincos_sp
|
||||
__cla_CLAsincos_sp .usect ".scratchpad:Cla1Prog:_CLAsincos",8,0,1
|
||||
|
||||
_CLAsincos:
|
||||
.asmfunc
|
||||
.asg __cla_CLAsincos_sp + 0, _save_MR3
|
||||
.asg __cla_CLAsincos_sp + 2, _ptr_y1
|
||||
.asg __cla_CLAsincos_sp + 3, _ptr_y2
|
||||
.asg __cla_CLAsincos_sp + 4, _sincos_tmp1
|
||||
.asg __cla_CLAsincos_sp + 6, _sincos_tmp2
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
MMOV16 @_ptr_y1, MAR0
|
||||
MMOV16 @_ptr_y2, MAR1
|
||||
|
||||
; MR0 = rad
|
||||
; MR1 = TABLE_SIZE/(2*Pi)
|
||||
; MR1 = rad*TABLE_SIZE/(2*Pi)
|
||||
; MR2 = TABLE_MASK
|
||||
; MR3 = K = integer(rad*TABLE_SIZE/(2*Pi))
|
||||
; MR3 = K & TABLE_MASK
|
||||
; MR3 = K * 2
|
||||
MMOV32 MR1,@_CLAsincosTable_TABLE_SIZEDivTwoPi
|
||||
MMPYF32 MR1,MR0,MR1
|
||||
|| MMOV32 MR2,@_CLAsincosTable_TABLE_MASK
|
||||
MF32TOI32 MR3,MR1
|
||||
MAND32 MR3,MR3,MR2
|
||||
MLSL32 MR3,#1
|
||||
|
||||
; MAR0 = address of Cos(K)
|
||||
; MR1 = frac(TABLE_SIZE*rad/2*Pi)
|
||||
; MR0 = 2*Pi/TABLE_SIZE
|
||||
; MR1 = X = frac(TABLE_SIZE*rad/2*Pi) * (2*Pi/TABLE_SIZE)
|
||||
; MR0 = Coef3
|
||||
MMOV16 MAR0,MR3,#_CLAsincosTable_Cos0
|
||||
MFRACF32 MR1,MR1
|
||||
MMOV32 MR0,@_CLAsincosTable_TwoPiDivTABLE_SIZE
|
||||
MMPYF32 MR1,MR1,MR0
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef3
|
||||
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = Coef3*Cos(K)
|
||||
; MR2 = Sin(K)
|
||||
; MR3 = X*Coef3*Cos(K)
|
||||
; MR0 = Coef3_neg
|
||||
MMOV32 MR2,*MAR0[#-64]++
|
||||
MMPYF32 MR3,MR0,MR2
|
||||
|| MMOV32 MR2,*MAR0[#+64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0, @_CLAsincosTable_Coef3_neg
|
||||
|
||||
; MR3 = Coef3_neg*Sin(K)
|
||||
; tmp1 = X*Coef3*Cos(K)
|
||||
; MR3 = X*Coef3_neg*Sin(K)
|
||||
; MR0 = Coef2
|
||||
; MR2 = Coef2*Sin(K)
|
||||
; tmp2 = X*Coef3*Sin(K)
|
||||
MMPYF32 MR3,MR0,MR2
|
||||
|| MMOV32 @_sincos_tmp1, MR3
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef2
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
|| MMOV32 @_sincos_tmp2, MR3
|
||||
|
||||
; MR3 = X*Coef3*Cos(K)
|
||||
; MR3 = Coef2*Sin(K) + X*Coef3*Cos(K)
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = X*Coef2*Sin(K) + X^2*Coef3*Cos(K)
|
||||
; MR0 = Coef2*Cos(K)
|
||||
; tmp1 = X*Coef2*Sin(K) + X^2*Coef3*Cos(K)
|
||||
MMOV32 MR3, @_sincos_tmp1
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#-64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
MMPYF32 MR0, MR0, MR2
|
||||
|| MMOV32 @_sincos_tmp1, MR3
|
||||
|
||||
; MR3 = X*Coef3*Sin(K)
|
||||
; MR3 = Coef2*Cos(K) + X*Coef3_neg*Sin(K)
|
||||
; MR3 = X*Coef2*Cos(K) - X^2*Coef3*Sin(K)
|
||||
; MR0 = Coef1
|
||||
; MR2 = Coef1*Cos(K)
|
||||
; tmp2 = X*Coef2*Cos(K) - X^2*Coef3*Sin(K)
|
||||
MMOV32 MR3, @_sincos_tmp2
|
||||
MADDF32 MR3, MR0, MR3
|
||||
MMPYF32 MR3, MR3, MR1
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef1
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
|| MMOV32 @_sincos_tmp2, MR3
|
||||
|
||||
; MR3 = X*Coef2*Sin(K) + X^2*Coef3*Cos(K) (G)+(F)
|
||||
; MR3 = Coef1*Cos(K) + X*Coef2*Sin(K) + X^2*Coef3*Cos(K)
|
||||
; MR2 = Sin(K)
|
||||
; MR3 = X*Coef1*Cos(K) + X^2*Coef2*Sin(K) + X^3*Coef3*Cos(K)
|
||||
; MR0 = Coef1_pos
|
||||
; MR0 = Coef1_pos*Sin(K)
|
||||
; tmp1 = X*Coef1*Cos(K) + X^2*Coef2*Sin(K) + X^3*Coef3*Cos(K)
|
||||
MMOV32 MR3, @_sincos_tmp1
|
||||
MADDF32 MR3,MR3,MR2
|
||||
|| MMOV32 MR2,*MAR0[#+64]++
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|| MMOV32 MR0, @_CLAsincosTable_Coef1_pos
|
||||
MMPYF32 MR0, MR0, MR2
|
||||
|| MMOV32 @_sincos_tmp1, MR3
|
||||
|
||||
; MR3 = X*Coef2*Cos(K) + X^2*Coef3_neg*Sin(K) (B)-(A)
|
||||
; MR3 = Coef1-pos*Sin(K) + X*Coef2*Cos(K) + X^2*Coef3_neg*Sin(K)
|
||||
; MR3 = X*Coef1_pos*Sin(K) + X^2*Coef2*Cos(K) + X^3*Coef3_neg*Sin(K)
|
||||
; MR0 = Coef0
|
||||
; MR2 = Coef0*Sin(K)
|
||||
; tmp2 = X*Coef1_pos*Sin(K) + X^2*Coef2*Cos(K) + X^3*Coef3_neg*Sin(K)
|
||||
; MR3 = X*Coef1*Cos(K) + X^2*Coef2*Sin(K) + X^3*Coef3*Cos(K)
|
||||
MMOV32 MR3, @_sincos_tmp2
|
||||
MADDF32 MR3, MR0, MR3
|
||||
MMPYF32 MR3, MR1, MR3
|
||||
|| MMOV32 MR0,@_CLAsincosTable_Coef0
|
||||
|
||||
MMPYF32 MR2,MR0,MR2
|
||||
|| MMOV32 @_sincos_tmp2, MR3
|
||||
|
||||
MMOV32 MR3, @_sincos_tmp1
|
||||
|
||||
|
||||
; MR3 = Coef0*Sin(K) + X*Coef1*Cos(K) + X^2*Coef2*Sin(K)
|
||||
; + X^3*Coef3*Cos(K)
|
||||
;
|
||||
; MR2 = Cos(K)
|
||||
;
|
||||
; MR3 = X*Coef0*Sin(K) + X^2*Coef1*Cos(K)
|
||||
; + X^3*Coef2*Sin(K) + X^4*Coef3*Cos(K)
|
||||
;
|
||||
; MR3 = Cos(K) + X^1*Coef0*Sin(K) + X^2*Coef1*Cos(K)
|
||||
; + X^3*Coef2*Sin(K) + X^4*Coef3*Cos(K)
|
||||
;
|
||||
; MR3 = X*Cos(K) + X^2*Coef0*Sin(K) + X^3*Coef1*Cos(K)
|
||||
; + X^4*Coef2*Sin(K) + X^5*Coef3*Cos(K)
|
||||
MADDF32 MR3, MR2, MR3
|
||||
|| MMOV32 MR2,*MAR0[#-64]++
|
||||
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
MADDF32 MR3,MR3,MR2
|
||||
MMOV16 MAR1, @_ptr_y1
|
||||
MMPYF32 MR3,MR3,MR1
|
||||
|
||||
; MR0 = Coef0*Cos(K)
|
||||
; MR2 = Sin(K)
|
||||
|
||||
; MR3 = Sin(K) + X*Cos(K) + X^2*Coef0*Sin(K)
|
||||
; + X^3*Coef1*Cos(K) + X^4*Coef2*Sin(K) + X^5*Coef3*Cos(K)
|
||||
; Store Y1 = Sin(rad)
|
||||
;
|
||||
; MR3 = X*Coef1_pos*Sin(K) + X^2*Coef2*Cos(K) + X^3*Coef3_neg*Sin(K)
|
||||
MMPYF32 MR0, MR0, MR2
|
||||
|| MMOV32 MR2,*MAR0[#+64]++
|
||||
|
||||
MADDF32 MR3,MR2,MR3
|
||||
MMOV32 *MAR1[#0]++, MR3
|
||||
|
||||
MMOV32 MR3, @_sincos_tmp2
|
||||
|
||||
; MR3 = Coef0*Cos(K) + X*Coef1_pos*Sin(K) + X^2*Coef2*Cos(K)
|
||||
; + X^3*Coef3_neg*Sin(K)
|
||||
;
|
||||
; MR3 = X*Coef0*Cos(K) + X^2*Coef1_pos*Sin(K)
|
||||
; + X^3*Coef2*Cos(K) + X^4*Coef3_neg*Sin(K)
|
||||
;
|
||||
; MR3 = -Sin(K)+X*Coef0*Cos(K) + X^2*Coef1_pos*Sin(K)
|
||||
; + X^3*Coef2*Cos(K) + X^4*Coef3_neg*Sin(K)
|
||||
;
|
||||
; MR2 = Cos(K)
|
||||
; MR3 = -X*Sin(K) + X^2*Coef0*Cos(K) + X^3*Coef1_pos*Sin(K)
|
||||
; + X^4*Coef2*Cos(K) + X^5*Coef3_neg*Sin(K)
|
||||
;
|
||||
; MR3 = Cos(K) - X*Sin(K) + X^2*Coef0*Cos(K) + X^3*Coef1_pos*Sin(K)
|
||||
; + X^4*Coef2*Cos(K) + X^5*Coef3_neg*Sin(K)
|
||||
; Store Y2 = Cos(rad)
|
||||
MADDF32 MR3, MR0, MR3
|
||||
MMPYF32 MR3, MR1, MR3
|
||||
MMOV16 MAR1, @_ptr_y2
|
||||
MSUBF32 MR3, MR3, MR2
|
||||
|| MMOV32 MR2,*MAR0[#0]++
|
||||
MMPYF32 MR3, MR1, MR3
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MADDF32 MR3, MR2, MR3
|
||||
MMOV32 *MAR1[#0]++, MR3
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.unasg _ptr_y1
|
||||
.unasg _ptr_y2
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
@@ -0,0 +1,259 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLASinCosTable.asm
|
||||
;;
|
||||
;; DESCRIPTION: Sine and Cosine Tables
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
.def _CLAsincosTable
|
||||
.def _CLAsinTable
|
||||
.def _CLAsincosTable_Sin0
|
||||
.def _CLAcosTable
|
||||
.def _CLAsincosTable_Cos0
|
||||
.def _CLAsinTableEnd
|
||||
.def _CLAcosTableEnd
|
||||
.def _CLAsincosTable_TABLE_SIZE
|
||||
.def _CLAsincosTable_TABLE_SIZEDivTwoPi
|
||||
.def _CLAsincosTable_TwoPiDivTABLE_SIZE
|
||||
.def _CLAsincosTable_TABLE_MASK
|
||||
.def _CLAsincosTable_Coef0
|
||||
.def _CLAsincosTable_Coef1
|
||||
.def _CLAsincosTable_Coef1_pos
|
||||
.def _CLAsincosTable_Coef2
|
||||
.def _CLAsincosTable_Coef3
|
||||
.def _CLAsincosTable_Coef3_neg
|
||||
.def _CLAsincosTableEnd
|
||||
|
||||
.sect "CLA1mathTables"
|
||||
|
||||
_CLAsincosTable:
|
||||
_CLAsinTable:
|
||||
_CLAsincosTable_Sin0:
|
||||
.float 0.0; ; sin( 0 * 2*pi/TABLE_SIZE)
|
||||
.float 0.04906767432742; ; sin( 1 * 2*pi/TABLE_SIZE)
|
||||
.float 0.09801714032956; ; sin( 2 * 2*pi/TABLE_SIZE)
|
||||
.float 0.1467304744553; ; sin( 3 * 2*pi/TABLE_SIZE)
|
||||
.float 0.1950903220162; ; sin( 4 * 2*pi/TABLE_SIZE)
|
||||
.float 0.2429801799032; ; sin( 5 * 2*pi/TABLE_SIZE)
|
||||
.float 0.2902846772544; ; sin( 6 * 2*pi/TABLE_SIZE)
|
||||
.float 0.3368898533922; ; sin( 7 * 2*pi/TABLE_SIZE)
|
||||
.float 0.3826834323651; ; sin( 8 * 2*pi/TABLE_SIZE)
|
||||
.float 0.4275550934303; ; sin( 9 * 2*pi/TABLE_SIZE)
|
||||
.float 0.4713967368260; ; sin( 10 * 2*pi/TABLE_SIZE)
|
||||
.float 0.5141027441932; ; sin( 11 * 2*pi/TABLE_SIZE)
|
||||
.float 0.5555702330196; ; sin( 12 * 2*pi/TABLE_SIZE)
|
||||
.float 0.5956993044925; ; sin( 13 * 2*pi/TABLE_SIZE)
|
||||
.float 0.6343932841637; ; sin( 14 * 2*pi/TABLE_SIZE)
|
||||
.float 0.6715589548470; ; sin( 15 * 2*pi/TABLE_SIZE)
|
||||
.float 0.7071067811865; ; sin( 16 * 2*pi/TABLE_SIZE)
|
||||
.float 0.7409511253549; ; sin( 17 * 2*pi/TABLE_SIZE)
|
||||
.float 0.7730104533627; ; sin( 18 * 2*pi/TABLE_SIZE)
|
||||
.float 0.8032075314806; ; sin( 19 * 2*pi/TABLE_SIZE)
|
||||
.float 0.8314696123026; ; sin( 20 * 2*pi/TABLE_SIZE)
|
||||
.float 0.8577286100001; ; sin( 21 * 2*pi/TABLE_SIZE)
|
||||
.float 0.8819212643481; ; sin( 22 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9039892931235; ; sin( 23 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9238795325113; ; sin( 24 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9415440651832; ; sin( 25 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9569403357322; ; sin( 26 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9700312531945; ; sin( 27 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9807852804033; ; sin( 28 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9891765099649; ; sin( 29 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9951847266721; ; sin( 30 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9987954562052; ; sin( 31 * 2*pi/TABLE_SIZE)
|
||||
|
||||
_CLAcosTable:
|
||||
_CLAsincosTable_Cos0:
|
||||
.float 1.0; ; sin( 32 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9987954562052; ; sin( 33 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9951847266721; ; sin( 34 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9891765099649; ; sin( 35 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9807852804033; ; sin( 36 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9700312531945; ; sin( 37 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9569403357322; ; sin( 38 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9415440651832; ; sin( 39 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9238795325113; ; sin( 40 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9039892931235; ; sin( 41 * 2*pi/TABLE_SIZE)
|
||||
.float 0.8819212643481; ; sin( 42 * 2*pi/TABLE_SIZE)
|
||||
.float 0.8577286100001; ; sin( 43 * 2*pi/TABLE_SIZE)
|
||||
.float 0.8314696123026; ; sin( 44 * 2*pi/TABLE_SIZE)
|
||||
.float 0.8032075314806; ; sin( 45 * 2*pi/TABLE_SIZE)
|
||||
.float 0.7730104533627; ; sin( 46 * 2*pi/TABLE_SIZE)
|
||||
.float 0.7409511253549; ; sin( 47 * 2*pi/TABLE_SIZE)
|
||||
.float 0.7071067811865; ; sin( 48 * 2*pi/TABLE_SIZE)
|
||||
.float 0.6715589548470; ; sin( 49 * 2*pi/TABLE_SIZE)
|
||||
.float 0.6343932841637; ; sin( 50 * 2*pi/TABLE_SIZE)
|
||||
.float 0.5956993044925; ; sin( 51 * 2*pi/TABLE_SIZE)
|
||||
.float 0.5555702330196; ; sin( 52 * 2*pi/TABLE_SIZE)
|
||||
.float 0.5141027441932; ; sin( 53 * 2*pi/TABLE_SIZE)
|
||||
.float 0.4713967368260; ; sin( 54 * 2*pi/TABLE_SIZE)
|
||||
.float 0.4275550934303; ; sin( 55 * 2*pi/TABLE_SIZE)
|
||||
.float 0.3826834323651; ; sin( 56 * 2*pi/TABLE_SIZE)
|
||||
.float 0.3368898533922; ; sin( 57 * 2*pi/TABLE_SIZE)
|
||||
.float 0.2902846772544; ; sin( 58 * 2*pi/TABLE_SIZE)
|
||||
.float 0.2429801799032; ; sin( 59 * 2*pi/TABLE_SIZE)
|
||||
.float 0.1950903220162; ; sin( 60 * 2*pi/TABLE_SIZE)
|
||||
.float 0.1467304744553; ; sin( 61 * 2*pi/TABLE_SIZE)
|
||||
.float 0.09801714032956; ; sin( 62 * 2*pi/TABLE_SIZE)
|
||||
.float 0.04906767432742; ; sin( 63 * 2*pi/TABLE_SIZE)
|
||||
.float 0.0; ; sin( 64 * 2*pi/TABLE_SIZE)
|
||||
.float -0.04906767432742; ; sin( 65 * 2*pi/TABLE_SIZE)
|
||||
.float -0.09801714032956; ; sin( 66 * 2*pi/TABLE_SIZE)
|
||||
.float -0.1467304744553; ; sin( 67 * 2*pi/TABLE_SIZE)
|
||||
.float -0.1950903220162; ; sin( 68 * 2*pi/TABLE_SIZE)
|
||||
.float -0.2429801799032; ; sin( 69 * 2*pi/TABLE_SIZE)
|
||||
.float -0.2902846772544; ; sin( 70 * 2*pi/TABLE_SIZE)
|
||||
.float -0.3368898533922; ; sin( 71 * 2*pi/TABLE_SIZE)
|
||||
.float -0.3826834323651; ; sin( 72 * 2*pi/TABLE_SIZE)
|
||||
.float -0.4275550934303; ; sin( 73 * 2*pi/TABLE_SIZE)
|
||||
.float -0.4713967368260; ; sin( 74 * 2*pi/TABLE_SIZE)
|
||||
.float -0.5141027441932; ; sin( 75 * 2*pi/TABLE_SIZE)
|
||||
.float -0.5555702330196; ; sin( 76 * 2*pi/TABLE_SIZE)
|
||||
.float -0.5956993044925; ; sin( 77 * 2*pi/TABLE_SIZE)
|
||||
.float -0.6343932841637; ; sin( 78 * 2*pi/TABLE_SIZE)
|
||||
.float -0.6715589548470; ; sin( 79 * 2*pi/TABLE_SIZE)
|
||||
.float -0.7071067811865; ; sin( 80 * 2*pi/TABLE_SIZE)
|
||||
.float -0.7409511253549; ; sin( 81 * 2*pi/TABLE_SIZE)
|
||||
.float -0.7730104533627; ; sin( 82 * 2*pi/TABLE_SIZE)
|
||||
.float -0.8032075314806; ; sin( 83 * 2*pi/TABLE_SIZE)
|
||||
.float -0.8314696123026; ; sin( 84 * 2*pi/TABLE_SIZE)
|
||||
.float -0.8577286100001; ; sin( 85 * 2*pi/TABLE_SIZE)
|
||||
.float -0.8819212643481; ; sin( 86 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9039892931235; ; sin( 87 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9238795325113; ; sin( 88 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9415440651832; ; sin( 89 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9569403357322; ; sin( 90 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9700312531945; ; sin( 91 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9807852804033; ; sin( 92 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9891765099649; ; sin( 93 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9951847266721; ; sin( 94 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9987954562052; ; sin( 95 * 2*pi/TABLE_SIZE)
|
||||
.float -1.0; ; sin( 96 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9987954562052; ; sin( 97 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9951847266721; ; sin( 98 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9891765099649; ; sin( 99 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9807852804033; ; sin(100 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9700312531945; ; sin(101 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9569403357322; ; sin(102 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9415440651832; ; sin(103 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9238795325113; ; sin(104 * 2*pi/TABLE_SIZE)
|
||||
.float -0.9039892931235; ; sin(105 * 2*pi/TABLE_SIZE)
|
||||
.float -0.8819212643481; ; sin(106 * 2*pi/TABLE_SIZE)
|
||||
.float -0.8577286100001; ; sin(107 * 2*pi/TABLE_SIZE)
|
||||
.float -0.8314696123026; ; sin(108 * 2*pi/TABLE_SIZE)
|
||||
.float -0.8032075314806; ; sin(109 * 2*pi/TABLE_SIZE)
|
||||
.float -0.7730104533627; ; sin(110 * 2*pi/TABLE_SIZE)
|
||||
.float -0.7409511253549; ; sin(111 * 2*pi/TABLE_SIZE)
|
||||
.float -0.7071067811865; ; sin(112 * 2*pi/TABLE_SIZE)
|
||||
.float -0.6715589548470; ; sin(113 * 2*pi/TABLE_SIZE)
|
||||
.float -0.6343932841637; ; sin(114 * 2*pi/TABLE_SIZE)
|
||||
.float -0.5956993044925; ; sin(115 * 2*pi/TABLE_SIZE)
|
||||
.float -0.5555702330196; ; sin(116 * 2*pi/TABLE_SIZE)
|
||||
.float -0.5141027441932; ; sin(117 * 2*pi/TABLE_SIZE)
|
||||
.float -0.4713967368260; ; sin(118 * 2*pi/TABLE_SIZE)
|
||||
.float -0.4275550934303; ; sin(119 * 2*pi/TABLE_SIZE)
|
||||
.float -0.3826834323651; ; sin(120 * 2*pi/TABLE_SIZE)
|
||||
.float -0.3368898533922; ; sin(121 * 2*pi/TABLE_SIZE)
|
||||
.float -0.2902846772544; ; sin(122 * 2*pi/TABLE_SIZE)
|
||||
.float -0.2429801799032; ; sin(123 * 2*pi/TABLE_SIZE)
|
||||
.float -0.1950903220162; ; sin(124 * 2*pi/TABLE_SIZE)
|
||||
.float -0.1467304744553; ; sin(125 * 2*pi/TABLE_SIZE)
|
||||
.float -0.09801714032956; ; sin(126 * 2*pi/TABLE_SIZE)
|
||||
.float -0.04906767432742; ; sin(127 * 2*pi/TABLE_SIZE)
|
||||
_CLAsinTableEnd:
|
||||
.float 0.0; ; sin( 0 * 2*pi/TABLE_SIZE)
|
||||
.float 0.04906767432742; ; sin( 1 * 2*pi/TABLE_SIZE)
|
||||
.float 0.09801714032956; ; sin( 2 * 2*pi/TABLE_SIZE)
|
||||
.float 0.1467304744553; ; sin( 3 * 2*pi/TABLE_SIZE)
|
||||
.float 0.1950903220162; ; sin( 4 * 2*pi/TABLE_SIZE)
|
||||
.float 0.2429801799032; ; sin( 5 * 2*pi/TABLE_SIZE)
|
||||
.float 0.2902846772544; ; sin( 6 * 2*pi/TABLE_SIZE)
|
||||
.float 0.3368898533922; ; sin( 7 * 2*pi/TABLE_SIZE)
|
||||
.float 0.3826834323651; ; sin( 8 * 2*pi/TABLE_SIZE)
|
||||
.float 0.4275550934303; ; sin( 9 * 2*pi/TABLE_SIZE)
|
||||
.float 0.4713967368260; ; sin( 10 * 2*pi/TABLE_SIZE)
|
||||
.float 0.5141027441932; ; sin( 11 * 2*pi/TABLE_SIZE)
|
||||
.float 0.5555702330196; ; sin( 12 * 2*pi/TABLE_SIZE)
|
||||
.float 0.5956993044925; ; sin( 13 * 2*pi/TABLE_SIZE)
|
||||
.float 0.6343932841637; ; sin( 14 * 2*pi/TABLE_SIZE)
|
||||
.float 0.6715589548470; ; sin( 15 * 2*pi/TABLE_SIZE)
|
||||
.float 0.7071067811865; ; sin( 16 * 2*pi/TABLE_SIZE)
|
||||
.float 0.7409511253549; ; sin( 17 * 2*pi/TABLE_SIZE)
|
||||
.float 0.7730104533627; ; sin( 18 * 2*pi/TABLE_SIZE)
|
||||
.float 0.8032075314806; ; sin( 19 * 2*pi/TABLE_SIZE)
|
||||
.float 0.8314696123026; ; sin( 20 * 2*pi/TABLE_SIZE)
|
||||
.float 0.8577286100001; ; sin( 21 * 2*pi/TABLE_SIZE)
|
||||
.float 0.8819212643481; ; sin( 22 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9039892931235; ; sin( 23 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9238795325113; ; sin( 24 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9415440651832; ; sin( 25 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9569403357322; ; sin( 26 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9700312531945; ; sin( 27 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9807852804033; ; sin( 28 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9891765099649; ; sin( 29 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9951847266721; ; sin( 30 * 2*pi/TABLE_SIZE)
|
||||
.float 0.9987954562052; ; sin( 31 * 2*pi/TABLE_SIZE)
|
||||
.float 1.0; ; sin( 32 * 2*pi/TABLE_SIZE)
|
||||
_CLAcosTableEnd:
|
||||
|
||||
|
||||
_CLAsincosTable_TABLE_SIZE .float 128.0
|
||||
_CLAsincosTable_TABLE_SIZEDivTwoPi .float 20.37183271576
|
||||
_CLAsincosTable_TwoPiDivTABLE_SIZE .float 0.04908738521234
|
||||
_CLAsincosTable_TABLE_MASK .long 0x0000007F;
|
||||
_CLAsincosTable_Coef0 .float -0.5;
|
||||
_CLAsincosTable_Coef1 .float -0.1666666666666;
|
||||
_CLAsincosTable_Coef1_pos .float 0.1666666666666;
|
||||
_CLAsincosTable_Coef2 .float 4.1666666666666e-2;
|
||||
_CLAsincosTable_Coef3 .float 8.3333333333333e-3;
|
||||
_CLAsincosTable_Coef3_neg .float -8.3333333333333e-3;
|
||||
_CLAsincosTableEnd:
|
||||
|
||||
;; End of File
|
||||
@@ -0,0 +1,116 @@
|
||||
;;#############################################################################
|
||||
;; FILE: CLAsqrt.asm
|
||||
;;
|
||||
;; DESCRIPTION: CLA square root function using Newton Raphson
|
||||
;; Approximation
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;----------------------------------------------------------------------------
|
||||
;; Description: Implement square root using Newton-Raphson Method
|
||||
;;
|
||||
;; Equation: y = sqrt(x)
|
||||
;;
|
||||
;; Regs Used: MR0, MR1, MR2, MR3
|
||||
;;
|
||||
;; Input: x f32 value in memory
|
||||
;;
|
||||
;; Output: y f32 value in memory
|
||||
;; MR0 = y f32 result
|
||||
;;
|
||||
;; Benchmark: Cycles = 16
|
||||
;; Instructions = 16
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- square root temporary variable (SP+2)
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;;----------------------------------------------------------------------------
|
||||
|
||||
|
||||
.def _CLAsqrt
|
||||
.sect "Cla1Prog:_CLAsqrt"
|
||||
.align 2
|
||||
.def __cla_CLAsqrt_sp
|
||||
__cla_CLAsqrt_sp .usect ".scratchpad:Cla1Prog:_CLAsqrt",4,0,1
|
||||
|
||||
_CLAsqrt:
|
||||
.asmfunc
|
||||
.asg __cla_CLAsqrt_sp + 0, _save_MR3
|
||||
.asg __cla_CLAsqrt_sp + 2, _sqrt_tmp
|
||||
; Context Save
|
||||
MMOV32 @_save_MR3, MR3
|
||||
MMOV32 MR0, MR0 ; Dummy load of MR0 will set/clear ZF
|
||||
; useful if the compiler load is done with
|
||||
; a MUInTOF32 which does not alter the ZF bit
|
||||
; MR0 = Number
|
||||
MEISQRTF32 MR1,MR0 ; MR1 = Ye = Estimate(1/sqrt(X))
|
||||
MMOV32 MR1,MR0,EQ ; if(X == 0.0) Ye = 0.0
|
||||
MMPYF32 MR3,MR0,#0.5 ; MR3 = X*0.5
|
||||
MMPYF32 MR2,MR1,MR3 ; MR2 = Ye*X*0.5
|
||||
MMPYF32 MR2,MR1,MR2 ; MR2 = Ye*Ye*X*0.5
|
||||
MSUBF32 MR2,#1.5,MR2 ; MR2 = 1.5 - Ye*Ye*X*0.5
|
||||
MMPYF32 MR1,MR1,MR2 ; MR1 = Ye = Ye*(1.5 - Ye*Ye*X*0.5)
|
||||
MMPYF32 MR2,MR1,MR3 ; MR2 = Ye*X*0.5
|
||||
MMPYF32 MR2,MR1,MR2 ; MR2 = Ye*Ye*X*0.5
|
||||
MSUBF32 MR2,#1.5,MR2 ; MR2 = 1.5 - Ye*Ye*X*0.5
|
||||
; Context Restore and Final Operations
|
||||
MRCNDD UNC
|
||||
MMPYF32 MR1,MR1,MR2 ; MR1 = Ye = Ye*(1.5 - Ye*Ye*X*0.5)
|
||||
MMPYF32 MR0,MR1,MR0 ; MR0 = Y = Ye*X
|
||||
MMOV32 MR3,@_save_MR3
|
||||
.unasg _save_MR3
|
||||
.unasg _sqrt_tmp
|
||||
.endasmfunc
|
||||
|
||||
;; End of File
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,377 @@
|
||||
;;#############################################################################
|
||||
;;
|
||||
;; FILE: cla_fft_unpack_256.asm
|
||||
;;
|
||||
;; TITLE: 256-pt Complex FFT Spectrum Unpack for the C2000 real-time CLA CPU
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
;;
|
||||
;;*****************************************************************************
|
||||
;; includes
|
||||
;;*****************************************************************************
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;*****************************************************************************
|
||||
;; globals
|
||||
;;*****************************************************************************
|
||||
.global _CLA_CFFT_unpack256Pt
|
||||
.ref _cla_twiddleFactors
|
||||
.ref _IOBuffer
|
||||
.ref _IOBuffer2
|
||||
|
||||
;;*****************************************************************************
|
||||
;; global defines
|
||||
;;*****************************************************************************
|
||||
;; FFT Routine defines
|
||||
TWIDDLES_TBL_SIZE .set 1024 ; size of twiddle factor table
|
||||
NCSTAGES .set 8 ; # of complex stages in the CFFT
|
||||
NCSAMPLES .set (1 << NCSTAGES) ; # of complex samples to unpack
|
||||
NSAMPLES .set (1 <<(NCSTAGES+1)); # of real samples
|
||||
|
||||
; If the user changes the name of the buffers in the header files it must be
|
||||
; changed here and the code rebuilt
|
||||
I_BUFFER .set _IOBuffer
|
||||
O_BUFFER .set _IOBuffer2
|
||||
; skipfactor = tbl_size/size_of_rfft * 2(complex)*2(words per float)
|
||||
; where size_of_rfft = 2 * size_of_cfft
|
||||
SKIPFACTOR .set 4*(TWIDDLES_TBL_SIZE/(NCSAMPLES*2))
|
||||
DEBUG_BRKPT_ENABLE .set 0x0
|
||||
;;*****************************************************************************
|
||||
;; macros
|
||||
;;*****************************************************************************
|
||||
SET_BRKPT_AT_ITER .macro ITER
|
||||
.if DEBUG_BRKPT_ENABLE
|
||||
MNOP
|
||||
MMOVZ16 MR0, @LOOP_COUNTER ; set ZF = 1 if loop count = 0
|
||||
MMOVIZ MR1, #0
|
||||
MMOVXI MR1, #(NSAMPLES/4 - :ITER: - 1 + 1)
|
||||
MCMP32 MR0, MR1
|
||||
MNOP
|
||||
MNOP
|
||||
MNOP
|
||||
MBCNDD _skip_bkpt_:ITER:, NEQ ; if count != 100 skipfactor
|
||||
MNOP
|
||||
MNOP
|
||||
MNOP
|
||||
MNOP
|
||||
MNOP
|
||||
MNOP
|
||||
MDEBUGSTOP
|
||||
MNOP
|
||||
MNOP
|
||||
MNOP
|
||||
_skip_bkpt_:ITER:
|
||||
.endif ;;DEBUG_BRKPT_ENABLE
|
||||
.endm
|
||||
|
||||
;;*****************************************************************************
|
||||
;; function definitions
|
||||
;;*****************************************************************************
|
||||
.sect "Cla1Prog:_CLA_CFFT_unpack256Pt"
|
||||
.align 2
|
||||
__CLA_CFFT_unpack256Pt_sp .usect ".scratchpad:Cla1Prog:_CLA_CFFT_unpack256Pt",14,0,1
|
||||
|
||||
;;
|
||||
;; \brief Run the unpack function on a 1024 point complex spectrum to get
|
||||
;; half of the spectrum of the 2048 point real data (original)
|
||||
;;
|
||||
;;! \note
|
||||
;;! -# This is an off-place algorithm
|
||||
;;! -# Since this function follows an FFT the input buffer must have been
|
||||
;;! aligned to a 12-bit address, usually the starting address of one of the
|
||||
;;! CLA data RAMs
|
||||
;;! -# The complex data has real-first ordering i.e. the real part occupies
|
||||
;;! the lower double word
|
||||
;;! -# This function expects the FFT buffers to be global (to both
|
||||
;;! the C28 and CLA) and to be named "IOBuffer" and "IOBuffer2" respectively.
|
||||
;;! If the user desires to change the name, the macros I_BUFFER and O_BUFFER
|
||||
;;! must be altered in the source assembly to reflect the new name and the
|
||||
;;! code rebuilt
|
||||
;;! -# In the loops the code does two extra reads beyond the end of the
|
||||
;;! twiddle factor table. Ensure that atleast 4 words after the twiddle
|
||||
;;! factor table are within CLA accessible data RAM. If using the tables in
|
||||
;;! Data ROM this is not an issue as the bit reversal tables follow the
|
||||
;;! twiddle table and you end up reading the first two entries of that
|
||||
;;! table instead
|
||||
;;
|
||||
;; \return FFT of the real input in the I/O buffer
|
||||
;;
|
||||
;; Register Usage:
|
||||
;; MR0: Used in complex calculations
|
||||
;; MR1: Used in complex calculations
|
||||
;; MR2: Used in complex calculations
|
||||
;; MR3: Used in complex calculations
|
||||
;; MAR0: Input/Output pointer to the buffer
|
||||
;; MAR1: Input/Output pointer to the buffer, pointer to twiddles
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- PTR_OUTPUT (SP+13)
|
||||
;; |_______|<- PTR_TWIDDLES (SP+12)
|
||||
;; |_______|<- COS (SP+10)
|
||||
;; |_______|<- SIN (SP+8)
|
||||
;; |_______|<- MAR1 (SP+6)
|
||||
;; |_______|<- MAR0 (SP+5)
|
||||
;; |_______|<- loop counter (SP+4)
|
||||
;; |_______|<- RS (SP+2)
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;; #cycles = 20 + 36*loop_1Q_count + 8 + 36*loop_2Q_count + 4
|
||||
;; = 20 + 36*254 + 8 + 36*255 + 4
|
||||
;; = 18356
|
||||
;;
|
||||
_CLA_CFFT_unpack256Pt:
|
||||
.asmfunc
|
||||
.asg __CLA_CFFT_unpack256Pt_sp + 0, SCRATCH_MR3
|
||||
.asg __CLA_CFFT_unpack256Pt_sp + 2, RS_TEMP
|
||||
.asg __CLA_CFFT_unpack256Pt_sp + 4, LOOP_COUNTER
|
||||
.asg __CLA_CFFT_unpack256Pt_sp + 5, SCRATCH_MAR0
|
||||
.asg __CLA_CFFT_unpack256Pt_sp + 6, SCRATCH_MAR1
|
||||
.asg __CLA_CFFT_unpack256Pt_sp + 8, SCRATCH_SIN
|
||||
.asg __CLA_CFFT_unpack256Pt_sp + 10, SCRATCH_COS
|
||||
.asg __CLA_CFFT_unpack256Pt_sp + 12, PTR_TWIDDLES
|
||||
.asg __CLA_CFFT_unpack256Pt_sp + 13, PTR_OUTPUT
|
||||
;; |Order of access
|
||||
;; MAR0 starts at F[0].r |
|
||||
.asg 2 , I0_NEXT ; MAR0 -> F[0].i | 1, 3
|
||||
.asg -2 , R0_NEXT ; MAR0 -> F[0].r | 2
|
||||
.asg 2 , R0_NEXT_1 ; MAR0 -> F[1].r | 4
|
||||
;; |Order of access
|
||||
;; MAR1 starts at F[N/2].r|
|
||||
.asg 2 , IN_O_2_M_K_NEXT ; MAR1 -> F[N/2].i | 1, 3
|
||||
.asg -2 , RN_O_2_M_K_NEXT ; MAR1 -> F[N/2].r | 2
|
||||
.asg -6 , RN_O_2_M_K_NEXT_1; MAR1 -> F[N/2-1].r| 4
|
||||
.if DEBUG_BRKPT_ENABLE
|
||||
MDEBUGSTOP
|
||||
.endif ;;DEBUG_BRKPT_ENABLE
|
||||
MMOV32 @SCRATCH_MR3, MR3 ; Save MR3 on entry
|
||||
;; Note N is the number of real samples N = 1024
|
||||
MMOV32 MR0, @I_BUFFER+0 ; MR0 = Z[0].r
|
||||
MMOV32 MR1, @I_BUFFER+2 ; MR0 = Z[0].i
|
||||
MMOVIZ MR3, #0 ; MR3 = 0
|
||||
MADDF32 MR2, MR0, MR1 ; MR0 = Z[0].r + Z[0].i
|
||||
|| MMOV32 @O_BUFFER+2, MR3 ; Save F[0].i = 0
|
||||
MSUBF32 MR1, MR0, MR1 ; MR1 = Z[0].r - Z[0].i
|
||||
|| MMOV32 @O_BUFFER+0, MR2 ; Save F[0].r
|
||||
MMOV32 @O_BUFFER+4*(NCSAMPLES), MR1 ; Save F[N/2].r
|
||||
MMOV32 @O_BUFFER+4*(NCSAMPLES)+2, MR3 ; Save F[N/2].i = 0
|
||||
MMOVI16 MAR0, #I_BUFFER+4 ; MAR0 -> Z[1].r
|
||||
MMOVI16 MAR1, #I_BUFFER+((NSAMPLES/2-1)*4) ; MAR1 -> Z[N/2-1].r
|
||||
; MR3.L = IOBuffer2+4 (F[1].r), MR3.H = 0
|
||||
MMOVXI MR3, #O_BUFFER+4
|
||||
MMOV16 @PTR_OUTPUT, MR3
|
||||
; MR3.L = twiddle_tbl + 2*skipfactor, MR3.H = 0
|
||||
MMOVXI MR3, #_cla_twiddleFactors+2*SKIPFACTOR
|
||||
MMOV16 @PTR_TWIDDLES, MR3 ; Save to the twiddle pointer
|
||||
MMOV32 MR0, @_cla_twiddleFactors+SKIPFACTOR
|
||||
MMOV32 @SCRATCH_SIN, MR0 ; MR0 = SIN, save to scratchpad
|
||||
MMOV32 MR0, @_cla_twiddleFactors+SKIPFACTOR+2
|
||||
MMOV32 @SCRATCH_COS, MR0 ; MR0 = COS, save to scratchpad
|
||||
|
||||
;; | Order of access
|
||||
;; MAR0 starts at F[k].r |
|
||||
.asg 2 , I0_NEXT ; MAR0 -> F[k].i | 1, 3
|
||||
.asg 2 , R0_NEXT_1 ; MAR0 -> F[k+1].r | 2, 4
|
||||
;; | Order of access
|
||||
;; MAR1 starts at F[N/2-k].r |
|
||||
.asg 2 , IN_O_2_M_K_NEXT ; MAR0 -> F[N/2-k].i | 1
|
||||
.asg -6, RN_O_2_M_K_NEXT_1 ; MAR0 -> F[N/2-k-1].r | 2
|
||||
|
||||
|
||||
MMOVI32 MR0, #(NSAMPLES/4-2) ; 1| MR0 = NSAMPLES/4 - 2
|
||||
MMOV16 @LOOP_COUNTER, MR0 ; 2|
|
||||
; 3| first instruction of loop
|
||||
_CLA_CFFT_unpack256Pt_loop_1Q:
|
||||
SET_BRKPT_AT_ITER 255
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
;| unpack for k = 1 to N/4-1 | MR0 | MR1 | MR2 | MR3 | MAR0 | MAR1 |
|
||||
;| cycles = 36 | | | | | | |
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
;| | | | |Z[k].r |Z[N/2-k].r |
|
||||
MMOV32 MR1, *MAR1[IN_O_2_M_K_NEXT]++ ;| |Z[N/2-k].r | | | |Z[N/2-k].i |
|
||||
MMOV32 MR0, *MAR0[I0_NEXT]++ ;|Z[k].r | | | |Z[k].i | |
|
||||
MSUBF32 MR2, MR0, MR1 ;| | |RS=Z[k].r-Z[N/2-k].r| | | |
|
||||
|| MMOV32 MR3, @SCRATCH_SIN ;| | | |SIN or S | | |
|
||||
MMPYF32 MR3, MR3, MR2 ;| | | |S*RS | | |
|
||||
|| MADDF32 MR0, MR0, MR1 ;|RA=Z[k].r+Z[N/2-k].r|free | | | | |
|
||||
MSUBF32 MR0, MR0, MR3 ;|RA-S*RS | | |free | | |
|
||||
|| MMOV32 MR1, *MAR0[R0_NEXT_1]++ ;| |Z[k].i | | |Z[k+1].r | |
|
||||
MMOV16 @SCRATCH_MAR0, MAR0 ;|----Save MAR0 to scratchpad--------------|---------------------------------------------------------|
|
||||
MMOV16 MAR0, @PTR_OUTPUT ;|----MAR0 -> output--------------------------------------------------------|F[k].r |------------|
|
||||
MMOV32 MR3, *MAR1[RN_O_2_M_K_NEXT_1]++ ;| | | |Z[N/2-k].i | |Z[N/2-k-1].r|
|
||||
MADDF32 MR2, MR1, MR3 ;| | |IA=Z[k].i+Z[N/2-k].i| | | |
|
||||
|| MMOV32 @RS_TEMP, MR2 ;| | |IA (RS saved) | | | |
|
||||
MSUBF32 MR1, MR1, MR3 ;| |IS=Z[k].i-Z[N/2-k].i| |free | | |
|
||||
|| MMOV32 MR3, @SCRATCH_COS ;| | | |COS or C | | |
|
||||
MMPYF32 MR3, MR3, MR2 ;| | | |C*IA | | |
|
||||
MADDF32 MR0, MR0, MR3 ;|RA-S*RS+C*IA | | |free | | |
|
||||
|| MMOV32 MR3, @SCRATCH_SIN ;| | | |S | | |
|
||||
MMPYF32 MR2, MR3, MR2 ;| | |S*IA |free | | |
|
||||
MMOV32 MR3, @RS_TEMP ;| | | |RS | | |
|
||||
MMPYF32 MR0, #0.5, MR0 ;|0.5*(RA-S*RS+C*IA) | | | | | |
|
||||
MSUBF32 MR1, MR1, MR2 ;| |IS-S*IA |free | | | |
|
||||
|| MMOV32 MR2, @SCRATCH_COS ;| | |C | | | |
|
||||
MMPYF32 MR2, MR2, MR3 ;| | |C *RS |free | | |
|
||||
|| MMOV32 *MAR0[I0_NEXT]++, MR0 ;|free(saved) | | | |F[k].i | |
|
||||
MMOV16 @SCRATCH_MAR1, MAR1 ;|----Save MAR1 to scratchpad--------------|---------------------------------------------------------|
|
||||
MMOV16 MAR1, @PTR_TWIDDLES ;|----MAR1 -> twiddles-------------------------------------------------------------------------------|
|
||||
MSUBF32 MR1, MR1, MR2 ;| |IS-S*IA-C*RS |free | | | |
|
||||
MMPYF32 MR1, #0.5, MR1 ;| |0.5*(IS-S*IA-C*RS) | | | | |
|
||||
MMOV32 *MAR0[R0_NEXT_1]++, MR1 ;|free |free(saved) |free |free |F[k+1].r | |
|
||||
MMOV16 @PTR_OUTPUT, MAR0 ;|----Save MAR0 to Output Pointer--------------------------------------------------------------------|
|
||||
MMOV16 MAR0, @SCRATCH_MAR0 ;|----Restore MAR0----------------------------------------------------------|Z[k+1].r |------------|
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
;| State of registers |free |free |free |free |Z[k+1].r |Z[N/2-k-1].r|
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
MMOV32 MR0, *MAR1[2]++ ; MR0 = SIN, save to scratchpad
|
||||
MMOV32 @SCRATCH_SIN, MR0 ;
|
||||
MMOV32 MR0, *MAR1[SKIPFACTOR-2]++ ; MR0 = COS, save to scratchpad
|
||||
MMOV32 @SCRATCH_COS, MR0 ;
|
||||
MMOVZ16 MR0, @LOOP_COUNTER ; set ZF = 1 if loop count = 0
|
||||
MMOV16 @PTR_TWIDDLES, MAR1 ;-1| Save to the twiddle pointer
|
||||
MMOV16 MAR1, @SCRATCH_MAR1 ;-2|*| Restore MAR1
|
||||
MMOVIZ MR1, #0 ;-3|1|
|
||||
MBCNDD _CLA_CFFT_unpack256Pt_loop_1Q, NEQ ; *|2| Branch if loop count != 0
|
||||
MMOVXI MR1, #1 ;-2|3|
|
||||
MSUB32 MR0, MR0, MR1 ;-1| loop counter --
|
||||
MMOV32 @LOOP_COUNTER, MR0 ;+1|
|
||||
|
||||
.if DEBUG_BRKPT_ENABLE
|
||||
MDEBUGSTOP
|
||||
.endif ;;DEBUG_BRKPT_ENABLE
|
||||
; Reset the twiddle pointers
|
||||
; MR1.L = twiddle_tbl + skipfactor, MR1.H = 0 from last loop
|
||||
MMOVXI MR1, #_cla_twiddleFactors+SKIPFACTOR
|
||||
MMOV16 @PTR_TWIDDLES, MR1
|
||||
MMOV32 MR0, @_cla_twiddleFactors+0
|
||||
MMOV32 @SCRATCH_SIN, MR0
|
||||
MMOV32 MR0, @_cla_twiddleFactors+2
|
||||
MMOV32 @SCRATCH_COS, MR0
|
||||
|
||||
MMOVI32 MR0, #(NSAMPLES/4-1) ; MR0 = NSAMPLES/4-1
|
||||
MMOV16 @LOOP_COUNTER, MR0
|
||||
_CLA_CFFT_unpack256Pt_loop_2Q:
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
;| unpack for k = N/4 to N/2-1 | MR0 | MR1 | MR2 | MR3 | MAR0 | MAR1 |
|
||||
;| For the second quadrant the twiddles have the | | | | | | |
|
||||
;| following relationship | | | | | | |
|
||||
;| COS = -SIN and SIN = COS | | | | | | |
|
||||
;| cycles = 36 | | | | | | |
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
;| | | | |Z[k].r |Z[N/2-k].r |
|
||||
MMOV32 MR1, *MAR1[IN_O_2_M_K_NEXT]++ ;| |Z[N/2-k].r | | | |Z[N/2-k].i |
|
||||
MMOV32 MR0, *MAR0[I0_NEXT]++ ;|Z[k].r | | | |Z[k].i | |
|
||||
MSUBF32 MR2, MR0, MR1 ;| | |RS=Z[k].r-Z[N/2-k].r| | | |
|
||||
|| MMOV32 MR3, @SCRATCH_COS ;| | | |COS or C | | |
|
||||
MMPYF32 MR3, MR3, MR2 ;| | | |C*RS | | |
|
||||
|| MADDF32 MR0, MR0, MR1 ;|RA=Z[k].r+Z[N/2-k].r|free | | | | |
|
||||
MSUBF32 MR0, MR0, MR3 ;|RA-C*RS | | |free | | |
|
||||
|| MMOV32 MR1, *MAR0[R0_NEXT_1]++ ;| |Z[k].i | | |Z[k+1].r | |
|
||||
MMOV16 @SCRATCH_MAR0, MAR0 ;|----Save MAR0 to scratchpad--------------|---------------------------------------------------------|
|
||||
MMOV16 MAR0, @PTR_OUTPUT ;|----MAR0 -> output--------------------------------------------------------|F[k].r |------------|
|
||||
MMOV32 MR3, *MAR1[RN_O_2_M_K_NEXT_1]++ ;| | | |Z[N/2-k].i | |Z[N/2-k-1].r|
|
||||
MADDF32 MR2, MR1, MR3 ;| | |IA=Z[k].i+Z[N/2-k].i| | | |
|
||||
|| MMOV32 @RS_TEMP, MR2 ;| | |IA (RS saved) | | | |
|
||||
MSUBF32 MR1, MR1, MR3 ;| |IS=Z[k].i-Z[N/2-k].i| |free | | |
|
||||
|| MMOV32 MR3, @SCRATCH_SIN ;| | | |SIN or S | | |
|
||||
MMPYF32 MR3, MR3, MR2 ;| | | |S*IA | | |
|
||||
MSUBF32 MR0, MR0, MR3 ;|RA-C*RS-S*IA | | |free | | |
|
||||
|| MMOV32 MR3, @SCRATCH_COS ;| | | |C | | |
|
||||
MMPYF32 MR2, MR3, MR2 ;| | |C*IA |free | | |
|
||||
MMOV32 MR3, @RS_TEMP ;| | | |RS | | |
|
||||
MMPYF32 MR0, #0.5, MR0 ;|0.5*(RA-C*RS-S*IA) | | | | | |
|
||||
MSUBF32 MR1, MR1, MR2 ;| |IS-C*IA |free | | | |
|
||||
|| MMOV32 MR2, @SCRATCH_SIN ;| | |S | | | |
|
||||
MMPYF32 MR2, MR2, MR3 ;| | |S*RS |free | | |
|
||||
|| MMOV32 *MAR0[I0_NEXT]++, MR0 ;|free(saved) | | | |F[k].i | |
|
||||
MMOV16 @SCRATCH_MAR1, MAR1 ;|----Save MAR1 to scratchpad--------------| | | | |
|
||||
MMOV16 MAR1, @PTR_TWIDDLES ;|----MAR1 -> twiddles---------------------| | | | |
|
||||
MADDF32 MR1, MR1, MR2 ;| |IS-C*IA+S*RS |free | | | |
|
||||
MMPYF32 MR1, #0.5, MR1 ;| |0.5*(IS-C*IA+S*RS) | | | | |
|
||||
MMOV32 *MAR0[R0_NEXT_1]++, MR1 ;|free |free(saved) |free |free |F[k+1].r | |
|
||||
MMOV16 @PTR_OUTPUT, MAR0 ;|----Save MAR0 to Output Pointer--------------------------------------------------------------------|
|
||||
MMOV16 MAR0, @SCRATCH_MAR0 ;|----Restore MAR0----------------------------------------------------------|Z[k+1].r |------------|
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
;| State of registers |free |free |free |free |Z[k+1].r |Z[N/2-k-1].r|
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
MMOV32 MR0, *MAR1[2]++ ; MR0 = SIN, save to scratchpad
|
||||
MMOV32 @SCRATCH_SIN, MR0 ;
|
||||
MMOV32 MR0, *MAR1[SKIPFACTOR-2]++ ; MR0 = COS, save to scratchpad
|
||||
MMOV32 @SCRATCH_COS, MR0 ;
|
||||
MMOVZ16 MR0, @LOOP_COUNTER ; set ZF = 1 if loop count = 0
|
||||
MMOV16 @PTR_TWIDDLES, MAR1 ;-1| Save to the twiddle pointer
|
||||
MMOV16 MAR1, @SCRATCH_MAR1 ;-2|*| Restore MAR1
|
||||
MMOVIZ MR1, #0 ;-3|1|
|
||||
MBCNDD _CLA_CFFT_unpack256Pt_loop_2Q, NEQ ; *| Branch if loop count != 0
|
||||
MMOVXI MR1, #1 ;-2|3|
|
||||
MSUB32 MR0, MR0, MR1 ;-1| loop counter --
|
||||
MMOV32 @LOOP_COUNTER, MR0 ;+1|
|
||||
|
||||
MRCNDD UNC
|
||||
MMOV32 MR3, @SCRATCH_MR3 ; Restore MR3
|
||||
MNOP
|
||||
MNOP
|
||||
.unasg I0_NEXT
|
||||
.unasg R0_NEXT_1
|
||||
.unasg IN_O_2_M_K_NEXT
|
||||
.unasg RN_O_2_M_K_NEXT
|
||||
.unasg RN_O_2_M_K_NEXT_1
|
||||
.unasg SCRATCH_MR3
|
||||
.unasg RS_TEMP
|
||||
.unasg LOOP_COUNTER
|
||||
.unasg SCRATCH_MAR0
|
||||
.unasg SCRATCH_MAR1
|
||||
.unasg SCRATCH_SIN
|
||||
.unasg SCRATCH_COS
|
||||
.unasg PTR_TWIDDLES
|
||||
.endasmfunc
|
||||
|
||||
;; End of file
|
||||
@@ -0,0 +1,377 @@
|
||||
;;#############################################################################
|
||||
;;
|
||||
;; FILE: cla_fft_unpack_512.asm
|
||||
;;
|
||||
;; TITLE: 512-pt Complex FFT Spectrum Unpack for the C2000 real-time CLA CPU
|
||||
;;
|
||||
;;#############################################################################
|
||||
;;!
|
||||
;;! Copyright: Copyright (C) 2023 Texas Instruments Incorporated -
|
||||
;;! All rights reserved not granted herein.
|
||||
;;! Limited License.
|
||||
;;!
|
||||
;;! Texas Instruments Incorporated grants a world-wide, royalty-free,
|
||||
;;! non-exclusive license under copyrights and patents it now or hereafter
|
||||
;;! owns or controls to make, have made, use, import, offer to sell and sell
|
||||
;;! ("Utilize") this software subject to the terms herein. With respect to the
|
||||
;;! foregoing patent license, such license is granted solely to the extent that
|
||||
;;! any such patent is necessary to Utilize the software alone. The patent
|
||||
;;! license shall not apply to any combinations which include this software,
|
||||
;;! other than combinations with devices manufactured by or for TI
|
||||
;;! ("TI Devices").
|
||||
;;! No hardware patent is licensed hereunder.
|
||||
;;!
|
||||
;;! Redistributions must preserve existing copyright notices and reproduce this
|
||||
;;! license (including the above copyright notice and the disclaimer and
|
||||
;;! (if applicable) source code license limitations below) in the documentation
|
||||
;;! and/or other materials provided with the distribution.
|
||||
;;!
|
||||
;;! Redistribution and use in binary form, without modification, are permitted
|
||||
;;! provided that the following conditions are met:
|
||||
;;!
|
||||
;;! * No reverse engineering, decompilation, or disassembly of this software is
|
||||
;;! permitted with respect to any software provided in binary form.
|
||||
;;! * Any redistribution and use are licensed by TI for use only
|
||||
;;! with TI Devices.
|
||||
;;! * Nothing shall obligate TI to provide you with source code for the
|
||||
;;! software licensed and provided to you in object code.
|
||||
;;!
|
||||
;;! If software source code is provided to you, modification and redistribution
|
||||
;;! of the source code are permitted provided that the following conditions
|
||||
;;! are met:
|
||||
;;!
|
||||
;;! * any redistribution and use of the source code, including any resulting
|
||||
;;! derivative works, are licensed by TI for use only with TI Devices.
|
||||
;;! * any redistribution and use of any object code compiled from the source
|
||||
;;! code and any resulting derivative works, are licensed by TI for use
|
||||
;;! only with TI Devices.
|
||||
;;!
|
||||
;;! Neither the name of Texas Instruments Incorporated nor the names of its
|
||||
;;! suppliers may be used to endorse or promote products derived from this
|
||||
;;! software without specific prior written permission.
|
||||
;;#############################################################################
|
||||
|
||||
;;
|
||||
;;*****************************************************************************
|
||||
;; includes
|
||||
;;*****************************************************************************
|
||||
|
||||
.cdecls C,LIST,"CLAmath.h"
|
||||
.include "CLAeabi.asm"
|
||||
|
||||
;;*****************************************************************************
|
||||
;; globals
|
||||
;;*****************************************************************************
|
||||
.global _CLA_CFFT_unpack512Pt
|
||||
.ref _cla_twiddleFactors
|
||||
.ref _IOBuffer
|
||||
.ref _IOBuffer2
|
||||
|
||||
;;*****************************************************************************
|
||||
;; global defines
|
||||
;;*****************************************************************************
|
||||
;; FFT Routine defines
|
||||
TWIDDLES_TBL_SIZE .set 1024 ; size of twiddle factor table
|
||||
NCSTAGES .set 9 ; # of complex stages in the CFFT
|
||||
NCSAMPLES .set (1 << NCSTAGES) ; # of complex samples to unpack
|
||||
NSAMPLES .set (1 <<(NCSTAGES+1)); # of real samples
|
||||
|
||||
; If the user changes the name of the buffers in the header files it must be
|
||||
; changed here and the code rebuilt
|
||||
I_BUFFER .set _IOBuffer
|
||||
O_BUFFER .set _IOBuffer2
|
||||
; skipfactor = tbl_size/size_of_rfft * 2(complex)*2(words per float)
|
||||
; where size_of_rfft = 2 * size_of_cfft
|
||||
SKIPFACTOR .set 4*(TWIDDLES_TBL_SIZE/(NCSAMPLES*2))
|
||||
DEBUG_BRKPT_ENABLE .set 0x0
|
||||
;;*****************************************************************************
|
||||
;; macros
|
||||
;;*****************************************************************************
|
||||
SET_BRKPT_AT_ITER .macro ITER
|
||||
.if DEBUG_BRKPT_ENABLE
|
||||
MNOP
|
||||
MMOVZ16 MR0, @LOOP_COUNTER ; set ZF = 1 if loop count = 0
|
||||
MMOVIZ MR1, #0
|
||||
MMOVXI MR1, #(NSAMPLES/4 - :ITER: - 1 + 1)
|
||||
MCMP32 MR0, MR1
|
||||
MNOP
|
||||
MNOP
|
||||
MNOP
|
||||
MBCNDD _skip_bkpt_:ITER:, NEQ ; if count != 100 skipfactor
|
||||
MNOP
|
||||
MNOP
|
||||
MNOP
|
||||
MNOP
|
||||
MNOP
|
||||
MNOP
|
||||
MDEBUGSTOP
|
||||
MNOP
|
||||
MNOP
|
||||
MNOP
|
||||
_skip_bkpt_:ITER:
|
||||
.endif ;;DEBUG_BRKPT_ENABLE
|
||||
.endm
|
||||
|
||||
;;*****************************************************************************
|
||||
;; function definitions
|
||||
;;*****************************************************************************
|
||||
.sect "Cla1Prog:_CLA_CFFT_unpack512Pt"
|
||||
.align 2
|
||||
__CLA_CFFT_unpack512Pt_sp .usect ".scratchpad:Cla1Prog:_CLA_CFFT_unpack512Pt",14,0,1
|
||||
|
||||
;;
|
||||
;; \brief Run the unpack function on a 1024 point complex spectrum to get
|
||||
;; half of the spectrum of the 2048 point real data (original)
|
||||
;;
|
||||
;;! \note
|
||||
;;! -# This is an off-place algorithm
|
||||
;;! -# Since this function follows an FFT the input buffer must have been
|
||||
;;! aligned to a 12-bit address, usually the starting address of one of the
|
||||
;;! CLA data RAMs
|
||||
;;! -# The complex data has real-first ordering i.e. the real part occupies
|
||||
;;! the lower double word
|
||||
;;! -# This function expects the FFT buffers to be global (to both
|
||||
;;! the C28 and CLA) and to be named "IOBuffer" and "IOBuffer2" respectively.
|
||||
;;! If the user desires to change the name, the macros I_BUFFER and O_BUFFER
|
||||
;;! must be altered in the source assembly to reflect the new name and the
|
||||
;;! code rebuilt
|
||||
;;! -# In the loops the code does two extra reads beyond the end of the
|
||||
;;! twiddle factor table. Ensure that atleast 4 words after the twiddle
|
||||
;;! factor table are within CLA accessible data RAM. If using the tables in
|
||||
;;! Data ROM this is not an issue as the bit reversal tables follow the
|
||||
;;! twiddle table and you end up reading the first two entries of that
|
||||
;;! table instead
|
||||
;;
|
||||
;; \return FFT of the real input in the I/O buffer
|
||||
;;
|
||||
;; Register Usage:
|
||||
;; MR0: Used in complex calculations
|
||||
;; MR1: Used in complex calculations
|
||||
;; MR2: Used in complex calculations
|
||||
;; MR3: Used in complex calculations
|
||||
;; MAR0: Input/Output pointer to the buffer
|
||||
;; MAR1: Input/Output pointer to the buffer, pointer to twiddles
|
||||
;;
|
||||
;; Scratchpad Usage: (Local Function Scratchpad Pointer (SP))
|
||||
;;
|
||||
;; |_______|<- PTR_OUTPUT (SP+13)
|
||||
;; |_______|<- PTR_TWIDDLES (SP+12)
|
||||
;; |_______|<- COS (SP+10)
|
||||
;; |_______|<- SIN (SP+8)
|
||||
;; |_______|<- MAR1 (SP+6)
|
||||
;; |_______|<- MAR0 (SP+5)
|
||||
;; |_______|<- loop counter (SP+4)
|
||||
;; |_______|<- RS (SP+2)
|
||||
;; |_______|<- MR3 (SP+0)
|
||||
;;
|
||||
;; #cycles = 20 + 36*loop_1Q_count + 8 + 36*loop_2Q_count + 4
|
||||
;; = 20 + 36*254 + 8 + 36*255 + 4
|
||||
;; = 18356
|
||||
;;
|
||||
_CLA_CFFT_unpack512Pt:
|
||||
.asmfunc
|
||||
.asg __CLA_CFFT_unpack512Pt_sp + 0, SCRATCH_MR3
|
||||
.asg __CLA_CFFT_unpack512Pt_sp + 2, RS_TEMP
|
||||
.asg __CLA_CFFT_unpack512Pt_sp + 4, LOOP_COUNTER
|
||||
.asg __CLA_CFFT_unpack512Pt_sp + 5, SCRATCH_MAR0
|
||||
.asg __CLA_CFFT_unpack512Pt_sp + 6, SCRATCH_MAR1
|
||||
.asg __CLA_CFFT_unpack512Pt_sp + 8, SCRATCH_SIN
|
||||
.asg __CLA_CFFT_unpack512Pt_sp + 10, SCRATCH_COS
|
||||
.asg __CLA_CFFT_unpack512Pt_sp + 12, PTR_TWIDDLES
|
||||
.asg __CLA_CFFT_unpack512Pt_sp + 13, PTR_OUTPUT
|
||||
;; |Order of access
|
||||
;; MAR0 starts at F[0].r |
|
||||
.asg 2 , I0_NEXT ; MAR0 -> F[0].i | 1, 3
|
||||
.asg -2 , R0_NEXT ; MAR0 -> F[0].r | 2
|
||||
.asg 2 , R0_NEXT_1 ; MAR0 -> F[1].r | 4
|
||||
;; |Order of access
|
||||
;; MAR1 starts at F[N/2].r|
|
||||
.asg 2 , IN_O_2_M_K_NEXT ; MAR1 -> F[N/2].i | 1, 3
|
||||
.asg -2 , RN_O_2_M_K_NEXT ; MAR1 -> F[N/2].r | 2
|
||||
.asg -6 , RN_O_2_M_K_NEXT_1; MAR1 -> F[N/2-1].r| 4
|
||||
.if DEBUG_BRKPT_ENABLE
|
||||
MDEBUGSTOP
|
||||
.endif ;;DEBUG_BRKPT_ENABLE
|
||||
MMOV32 @SCRATCH_MR3, MR3 ; Save MR3 on entry
|
||||
;; Note N is the number of real samples N = 1024
|
||||
MMOV32 MR0, @I_BUFFER+0 ; MR0 = Z[0].r
|
||||
MMOV32 MR1, @I_BUFFER+2 ; MR0 = Z[0].i
|
||||
MMOVIZ MR3, #0 ; MR3 = 0
|
||||
MADDF32 MR2, MR0, MR1 ; MR0 = Z[0].r + Z[0].i
|
||||
|| MMOV32 @O_BUFFER+2, MR3 ; Save F[0].i = 0
|
||||
MSUBF32 MR1, MR0, MR1 ; MR1 = Z[0].r - Z[0].i
|
||||
|| MMOV32 @O_BUFFER+0, MR2 ; Save F[0].r
|
||||
MMOV32 @O_BUFFER+4*(NCSAMPLES), MR1 ; Save F[N/2].r
|
||||
MMOV32 @O_BUFFER+4*(NCSAMPLES)+2, MR3 ; Save F[N/2].i = 0
|
||||
MMOVI16 MAR0, #I_BUFFER+4 ; MAR0 -> Z[1].r
|
||||
MMOVI16 MAR1, #I_BUFFER+((NSAMPLES/2-1)*4) ; MAR1 -> Z[N/2-1].r
|
||||
; MR3.L = IOBuffer2+4 (F[1].r), MR3.H = 0
|
||||
MMOVXI MR3, #O_BUFFER+4
|
||||
MMOV16 @PTR_OUTPUT, MR3
|
||||
; MR3.L = twiddle_tbl + 2*skipfactor, MR3.H = 0
|
||||
MMOVXI MR3, #_cla_twiddleFactors+2*SKIPFACTOR
|
||||
MMOV16 @PTR_TWIDDLES, MR3 ; Save to the twiddle pointer
|
||||
MMOV32 MR0, @_cla_twiddleFactors+SKIPFACTOR
|
||||
MMOV32 @SCRATCH_SIN, MR0 ; MR0 = SIN, save to scratchpad
|
||||
MMOV32 MR0, @_cla_twiddleFactors+SKIPFACTOR+2
|
||||
MMOV32 @SCRATCH_COS, MR0 ; MR0 = COS, save to scratchpad
|
||||
|
||||
;; | Order of access
|
||||
;; MAR0 starts at F[k].r |
|
||||
.asg 2 , I0_NEXT ; MAR0 -> F[k].i | 1, 3
|
||||
.asg 2 , R0_NEXT_1 ; MAR0 -> F[k+1].r | 2, 4
|
||||
;; | Order of access
|
||||
;; MAR1 starts at F[N/2-k].r |
|
||||
.asg 2 , IN_O_2_M_K_NEXT ; MAR0 -> F[N/2-k].i | 1
|
||||
.asg -6, RN_O_2_M_K_NEXT_1 ; MAR0 -> F[N/2-k-1].r | 2
|
||||
|
||||
|
||||
MMOVI32 MR0, #(NSAMPLES/4-2) ; 1| MR0 = NSAMPLES/4 - 2
|
||||
MMOV16 @LOOP_COUNTER, MR0 ; 2|
|
||||
; 3| first instruction of loop
|
||||
_CLA_CFFT_unpack512Pt_loop_1Q:
|
||||
SET_BRKPT_AT_ITER 255
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
;| unpack for k = 1 to N/4-1 | MR0 | MR1 | MR2 | MR3 | MAR0 | MAR1 |
|
||||
;| cycles = 36 | | | | | | |
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
;| | | | |Z[k].r |Z[N/2-k].r |
|
||||
MMOV32 MR1, *MAR1[IN_O_2_M_K_NEXT]++ ;| |Z[N/2-k].r | | | |Z[N/2-k].i |
|
||||
MMOV32 MR0, *MAR0[I0_NEXT]++ ;|Z[k].r | | | |Z[k].i | |
|
||||
MSUBF32 MR2, MR0, MR1 ;| | |RS=Z[k].r-Z[N/2-k].r| | | |
|
||||
|| MMOV32 MR3, @SCRATCH_SIN ;| | | |SIN or S | | |
|
||||
MMPYF32 MR3, MR3, MR2 ;| | | |S*RS | | |
|
||||
|| MADDF32 MR0, MR0, MR1 ;|RA=Z[k].r+Z[N/2-k].r|free | | | | |
|
||||
MSUBF32 MR0, MR0, MR3 ;|RA-S*RS | | |free | | |
|
||||
|| MMOV32 MR1, *MAR0[R0_NEXT_1]++ ;| |Z[k].i | | |Z[k+1].r | |
|
||||
MMOV16 @SCRATCH_MAR0, MAR0 ;|----Save MAR0 to scratchpad--------------|---------------------------------------------------------|
|
||||
MMOV16 MAR0, @PTR_OUTPUT ;|----MAR0 -> output--------------------------------------------------------|F[k].r |------------|
|
||||
MMOV32 MR3, *MAR1[RN_O_2_M_K_NEXT_1]++ ;| | | |Z[N/2-k].i | |Z[N/2-k-1].r|
|
||||
MADDF32 MR2, MR1, MR3 ;| | |IA=Z[k].i+Z[N/2-k].i| | | |
|
||||
|| MMOV32 @RS_TEMP, MR2 ;| | |IA (RS saved) | | | |
|
||||
MSUBF32 MR1, MR1, MR3 ;| |IS=Z[k].i-Z[N/2-k].i| |free | | |
|
||||
|| MMOV32 MR3, @SCRATCH_COS ;| | | |COS or C | | |
|
||||
MMPYF32 MR3, MR3, MR2 ;| | | |C*IA | | |
|
||||
MADDF32 MR0, MR0, MR3 ;|RA-S*RS+C*IA | | |free | | |
|
||||
|| MMOV32 MR3, @SCRATCH_SIN ;| | | |S | | |
|
||||
MMPYF32 MR2, MR3, MR2 ;| | |S*IA |free | | |
|
||||
MMOV32 MR3, @RS_TEMP ;| | | |RS | | |
|
||||
MMPYF32 MR0, #0.5, MR0 ;|0.5*(RA-S*RS+C*IA) | | | | | |
|
||||
MSUBF32 MR1, MR1, MR2 ;| |IS-S*IA |free | | | |
|
||||
|| MMOV32 MR2, @SCRATCH_COS ;| | |C | | | |
|
||||
MMPYF32 MR2, MR2, MR3 ;| | |C *RS |free | | |
|
||||
|| MMOV32 *MAR0[I0_NEXT]++, MR0 ;|free(saved) | | | |F[k].i | |
|
||||
MMOV16 @SCRATCH_MAR1, MAR1 ;|----Save MAR1 to scratchpad--------------|---------------------------------------------------------|
|
||||
MMOV16 MAR1, @PTR_TWIDDLES ;|----MAR1 -> twiddles-------------------------------------------------------------------------------|
|
||||
MSUBF32 MR1, MR1, MR2 ;| |IS-S*IA-C*RS |free | | | |
|
||||
MMPYF32 MR1, #0.5, MR1 ;| |0.5*(IS-S*IA-C*RS) | | | | |
|
||||
MMOV32 *MAR0[R0_NEXT_1]++, MR1 ;|free |free(saved) |free |free |F[k+1].r | |
|
||||
MMOV16 @PTR_OUTPUT, MAR0 ;|----Save MAR0 to Output Pointer--------------------------------------------------------------------|
|
||||
MMOV16 MAR0, @SCRATCH_MAR0 ;|----Restore MAR0----------------------------------------------------------|Z[k+1].r |------------|
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
;| State of registers |free |free |free |free |Z[k+1].r |Z[N/2-k-1].r|
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
MMOV32 MR0, *MAR1[2]++ ; MR0 = SIN, save to scratchpad
|
||||
MMOV32 @SCRATCH_SIN, MR0 ;
|
||||
MMOV32 MR0, *MAR1[SKIPFACTOR-2]++ ; MR0 = COS, save to scratchpad
|
||||
MMOV32 @SCRATCH_COS, MR0 ;
|
||||
MMOVZ16 MR0, @LOOP_COUNTER ; set ZF = 1 if loop count = 0
|
||||
MMOV16 @PTR_TWIDDLES, MAR1 ;-1| Save to the twiddle pointer
|
||||
MMOV16 MAR1, @SCRATCH_MAR1 ;-2|*| Restore MAR1
|
||||
MMOVIZ MR1, #0 ;-3|1|
|
||||
MBCNDD _CLA_CFFT_unpack512Pt_loop_1Q, NEQ ; *|2| Branch if loop count != 0
|
||||
MMOVXI MR1, #1 ;-2|3|
|
||||
MSUB32 MR0, MR0, MR1 ;-1| loop counter --
|
||||
MMOV32 @LOOP_COUNTER, MR0 ;+1|
|
||||
|
||||
.if DEBUG_BRKPT_ENABLE
|
||||
MDEBUGSTOP
|
||||
.endif ;;DEBUG_BRKPT_ENABLE
|
||||
; Reset the twiddle pointers
|
||||
; MR1.L = twiddle_tbl + skipfactor, MR1.H = 0 from last loop
|
||||
MMOVXI MR1, #_cla_twiddleFactors+SKIPFACTOR
|
||||
MMOV16 @PTR_TWIDDLES, MR1
|
||||
MMOV32 MR0, @_cla_twiddleFactors+0
|
||||
MMOV32 @SCRATCH_SIN, MR0
|
||||
MMOV32 MR0, @_cla_twiddleFactors+2
|
||||
MMOV32 @SCRATCH_COS, MR0
|
||||
|
||||
MMOVI32 MR0, #(NSAMPLES/4-1) ; MR0 = NSAMPLES/4-1
|
||||
MMOV16 @LOOP_COUNTER, MR0
|
||||
_CLA_CFFT_unpack512Pt_loop_2Q:
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
;| unpack for k = N/4 to N/2-1 | MR0 | MR1 | MR2 | MR3 | MAR0 | MAR1 |
|
||||
;| For the second quadrant the twiddles have the | | | | | | |
|
||||
;| following relationship | | | | | | |
|
||||
;| COS = -SIN and SIN = COS | | | | | | |
|
||||
;| cycles = 36 | | | | | | |
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
;| | | | |Z[k].r |Z[N/2-k].r |
|
||||
MMOV32 MR1, *MAR1[IN_O_2_M_K_NEXT]++ ;| |Z[N/2-k].r | | | |Z[N/2-k].i |
|
||||
MMOV32 MR0, *MAR0[I0_NEXT]++ ;|Z[k].r | | | |Z[k].i | |
|
||||
MSUBF32 MR2, MR0, MR1 ;| | |RS=Z[k].r-Z[N/2-k].r| | | |
|
||||
|| MMOV32 MR3, @SCRATCH_COS ;| | | |COS or C | | |
|
||||
MMPYF32 MR3, MR3, MR2 ;| | | |C*RS | | |
|
||||
|| MADDF32 MR0, MR0, MR1 ;|RA=Z[k].r+Z[N/2-k].r|free | | | | |
|
||||
MSUBF32 MR0, MR0, MR3 ;|RA-C*RS | | |free | | |
|
||||
|| MMOV32 MR1, *MAR0[R0_NEXT_1]++ ;| |Z[k].i | | |Z[k+1].r | |
|
||||
MMOV16 @SCRATCH_MAR0, MAR0 ;|----Save MAR0 to scratchpad--------------|---------------------------------------------------------|
|
||||
MMOV16 MAR0, @PTR_OUTPUT ;|----MAR0 -> output--------------------------------------------------------|F[k].r |------------|
|
||||
MMOV32 MR3, *MAR1[RN_O_2_M_K_NEXT_1]++ ;| | | |Z[N/2-k].i | |Z[N/2-k-1].r|
|
||||
MADDF32 MR2, MR1, MR3 ;| | |IA=Z[k].i+Z[N/2-k].i| | | |
|
||||
|| MMOV32 @RS_TEMP, MR2 ;| | |IA (RS saved) | | | |
|
||||
MSUBF32 MR1, MR1, MR3 ;| |IS=Z[k].i-Z[N/2-k].i| |free | | |
|
||||
|| MMOV32 MR3, @SCRATCH_SIN ;| | | |SIN or S | | |
|
||||
MMPYF32 MR3, MR3, MR2 ;| | | |S*IA | | |
|
||||
MSUBF32 MR0, MR0, MR3 ;|RA-C*RS-S*IA | | |free | | |
|
||||
|| MMOV32 MR3, @SCRATCH_COS ;| | | |C | | |
|
||||
MMPYF32 MR2, MR3, MR2 ;| | |C*IA |free | | |
|
||||
MMOV32 MR3, @RS_TEMP ;| | | |RS | | |
|
||||
MMPYF32 MR0, #0.5, MR0 ;|0.5*(RA-C*RS-S*IA) | | | | | |
|
||||
MSUBF32 MR1, MR1, MR2 ;| |IS-C*IA |free | | | |
|
||||
|| MMOV32 MR2, @SCRATCH_SIN ;| | |S | | | |
|
||||
MMPYF32 MR2, MR2, MR3 ;| | |S*RS |free | | |
|
||||
|| MMOV32 *MAR0[I0_NEXT]++, MR0 ;|free(saved) | | | |F[k].i | |
|
||||
MMOV16 @SCRATCH_MAR1, MAR1 ;|----Save MAR1 to scratchpad--------------| | | | |
|
||||
MMOV16 MAR1, @PTR_TWIDDLES ;|----MAR1 -> twiddles---------------------| | | | |
|
||||
MADDF32 MR1, MR1, MR2 ;| |IS-C*IA+S*RS |free | | | |
|
||||
MMPYF32 MR1, #0.5, MR1 ;| |0.5*(IS-C*IA+S*RS) | | | | |
|
||||
MMOV32 *MAR0[R0_NEXT_1]++, MR1 ;|free |free(saved) |free |free |F[k+1].r | |
|
||||
MMOV16 @PTR_OUTPUT, MAR0 ;|----Save MAR0 to Output Pointer--------------------------------------------------------------------|
|
||||
MMOV16 MAR0, @SCRATCH_MAR0 ;|----Restore MAR0----------------------------------------------------------|Z[k+1].r |------------|
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
;| State of registers |free |free |free |free |Z[k+1].r |Z[N/2-k-1].r|
|
||||
;+-----------------------------------------------+---------------------------------------------------------------------------------------------------+
|
||||
MMOV32 MR0, *MAR1[2]++ ; MR0 = SIN, save to scratchpad
|
||||
MMOV32 @SCRATCH_SIN, MR0 ;
|
||||
MMOV32 MR0, *MAR1[SKIPFACTOR-2]++ ; MR0 = COS, save to scratchpad
|
||||
MMOV32 @SCRATCH_COS, MR0 ;
|
||||
MMOVZ16 MR0, @LOOP_COUNTER ; set ZF = 1 if loop count = 0
|
||||
MMOV16 @PTR_TWIDDLES, MAR1 ;-1| Save to the twiddle pointer
|
||||
MMOV16 MAR1, @SCRATCH_MAR1 ;-2|*| Restore MAR1
|
||||
MMOVIZ MR1, #0 ;-3|1|
|
||||
MBCNDD _CLA_CFFT_unpack512Pt_loop_2Q, NEQ ; *| Branch if loop count != 0
|
||||
MMOVXI MR1, #1 ;-2|3|
|
||||
MSUB32 MR0, MR0, MR1 ;-1| loop counter --
|
||||
MMOV32 @LOOP_COUNTER, MR0 ;+1|
|
||||
|
||||
MRCNDD UNC
|
||||
MMOV32 MR3, @SCRATCH_MR3 ; Restore MR3
|
||||
MNOP
|
||||
MNOP
|
||||
.unasg I0_NEXT
|
||||
.unasg R0_NEXT_1
|
||||
.unasg IN_O_2_M_K_NEXT
|
||||
.unasg RN_O_2_M_K_NEXT
|
||||
.unasg RN_O_2_M_K_NEXT_1
|
||||
.unasg SCRATCH_MR3
|
||||
.unasg RS_TEMP
|
||||
.unasg LOOP_COUNTER
|
||||
.unasg SCRATCH_MAR0
|
||||
.unasg SCRATCH_MAR1
|
||||
.unasg SCRATCH_SIN
|
||||
.unasg SCRATCH_COS
|
||||
.unasg PTR_TWIDDLES
|
||||
.endasmfunc
|
||||
|
||||
;; End of file
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user