📄 example 3-15.asm
字号:
; 5.2 Functional Description
; PHASE TWO (LogN)–Stage Complex FFT
; This function is called from main module of the ’C54x Real FFT code.
; Here we assume that the original 2N–point real input sequence is al
; ready packed into an N–point complex sequence and stored into the
; data processing buffer in bit–reversed order (as done in Phase One).
; Now we perform an in–place, N–point complex FFT on the data proces
; sing buffer, dividing the outputs by 2 at the end of each stage to
; prevent overflow. The resulting N–point complex sequence will be un–
; packed into a 2N–point complex sequencein Phase Three & Four.
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
;;
; 5.3 Activation
; Activation example:
; CALL fft
; Reentrancy: No
; Recursive : No
;
; 5.4 Inputs
; NONE
; 5.5 Outputs
; NONE
;
; 5.6 Global
;
; Data structure: AR0
; Data Format: 16–bit index pointer
; Modified: No
; Description: index to twiddle tables
;
; Data structure: AR1
; Data Format: 16–bit counter
; Modified: No
; Description: group counter
;
; Data structure: AR2
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to 1st butterfly data PR,PI
;
; Data structure: AR3
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to 2nd butterfly data QR,QI
;
; Data structure: AR4
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to cosine value WR
;
; Data structure: AR5
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to cosine value WI
;
; Data structure: AR6
; Data Format: 16–bit counter
; Modified: Yes
; Description: butterfly counter
;
; Data structure: AR7
; Data Format: 16–bit pointer
; Modified: Yes
; Description: start address of data processing buffer
;;
; 5.7 Special considerations for data structure
; –
; 5.8 Entry and Exit conditions
;
; |DP|OVM|SXM|C16|FRCT|ASM|AR0|AR1|AR2|AR3|AR4|AR5|AR6|AR7|A |B |BK|BRC| T|TRN|
; | | | | | | | | | | | | | | | | | | | | |
;in |U | 1 | 1 |NU | 1 | 0 |NU |NU |NU |NU |NU |NU |NU |NU |NU|NU|NU|NU |NU|NU |
; | | | | | | | | | | | | | | | | | | | | |
;out|U | 1 | 1 |NU | 1 |–1 |UM |UM |UM |UM |UM |UM |UM |UM |UM|UM|UM|UM |NU|NU |
;
; Note : UM – Used & Modified, U – Used, NU – Not Used
;
; 5.9 Execution
; Execution time: ?cycles
; Call rate: not applicable for this application
;
;==============================================================================
; HeaderEnd
; 5.10 Code
.asg AR1,GROUP_COUNTER
.asg AR2,PX
.asg AR3,QX
.asg AR4,WR
.asg AR5,WI
.asg AR6,BUTTERFLY_COUNTER
.asg AR7,DATA_PROC_BUF ; for Stages 1 & 2
.asg AR7,STAGE_COUNTER ; for the remaining stages
.sect ”rfft_prg”
fft:
; Stage 1 –––––––––––––––––––––––––––––––––––––––––––––
STM #K_ZERO_BK,BK ; BK=0 so that *ARn+0% == *ARn+0
LD #–1,ASM ; outputs div by 2 at each stage
MVMM DATA_PROC_BUF,PX ; PX –> PR
LD *PX,A ; A := PR
STM #fft_data+K_DATA_IDX_1,QX ; QX –> QR
STM #K_FFT_SIZE/2–1,BRC
RPTBD stage1end–1
STM #K_DATA_IDX_1+1,AR0
SUB *QX,16,A,B ; B := PR–QR
ADD *QX,16,A ; A := PR+QR
STH A,ASM,*PX+ ; PR’:= (PR+QR)/2
ST B,*QX+ ; QR’:= (PR–QR)/2
||LD *PX,A ; A := PI
SUB *QX,16,A,B ; B := PI–QI
ADD *QX,16,A ; A := PI+QI
STH A,ASM,*PX+0 ; PI’:= (PI+QI)/2
ST B,*QX+0% ; QI’:= (PI–QI)/2
||LD *PX,A ; A := next PR
stage1end:
; Stage 2 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
MVMM DATA_PROC_BUF,PX ; PX –> PR
STM #fft_data+K_DATA_IDX_2,QX ; QX –> QR
STM #K_FFT_SIZE/4–1,BRC
LD *PX,A ; A := PR
RPTBD stage2end–1
STM #K_DATA_IDX_2+1,AR0
; 1st butterfly
SUB *QX,16,A,B ; B := PR–QR
ADD *QX,16,A ; A := PR+QR
STH A,ASM,*PX+ ; PR’:= (PR+QR)/2
ST B,*QX+ ; QR’:= (PR–QR)/2
||LD *PX,A ; A := PI
SUB *QX,16,A,B ; B := PI–QI
ADD *QX,16,A ; A := PI+QI
STH A,ASM,*PX+ ; PI’:= (PI+QI)/2
STH B,ASM,*QX+ ; QI’:= (PI–QI)/2
; 2nd butterfly
MAR *QX+
ADD *PX,*QX,A ; A := PR+QI
SUB *PX,*QX–,B ; B := PR–QI
STH A,ASM,*PX+ ; PR’:= (PR+QI)/2
SUB *PX,*QX,A ; A := PI–QR
ST B,*QX ; QR’:= (PR–QI)/2
||LD *QX+,B ; B := QR
ST A, *PX ; PI’:= (PI–QR)/2
||ADD *PX+0%,A ; A := PI+QR
ST A,*QX+0% ; QI’:= (PI+QR)/2
||LD *PX,A ; A := PR
stage2end:
; Stage 3 thru Stage logN–1 ––––––––––––––––
STM #K_TWID_TBL_SIZE,BK ; BK = twiddle table size always
ST #K_TWID_IDX_3,d_twid_idx ; init index of twiddle table
STM #K_TWID_IDX_3,AR0 ; AR0 = index of twiddle table
STM #cosine,WR ; init WR pointer
STM #sine,WI ; init WI pointer
STM #K_LOGN–2–1,STAGE_COUNTER ; init stage counter
ST #K_FFT_SIZE/8–1,d_grps_cnt ; init group counter
STM #K_FLY_COUNT_3–1,BUTTERFLY_COUNTER ; init butterfly counter
ST #K_DATA_IDX_3,d_data_idx ; init index for input data
stage:
STM #fft_data,PX ; PX –> PR
LD d_data_idx, A
ADD *(PX),A
STLM A,QX ; QX –> QR
MVDK d_grps_cnt,GROUP_COUNTER ; AR1 contains group counter
group:
MVMD BUTTERFLY_COUNTER,BRC ; # of butterflies in each grp
RPTBD butterflyend–1
LD *WR,T ; T := WR
MPY *QX+,A ; A := QR*WR || QX–>QI
MACR *WI+0%,*QX–,A ; A := QR*WR+QI*WI
; || QX–>QR
ADD *PX,16,A,B ; B := (QR*WR+QI*WI)+PR
ST B,*PX ; PR’:=((QR*WR+QI*WI)+PR)/2
||SUB *PX+,B ; B := PR–(QR*WR+QI*WI)
; || PX–>PI
ST B,*QX ; QR’:= (PR–(QR*WR+QI*WI))/2
||MPY *QX+,A ; A := QR*WI [T=WI]
; || QX–>QI
MASR *QX,*WR+0%,A ; A := QR*WI–QI*WR
ADD *PX,16,A,B ; B := (QR*WI–QI*WR)+PI
ST B,*QX+ ; QI’:=((QR*WI–QI*WR)+PI)/2
; || QX–>QR
||SUB *PX,B ; B := PI–(QR*WI–QI*WR)
LD *WR,T ; T := WR
ST B,*PX+ ; PI’:= (PI–(QR*WI–QI*WR))/2
; || PX–>PR
||MPY *QX+,A ; A := QR*WR || QX–>QI
butterflyend:
; Update pointers for next group
PSHM AR0 ; preserve AR0
MVDK d_data_idx,AR0
MAR *PX+0 ; increment PX for next group
MAR *QX+0 ; increment QX for next group
BANZD group,*GROUP_COUNTER–
POPM AR0 ; restore AR0
MAR *QX–
; Update counters and indices for next stage
LD d_data_idx,A
SUB #1,A,B ; B = A–1
STLM B,BUTTERFLY_COUNTER ; BUTTERFLY_COUNTER = #flies–1
STL A,1,d_data_idx ; double the index of data
LD d_grps_cnt,A
STL A,ASM,d_grps_cnt ; 1/2 the offset to next group
LD d_twid_idx,A
STL A,ASM,d_twid_idx ; 1/2 the index of twiddle table
BANZ D stage,*STAGE_COUNTER–
MVDK d_twid_idx,AR0 ; AR0 = index of twiddle table
fft_end:
RET ; return to Real FFT main module
.end
;B.4 Unpack 256-Point Real FFT Output
; TEXAS INSTRUMENTS INCORPORATED
; DSP Data Communication System Development / ASP
; Archives: PVCS
; Filename: unpack.asm
; Version: 1.0
; Status : draft ( )
; proposal (X)
; accepted ( ) dd–mm–yy/?acceptor.
;
; AUTHOR Simon Lau and Nathan Baltz
;
; Application Specific Products
; Data Communication System Development
; 12203 SW Freeway, MS 701
; Stafford, TX 77477
;{
; IPR statements description (can be collected).
;}
; (C) Copyright 1996. Texas Instruments. All rights reserved.
;{
; Change history:
;
; VERSION DATE / AUTHORS COMMENT
; 1.0 July–17–96 / Simon & Nathan original created
;
;}
;{
; 1. ABSTRACT
;
; 1.1 Function Type
; a.Core Routine
; b.Subroutine
;
; 1.2 Functional Description
; This file contains one subroutine:
; unpack
;
; 1.3 Specification/Design Reference (optional)
; called by rfft.asm depending upon the task thru CALA
;
; 1.4 Module Test Document Reference
; Not done
;
; 1.5 Compilation Information
; Compiler: TMS320C54X ASSEMBLER
; Version: 1.02 (PC)
; Activation: asm500 –s unpack.asm
;
; 1.6 Notes and Special Considerations
; –
;}
;{
; 2. VOCABULARY
;
; 2.1 Definition of Special Words, Keywords (optional)
; –
; 2.2 Local Compiler Flags
; –
; 2.3 Local Constants
; –
;}
;{
; 3. EXTERNAL RESOURCES
;
; 3.1 Include Files
.mmregs
.include ”main.inc”
; 3.2 External Data
.ref fft_data,sine, cosine
; 3.3 Import Functions
;}
;{
; 4. INTERNAL RESOURCES
;
; 4.1 Local Static Data
; –
; 4.2 Global Static Data
; –
; 4.3 Dynamic Data
; –
; 4.4 Temporary Data
; –
; 4.5 Export Functions
.def unpack
;}
; 5. SUBROUTINE CODE
; HeaderBegin
;==============================================================================
;
; 5.1 unpack
;
; 5.2 Functional Description
;
; PHASE THREE & FOUR Unpacking to 2N Outputs
; This function is called from the main module of the ’C54x Real FFT
; code. It first computes four intermediate sequences (RP,RM, IP, IM)
; from the resulting complex sequence at the end of the previous phase.
; Next, it uses the four intermediate sequences to form the FFT of the
; original 2N–point real input. Again, the outputs are divided by 2 to
; prevent overflow
;––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––—
;
; 5.3 Activation
; Activation example:
; CALL unpack
;
; Reentrancy: No
; Recursive : No
;
; 5.4 Inputs
; NONE
; 5.5 Outputs
; NONE
;
; 5.6 Global
;
; 5.6.1 Phase Three Global
;
; Data structure: AR0
; Data Format: 16–bit index pointer
; Modified: No
; Description: index to twiddle tables
;
; Data structure: AR2
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to R[k], I[k], RP[k], IP[k]
;
; Data structure: AR3
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to R[N–k], I[N–k], RP[N–k], IP[N–k]
;
; Data structure: AR6
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to RM[k], IM[k]
;
; Data structure: AR7
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to RM[n–k], IM[n–k]
;
; 5.6.2 Phase Four Global
;
; Data structure: AR0
; Data Format: 16–bit index pointer
; Modified: No
; Description: index to twiddle tables
;
; Data structure: AR2
; Data Format: 16–bit counter
; Modified: No
; Description: pointer to RP[k], IP[k], AR[k], AI[k], AR[0]
;
; Data structure: AR3
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to RM[k], IM[k], AR[2N–k], AI[2N–k]
;
; Data structure: AR4
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to cos(k*pi/N), AI[0]
;
; Data structure: AR5
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to sin(k*pi/N), AR[N], AI[N]
;
; 5.7 Special considerations for data structure
; –
; 5.8 Entry and Exit conditions
;
; 5.8.1 Phase Three Entry and Exit Conditions
;
; |DP|OVM|SXM|C16|FRCT|ASM|AR0|AR1|AR2|AR3|AR4|AR5|AR6|AR7|A |B |BK|BRC| T|TRN
; | | | | | | | | | | | | | | | | | | | |
;in |2 | 1 | 1 | 0 | 1 | 0 |NU |NU |NU |NU |NU |NU |NU |NU |NU|NU|0 |NU |NU|NU
; | | | | | | | | | | | | | | | | | | | |
;out|2 | 1 | 1 | 0 | 1 |–1 |UM |NU |UM |UM |NU |NU |UM |UM |UM|UM|UM|UM |NU|NU
;
; Note : UM – Used & Modified, U – Used, NU – Not Used
;
; 5.8.2 Phase Four Entry and Exit Conditions
;
; |DP|OVM|SXM|C16|FRCT|ASM|AR0|AR1|AR2|AR3|AR4|AR5|AR6|AR7|A |B |BK|BRC| T|TRN
; | | | | | | | | | | | | | | | | | | | |
;in |U | 1 | 1 | 0 | 1 |–1 |NU |NU |NU |NU |NU |NU |NU |NU |NU|NU|NU|NU |NU|NU
; | | | | | | | | | | | | | | | | | | | |
;out|U | 1 | 1 | 0 | 1 |–1 |UM |NU |UM |UM |UM |UM |NU |NU |UM|UM|UM|UM |NU|NU
;
; Note : UM – Used & Modified, U – Used, NU – Not Used
;
; 5.9 Execution
; Execution time: ?cycles
; Call rate: not applicable for this application
;
;==============================================================================
; HeaderEnd
; 5.10 Code
.sect ”rfft_prg”
unpack:
; Compute intermediate values RP, RM, IP, IM
.asg AR2,XP_k
.asg AR3,XP_Nminusk
.asg AR6,XM_k
.asg AR7,XM_Nminusk
STM #fft_data+2,XP_k ; AR2 –> R[k] (temp RP[k])
STM #fft_data+2*K_FFT_SIZE–2,XP_Nminusk ; AR3 –> R[N–k] (temp RP[N–k])
STM #fft_data+2*K_FFT_SIZE+3,XM_Nminusk ; AR7 –> temp RM[N–k]
STM #fft_data+4*K_FFT_SIZE–1,XM_k ; AR6 –> temp RM[k]
STM #–2+K_FFT_SIZE/2,BRC
RPTBD phase3end–1
STM #3,AR0
ADD *XP_k,*XP_Nminusk,A ; A := R[k]+R[N–k] = 2*RP[k]
SUB *XP_k,*XP_Nminusk,B ; B := R[k]–R[N–k] =2*RM[k]
STH A,ASM,*XP_k+ ; store RP[k] at AR[k]
STH A,ASM,*XP_Nminusk+ ; store RP[N–k]=RP[k] at AR[N–k]
STH B,ASM,*XM_k– ; store RM[k] at AI[2N–k]
NEG B ; B := R[N–k]–R[k] = 2*RM[N–k]
STH B,ASM,*XM_Nminusk– ; store RM[N–k] at AI[N+k]
ADD *XP_k,*XP_Nminusk,A ; A := I[k]+I[N–k] = 2*IP[k]
SUB *XP_k,*XP_Nminusk,B ; B := I[k]–I[N–k] = 2*IM[k]
STH A,ASM,*XP_k+ ; store IP[k] at AI[k]
STH A,ASM,*XP_Nminusk–0 ; store IP[N–k]=IP[k] at AI[N–k]
STH B,ASM,*XM_k– ; store IM[k] at AR[2N–k]
NEG B ; B := I[N–k]–I[k] = 2*IM[N–k]
STH B,ASM,*XM_Nminusk+0 ; store IM[N–k] at AR[N+k]
phase3end:
ST #0,*XM_k– ; RM[N/2]=0
ST #0,*XM_k ; IM[N/2]=0
; Compute AR[0],AI[0], AR[N], AI[N]
.asg AR2,AX_k
.asg AR4,IP_0
.asg AR5,AX_N
STM #fft_data,AX_k ; AR2 –> AR[0] (temp RP[0])
STM #fft_data+1,IP_0 ; AR4 –> AI[0] (temp IP[0])
STM #fft_data+2*K_FFT_SIZE+1,AX_N ; AR5 –> AI[N]
ADD *AX_k,*IP_0,A ; A := RP[0]+IP[0]
SUB *AX_k,*IP_0,B ; B := RP[0]–IP[0]
STH A,ASM,*AX_k+ ; AR[0] = (RP[0]+IP[0])/2
ST #0,*AX_k ; AI[0] = 0
MVDD *AX_k+,*AX_N– ; AI[N] = 0
STH B,ASM,*AX_N ; AR[N] = (RP[0]–IP[0])/2
; Compute final output values AR[k], AI[k]
.asg AR3,AX_2Nminusk
.asg AR4,COS
.asg AR5,SIN
STM #fft_data+4*K_FFT_SIZE–1,AX_2Nminusk ; AR3 –> AI[2N–1](temp RM[1])
STM #cosine+K_TWID_TBL_SIZE/K_FFT_SIZE,COS ; AR4 –> cos(k*pi/N)
STM #sine+K_TWID_TBL_SIZE/K_FFT_SIZE,SIN ; AR5 –> sin(k*pi/N)
STM #K_FFT_SIZE–2,BRC
RPTBD phase4end–1
STM #K_TWID_TBL_SIZE/K_FFT_SIZE,AR0 ; index of twiddle tables
LD *AX_k+,16,A ; A := RP[k] || AR2–>IP[k]
MACR *COS,*AX_k,A ; A :=A+cos(k*pi/N)*IP[k]
MASR *SIN,*AX_2Nminusk–,A ; A := A–sin(k*pi/N)*RM[k]
; || AR3–>IM[k]
LD *AX_2Nminusk+,16,B ; B := IM[k] || AR3–>RM[k]
MASR *SIN+0%,*AX_k–,B ; B := B–sin(k*pi/N)*IP[k]
; || AR2–>RP[k]
MASR *COS+0%,*AX_2Nminusk,B ; B := B–cos(k*pi/N)*RM[k]
STH A,ASM,*AX_k+ ; AR[k] = A/2
STH B,ASM,*AX_k+ ; AI[k] = B/2
NEG B ; B := –B
STH B,ASM,*AX_2Nminusk– ; AI[2N–k] = –AI[k] = B/2
STH A,ASM,*AX_2Nminusk– ; AR[2N–k] = AR[k] = A/2
phase4end:
RET ; returntoRealFFTmain module
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -