📄 example 3-34.asm
字号:
; Example 3 - 34. Extended Precision DIT Radix-2 FFT Implementation ASM Listing for the TMS320C62x DSP
; THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
; REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY,
; INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
; FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR
; COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE.
; TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET
; POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY
; INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR
; YOUR USE OF THE PROGRAM.
;
; IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
; CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY
; THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED
; OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT
; OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM.
; EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF
; REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS
; OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF
; USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S
; AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF
; YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS
; (U.S.$500).
;
; Unless otherwise stated, the Program written and copyrighted
; by Texas Instruments is distributed as "freeware". You may,
; only under TI's copyright in the Program, use and modify the
; Program without any charge or restriction. You may
; distribute to third parties, provided that you transfer a
; copy of this license to the third party and the third party
; agrees to these terms by its first use of the Program. You
; must reproduce the copyright notice and any other legend of
; ownership on each copy or partial copy, of the Program.
;
; You acknowledge and agree that the Program contains
; copyrighted material, trade secrets and other TI proprietary
; information and is protected by copyright laws,
; international copyright treaties, and trade secret laws, as
; well as other intellectual property laws. To protect TI's
; rights in the Program, you agree not to decompile, reverse
; engineer, disassemble or otherwise translate any object code
; versions of the Program to a human-readable form. You agree
; that in no event will you alter, remove or destroy any
; copyright notice included in the Program. TI reserves all
; rights not specifically granted under this license. Except
; as specifically provided herein, nothing in this agreement
; shall be construed as conferring by implication, estoppel,
; or otherwise, upon you, any license or other right under any
; TI patents, copyrights or trade secrets.
;
; You may not use the Program in non-TI devices.
*******************************************************************************
* *
* TEXAS INSTRUMENTS INC. *
* *
* COMPLEX 32-BIT FFT (RADIX-2) *
* *
* USAGE *
* *
* This routine is C callable and can be called as *
* *
* void r2fft32(int x[], int n, int w[]) *
* *
* x[] --- input and output sequences (dim-2*n) (input/output) *
* n --- FFT size (power of 2)(input) *
* w[] --- FFT coefficients (dim-n) (input) *
* *
* REVISION HISTORY *
* 7/25/2000 Written /Mattias Ahnoff *
* 2/26/2001 Problems when running from far memory fixed /M. A. * *
* *
* C CODE *
* This is the C equivalent of the Assembly Code without the *
* assumptions listed below. Note that the assembly code is hand *
* optimized and assumptions may apply. *
* *
* *
* void r2fft32C( int x[], int n, int w[]) *
* { *
* int n1,n2,ie,ia,i,j,k,l; *
* int xt,yt,c,s; *
* int *wptr; *
* int wcounter; *
* int *xy_i_ptr_ld, *xy_i_ptr_st; *
* int *xy_iN2_ptr_ld, *xy_iN2_ptr_st; *
* int reset_offset; *
* *
* n2 = n; *
* ie = 1; *
* *
* reset_offset = 2*(n-1); *
* *
* for (k=n; k > 1; k = (k >> 1) ) { *
* n1 = n2; *
* n2 = n2>>1; *
* wptr = w; *
* *
* *
* xy_i_ptr_ld = x; *
* xy_i_ptr_st = x; *
* xy_iN2_ptr_ld = x+n1; *
* xy_iN2_ptr_st = x+n1; *
* wcounter = ie; *
* c = *wptr++; *
* s = *wptr--; *
* wptr += 2*ie; *
* *
* for (j=0; j<(n/2); j++){ *
* if(!wcounter) *
* { *
* wcounter = ie; *
* c = *wptr++; *
* s = *wptr--; *
* wptr += 2*ie; *
* *
* xy_i_ptr_ld -= reset_offset; *
* xy_i_ptr_st -= reset_offset; *
* xy_iN2_ptr_ld-= reset_offset; *
* xy_iN2_ptr_st-= reset_offset; *
* } *
* if(wcounter) *
* wcounter--; *
* *
* xt = *xy_iN2_ptr_ld - *xy_i_ptr_ld; *
* *xy_i_ptr_st++ = *xy_i_ptr_ld++ + *xy_iN2_ptr_ld++; *
* yt = *xy_iN2_ptr_ld - *xy_i_ptr_ld; *
* *xy_i_ptr_st-- = *xy_i_ptr_ld-- + *xy_iN2_ptr_ld--; *
* *
* *
* *xy_iN2_ptr_st++ = _smpyh(c,xt) + *
* (_mpyluhs(c,xt)>>15) + (_mpyhslu(c,xt)>>15)+ *
* _smpyh(s,yt)+ *
* (_mpyluhs(s,yt)>>15) + (_mpyhslu(s,yt)>>15); *
* *
* *xy_iN2_ptr_st-- = _smpyh(c,yt) + *
* (_mpyluhs(c,yt)>>15) + (_mpyhslu(c,yt)>>15)- *
* _smpyh(s,xt)- *
* (_mpyluhs(s,xt)>>15) - (_mpyhslu(s,xt)>>15); *
* xy_i_ptr_ld += 2*n1; *
* xy_i_ptr_st += 2*n1; *
* xy_iN2_ptr_ld+= 2*n1; *
* xy_iN2_ptr_st+= 2*n1; *
* } *
* ie = ie<<1; *
* } *
* } *
* *
* DESCRIPTION *
* This routine is used to compute an "in place" FFT of a complex *
* sequence of size n, a power of 2, with "decimation-in-frequency" *
* decomposition method. The output is in bit-reversed order. *
* Each complex value is with interleaved 32-bit real and *
* imaginary parts. *
* *
* DEFINITIONS *
* This implementation uses the following definition of the *
* FFT: *
* [X(1), X(2), ..., X(N-1)] = fft([x(0), x(1), ...,x(N-1)]) *
* with *
* X(n) = SUM(k=0,N-1)[x(k)*exp(2*pi*n*k/N)], n=0...N-1 *
* *
* TECHNIQUES *
* Last iteration of the outer loop is lifted out to avoid some *
* unnesessary multiplications with trivial twiddle factors. *
* 32-bit multiplies a*b are performed using three 16-bit multiplies. *
* Note that the smallest term ((a & 0xffff)*(b & 0xffff))>>31 *
* is disregarded. *
* *
* SCALING *
* Input must be in Q(31-log2(N)-1) format (or equivalently in *
* [-1/(2N), 1/(2N)] in Q31 format) to prevent overflow. *
* *
* INVERSE TRANSFORM *
* This routine could be used for calculation of the inverse transform *
* (IFFT) as well by simply conjugating the coefficients. *
* The result will be N*IFFT(x), since the IFFT is (most often) *
* defined with a weight factor of 1/N. *
* *
* ASSUMPTIONS *
* 4 <= n *
* x data is stored in the order real[0], image[0], real[1], ... *
* w coef is stored in the order -k*cos[0*delta], -k*sin[0*delta], *
* -k*cos[1*delta], ... where delta = 2*PI/N, k = 2147483647 *
* *
* MEMORY *
* 624 words *
* *
* CYCLES *
* LOG2(N) * (7 * N/2 + 22) - 3 * N/4 - 8 (=6952 for N=256) *
* *
*******************************************************************************
*=============================================================================*
* Copyright (C) 2000 Texas Instruments Incorporated. *
* All Rights Reserved *
*=============================================================================*
.sect ".data:copyright_h"
_Copyright: .string "Copyright (C) 2000 Texas Instruments Incorporated. "
.string "All Rights Reserved."
.sect ".text:hand"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -