⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rfft.asm

📁 54系列dsp算法程序
💻 ASM
📖 第 1 页 / 共 2 页
字号:
*********************************************************************************
*       (C) COPYRIGHT TEXAS INSTRUMENTS, INC. 1996                              *
*********************************************************************************
*                                                                               *
* FILE NAME:  rFFT.asm                                                          *
*                                                                               *
* AUTHORS:    Simon Lau and Nathan Baltz                                        *
*                                                                               *
* DESCRIPTION:                                                                  *
*  - TMS320C54x 2N-point Real FFT                                               *
*    Radix 2, in-place DIT algorithm                                            *
*  - For various input sizes (16 - 1024), simply modify N and LOGN.             *
*  - Input data is assumed to be in Q0.15 format, stored in natural order,      *
*    all real, in a data file named "Indata1"                                   *
*  - Bit-reversal of input data is done automatically before performing the FFT.*
*  - Computation is done in place, so the outputs come in natural order,        *
*    interleaved real/complex.                                                  *
*  - Twiddle factors are stored in normal order in two separate tables,         *
*    one for sine values and the other for cosine.                              *
*  - Total size of twiddle tables is 1024 bytes for FFT size up to 1024 points. *
*    Same twiddle tables are used for FFT size from 16 to 1024.                 *
*  - For additional information about the implementation of this code refer to  *
*    the readme.txt file.                                                       *
*                                                                               *
* DATE:       Summer 1996                                                       *
*                                                                               *
*********************************************************************************

        .mmregs
        .global reset,begin

N       .set 8                          ; number of complex points 
LOGN    .set 3                          ; number of stages (=logN/log2)

; Copy input data and twiddle tables from files

        .data
DATA    .space 2*N*16                   ; start addr. of complex output data
INPUT   .copy indata1                   ; start addr. of complex input data   

        .sect "twiddle1"
TWI1    .copy twiddle1                  ; sine table
        .sect "twiddle2"
TWI2    .copy twiddle2                  ; cosine table

; Define variables for indexing input data and twiddle tables

sav_grp .usect "tempv",3                ; saves (# groups in current stage)-1
sav_sin .set   sav_grp+1                ; saves index of twiddle tables
sav_idx .set   sav_grp+2                ; saves index of input data table

; Set up stack

BOS     .usect "stack",0Fh
TOS     .usect "stack",1


; Power up initialization ------------------------------------------------------

        .sect  "vectors"
reset: 
        BD     begin
        STM    #TOS,SP

        .text
begin:
        LD      #0,DP
        SSBX    FRCT                    ; fractional mode is on


;-------------------------------------------------------------------------------
; P H A S E   O N E       Bit-Reversal of Input Data
;  
; REGISTER USAGE:     AR0       index for bit-reversed addressing
;		      AR2	pointer to R, I (processed data, in bit-reversed order)
;		      AR3	pointer to XR, XI (original input data)
;		      AR7	start addr. of data
;-------------------------------------------------------------------------------

        STM     #INPUT,AR3              ; AR3 points to 1st input XR[0]
        STM     #DATA,AR7               ; store start addr. of data in AR7 
        MVMM    AR7,AR2                 ; AR2 points to 1st processed data R[0]
        STM     #N-1,BRC                 
        RPTBD   p1end-1
        STM     #N,AR0                  ; AR0 := 1/2 the size of circular buffer
      
        MVDD    *AR3+,*AR2+
        MVDD    *AR3-,*AR2+
        MAR     *AR3+0B                 ; bitrev(k)    
p1end: 
        

;-------------------------------------------------------------------------------
; P H A S E   T W O       (LogN)-Stage Complex IFFT  
;
; Outputs are divided by 2 at each stage to prevent overflow
;
; REGISTER USAGE:     AR0       offset to next butterfly
; (stages 1 & 2)      AR2       pointer to PR, PI (1st butterfly input data)
;		      AR3	pointer to QR, QI (2nd butterfly input data)
;		      AR7	start addr. of data
;
; REGISTER USAGE:     AR0       index of twiddle tables
; (remainder)         AR1       group counter
;		      AR2	pointer to PR, PI (1st butterfly input data)
;		      AR3	pointer to QR, QI (2nd butterfly input data)
;		      AR4	pointer to WR (cosine) 
;		      AR5	pointer to WI (sine)
;		      AR6	butterfly counter
;		      AR7	stage counter
;-------------------------------------------------------------------------------

; Stage 1 ----------------------------------------------------------------------

        STM     #0,BK                   ; circular buffer size BK=0
        LD      #-1,ASM                 ; outputs divided by 2 at every stage
        MVMM    AR7,AR2                 ; AR2 points to PR
        STM     #DATA+2,AR3             ; AR3 points to QR
        STM     #N/2-1,BRC
        LD      *AR2,16,A               ; A  :=  PR
        RPTBD   s1end-1
        STM     #3,AR0

        SUB     *AR3,16,A,B             ; B  :=  PR-QR
        ADD     *AR3,16,A               ; A  :=  PR+QR
        STH     A,ASM,*AR2+             ; PR':= (PR+QR)/2  
        ST      B,*AR3+                 ; QR':= (PR-QR)/2
        ||LD    *AR2,A                  ; A  :=  PI
        SUB     *AR3,16,A,B             ; B  :=  PI-QI
        ADD     *AR3,16,A               ; A  :=  PI+QI
        STH     A,ASM,*AR2+0            ; PI':= (PI+QI)/2
        ST      B,*AR3+0%               ; QI':= (PI-QI)/2 
        ||LD    *AR2,A                  ; A  :=  PR
s1end:

; Stage 2 ----------------------------------------------------------------------

        MVMM    AR7,AR2                 ; AR2 points to PR
        STM     #DATA+4,AR3             ; AR3 points to QR
        STM     #N/4-1,BRC
        LD      *AR2,16,A               ; A  :=  PR
        RPTBD   s2end-1
        STM     #5,AR0

; 1st butterfly
        SUB     *AR3,16,A,B             ; B  :=  PR-QR	
        ADD     *AR3,16,A               ; A  :=  PR+QR
        STH     A,ASM,*AR2+             ; PR':= (PR+QR)/2  
        ST      B,*AR3+                 ; QR':= (PR-QR)/2
        ||LD    *AR2,A                  ; A  :=  PI
        SUB     *AR3,16,A,B             ; B  :=  PI-QI
        ADD     *AR3,16,A               ; A  :=  PI+QI
        STH     A,ASM,*AR2+             ; PI':= (PI+QI)/2
        STH     B,ASM,*AR3+             ; QI':= (PI-QI)/2 

; 2nd butterfly
        MAR     *AR3+
        ADD     *AR2,*AR3,A             ; A   :=  PR+QI
        SUB     *AR2,*AR3-,B            ; B   :=  PR-QI
        STH     A,ASM,*AR2+             ; PR' := (PR+QI)/2  
        SUB     *AR2,*AR3,A             ; A   :=  PI-QR
        ST      B,*AR3                  ; QR' := (PR-QI)/2

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -