📄 cplxfft32b.s
字号:
;*********************************************************************
; *
; Software License Agreement *
; *
; The software supplied herewith by Microchip Technology *
; Incorporated (the "Company") for its dsPIC controller *
; is intended and supplied to you, the Company's customer, *
; for use solely and exclusively on Microchip dsPIC *
; products. The software is owned by the Company and/or its *
; supplier, and is protected under applicable copyright laws. All *
; rights are reserved. Any use in violation of the foregoing *
; restrictions may subject the user to criminal sanctions under *
; applicable laws, as well as to civil liability for the breach of *
; the terms and conditions of this license. *
; *
; THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO *
; WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, *
; BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND *
; FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE *
; COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, *
; INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. *
; *
; (c) Copyright 2007 Microchip Technology, All rights reserved. *
;*********************************************************************
; Local inclusions.
.nolist
.include "dspcommon.inc" ; MODCON, XBREV
.list
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.section .libdsp, code
.global _FFTComplex32bIP
.equ TF_FFT_SIZE,1024 ; 10stage, 1024 point complex FFT
.equ TF_FFT_STG, 10
.text
;******************************************************************************
; Butterfly Computation
; P=Pr+jPi, Q=Qr+jQi, W=Wr-jWi
; P'=P+W*Q and Q'=P-W*Q
;
; Indirect Address Pointers, it will be update to point to next date inputs
; W8->(Pr,Pi,Pr+1,Pi+1,....)
; W9->(Qr,Qi,Qr+1,Qi+1,....)
; W10-> Wr
; W11-> Wi
; W12 -> ACCA
; W13 -> ACCB
; W14 -> FP, First two location used for TEMP
; Equations for Butterfly Computation
; Pr'=(Pr+Qr*Wr+Qi*Wi)/2
; Qr'=(Pr-Qr*Wr-Qi*Wi)/2
; Pi'=(Pi+Qi*Wr-Qr*Wi)/2
; Qi'=(Pi-Qi*WR+Qr*Wi)/2
;******************************************************************************
.macro BFLY_MACRO
; Qr*Wi 32-bit multiplication
MOV.D [w11],W6 ; (w6,w7)=Wi=(y0,y1)
; (w9,w9+1)=Wi=(x0,x1)
MUL.SU w7,[w9],w0 ; y1*x0
MUL.US w6,[++w9],w2 ; y0*x1
MUL.SS w7,[w9++],w4 ; y1*x1
LAC w3,B
ADD w1,B
SFTAC B,#16 ; B=(y1*x0 + y0*x1)>>16
ADD w4,[w13++],[w14++]
ADDC w5,[w13--],[w14--] ; TEMP=Qr*Wi=y1*x1 + (y1*x0 + y0*x1)>>16
; Qi*Wi 32-bit multiplication
; (w6,w7)=Wi=(y0,y1)
; (w9,w9+1)=Qi=(x0,x1)
MUL.SU w7,[w9],w0 ; y1*x0
MUL.US w6,[++w9],w2 ; y0*x1
MUL.SS w7,[w9--],w4 ; y1*x1
LAC w3,B
ADD w1,B
SFTAC B,#16 ; B=(y1*x0 + y0*x1)>>16
ADD w4,[w13],[w13++]
ADDC w5,[w13],[w13--] ; B=Qi*Wi=y1*x1 + (y1*x0 + y0*x1)>>16
; Qr*Wr 32-bit multiplication
MOV.D [w10],W6 ; (w6,w7)=Wr=(y0,y1)
; (w9-2,w9-1)=Qr=(x0,x1)
MUL.US w6,[--w9],w2 ; y0*x1
MUL.SS w7,[w9--],w4 ; y1*x1
MUL.SU w7,[w9],w0 ; y1*x0
LAC w3,A
ADD w1,A
SFTAC A,#16 ; A=(y1*x0 + y0*x1)>>16
ADD w4,[w12],[w12++]
ADDC w5,[w12],[w12--] ; A=Qr*Wr=y1*x1 + (y1*x0 + y0*x1)>>16
; Pr'=(Pr+Qr*Wr+Qi*Wi)/2
; Qr'=(Pr-Qr*Wr-Qi*Wi)/2
ADD A ; A=Qr*Wr+Qi*Wi
LAC [++W8],B ; B=Pr
MOV [--w8],[w13]
SFTAC B,#1 ; B=Pr/2 in Q31 format
ADD A ; A=(Pr + Qr*Wr+Qi*Wi)/2 in Q31 format
SFTAC B,#-1
SUB B ; B=(Pr - Qr*Wr-Qi*Wi)/2 in Q31 format
MOV [w12++],[W8++]
MOV [w12--],[w8++] ; Pr'=(Pr+Qr*Wr+Qi*Wi)/2
MOV [w13++],[W9++]
MOV [w13--],[w9++] ; Qr'=(Pr-Qr*Wr-Qi*Wi)/2
; Qi*Wr 32-bit multiplication
; (w6,w7)=Wr=(y0,y1)
; (w9,w9++)=Qi=(x0,x1)
MUL.SU w7,[w9],w0 ; y1*x0
MUL.US w6,[++w9],w2 ; y0*x1
MUL.SS w7,[w9--],w4 ; y1*x1
LAC w3,A
ADD w1,A
SFTAC A,#16 ; B=(y1*x0 + y0*x1)>>16
ADD w4,[w12],[w12++]
ADDC w5,[w12],[w12--] ; A=Qi*Wr=y1*x1 + (y1*x0 + y0*x1)>>16
; Pi'=(Pi+Qi*Wr-Qr*Wi)/2
; Qi'=(Pi-Qi*Wr+Qr*Wi)/2
LAC [++W14],B
MOV [--w14],[w13] ; B=Qr*Wi
SUB A ; A=Qi*Wr-Qr*Wi
LAC [++W8],B ; B=Pr
MOV [--w8],[w13]
SFTAC B,#1 ; B=Pi/2 in Q31 format
ADD A ; A=(Pi + Qi*Wr-Qr*Wi)/2 in Q31 format
SFTAC B,#-1
SUB B ; B=(Pi - Qi*Wr+Qr*Wi)/2 in Q31 format
MOV [w12++],[W8++]
MOV [w12--],[w8++] ; Pi'=(Pi + Qi*Wr-Qr*Wi)/2
MOV [w13++],[W9++]
MOV [w13--],[w9++] ; Qi'=(Pi - Qi*Wr+Qr*Wi)/2
.endm
;............................................................................
; Pointer Usage
; w8->(Pr1,Pi1)
; w9->(Pr2,Pi2)
; w10->(Pr3,Pi3)
; w11->(Pr4,Pi4)
;
; W12 -> ACCA
; W13 -> ACCB
; W14 -> FP, First two location used for TEMP
;
; Calculations
; Pr6 -> Pr1'=(Pr1+Pr2+Pr3+Pr4)/4
; Pr2 -> Pr2'=(Pr1-Pr2+Pi3-Pi4)/4
; Pr3 -> Pr3'=(Pr1+Pr2-Pr3-Pr4)/4
; Pr4 -> Pr4'=(Pr1-Pr2-Pi3+Pi4)/4
; Pr6+1 -> Pi1'=(Pi1+Pi2+Pi3+Pi4)/4
; Pr2+1 -> Pi2'=(Pi1-Pi2-Pr3+Pr4)/4
; Pr3+1 -> Pi3'=(Pi1+Pi2-Pi3-Pi4)/4
; Pr4+1 -> Pi4'=(Pi1-Pi2+Pr3-Pr4)/4
;............................................................................
.macro STG12_MACRO
;----------
LAC [++w8],B ; B=Pr1
MOV [--w8],[w13]
SFTAC B,#2 ; B=Pr1/4 in Q31 format
LAC [++w9],A ; A=Pr2
MOV [--w9],[w12]
SFTAC A,#2 ; A=Pr2/4 in Q31 format
ADD A ; A=(Pr1+Pr2)/4
SFTAC B,#-1
SUB B ; B=(Pr1-Pr2)/4
MOV [w12++],[W8++] ; Pr1=(Pr1+Pr2)/4
MOV [w12--],[w8++]
MOV [w13++],[W9++] ; Pr2=(Pr1-Pr2)/4
MOV [w13--],[w9++]
;----------
LAC [++w10],B ; B=Pr3
MOV [--w10],[w13]
SFTAC B,#2 ; B=Pr3/4 in Q31 format
LAC [++w11],A ; A=Pr4
MOV [--w11],[w12]
SFTAC A,#2 ; A=Pr4/4 in Q31 format
ADD A ; A=(Pr3+Pr4)/4
SFTAC B,#-1
SUB B ; B=(Pr3-Pr4)/4
MOV [w12++],[W10++] ; Pr3=(Pr3+Pr4)/4
MOV [w12--],[w10++]
MOV [w13++],[W11++] ; Pr4=(Pr3-Pr4)/4
MOV [w13--],[w11++]
MOV [w13++],w0 ; (w0,w1)=(Pr3-Pr4)/4
MOV [w13--],w1
;----------
LAC [++w8],B ; B=Pi1
MOV [--w8],[w13]
SFTAC B,#2 ; B=Pi1/4 in Q31 format
LAC [++w9],A ; A=Pi2
MOV [--w9],[w12]
SFTAC A,#2 ; A=Pi2/4 in Q31 format
ADD A ; A=(Pi1+Pi2)/4
SFTAC B,#-1
SUB B ; B=(Pi1-Pi2)/4
MOV [w12++],[W8++] ; Pi1=(Pi1+Pi2)/4
MOV [w12--],[w8--]
MOV [w13++],[W9++] ; Pi2=(Pi1-Pi2)/4
MOV [w13--],[w9--]
;----------
LAC [++w10],B ; B=Pi3
MOV [--w10],[w13]
SFTAC B,#2 ; B=Pi3/4 in Q31 format
LAC [++w11],A ; A=Pi4
MOV [--w11],[w12]
SFTAC A,#2 ; A=Pi4/4 in Q31 format
ADD A ; A=(Pi3+Pi4)/4
SFTAC B,#-1
SUB B ; B=(Pi3-Pi4)/4
MOV [w12++],[W10++] ; Pr3=(Pi3+Pi4)/4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -