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

📄 example 3-15.asm

📁 《基于TI DSP的通用算法实现》程序代码
💻 ASM
📖 第 1 页 / 共 2 页
字号:

;Example 3 - 15. FFT Implementation of a 2N Real Sequence Based on Data-Packing Method for TMS320C54x	

* Appendix A Main.inc


* Filename: Main.inc
* Includes all the constants that are used in the entire application

	K_0 		.set 0 ; constant
	K_FIR_INDEX 	.set 1 ; index count
	K_FIR_BFFR 	.set 16 ; FIR buffer size
	K_neg1 		.set –1h ; index count
	K_BIQUAD 	.set 2 ; there are 2 bi-quad sections
	K_IIR_SIZE 	.set 10 ; each bi-quad has 5 coeffs
	K_STACK_SIZE 	.set 200 ; stack size
	K_FRAME_SIZE 	.set 256 ; PING/PONG buffer size
	K_FRAME_FLAG 	.set 1 ; set after 256 collected
	H_FILT_SIZE 	.set 128 ; H(z) filter size
	ADPT_FILT_SIZE 	.set 128 ; W(z) filter size
	K_mu 		.set 0h ; initial step constant
	K_HOST_FLAG 	.set 1 ; Enable EVM_HOST interface
	K_DEFAULT_AC01 	.set 1h ; default AC01 init   
	
* This include file sets the FFT size for the ’54x Real FFT code
* Note that the Real FFT size (i.e. the number of points in the
* original real input sequence) is 2N; whereas the FFT size is
* the number of complex points formed by packing the real inputs,
* which is N. For example, for a 256-pt Real FFT, K_FFT_SIZE
* should be set to 128 and K_LOGN should be set to 7.

	K_FFT_SIZE 	.set 128 ; # of complex points (=N)
	K_LOGN 		.set 7 ; # of stages (=logN/log2)
	K_ZERO_BK 	.set 0
	K_TWID_TBL_SIZE .set 128 ; Twiddle table size
	K_DATA_IDX_1 	.set 2 ; Data index for Stage 1
	K_DATA_IDX_2 	.set 4 ; Data index for Stage 2
	K_DATA_IDX_3 	.set 8 ; Data index for Stage 3
	K_FLY_COUNT_3 	.set 4 ; Butterfly counter for Stage 3
	K_TWID_IDX_3 	.set 32 ; Twiddle index for Stage 3


; Appendix B FFT Example Code

; B.1 256-Point Real FFT Initialization

; TEXAS INSTRUMENTS INCORPORATED
; DSP Data Communication System Development / ASP
;
; Archives: PVCS
; Filename: rfft.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 core routine:
; rfft
;
; 1.3 Specification/Design Reference (optional)
;
; 1.4 Module Test Document Reference
; Not done
;
; 1.5 Compilation Information
; Compiler: TMS320C54X ASSEMBLER
; Version: 1.02 (PC)
; Activation: asm500 –s rfft.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”
	.include ”init_54x.inc”
; 3.2 External Data
	.ref bit_rev, fft, unpack
	.ref power
	.ref sine,cosine
	.ref sine_table,cos_table
	
; 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 rfft_task
;}
; 5. SUBROUTINE CODE
; HeaderBegin
;==============================================================================
;
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
; 5.1 rfft
;
; 5.2 Functional Description
; The following code implements a Radix–2, DIT, 2N–point Real FFT for the
; TMS320C54x. This main program makes four function calls, each
; corresponds to a different phase of the algorithm. For more details about
; how each phase is implemented, see bit_rev.asm, fft.asm, unpack.asm, and
; power.asm assembly files.
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
;
; 5.3 Activation
; Activation example:
; CALL rfft
; Reentrancy: No
; Recursive : No
; 5.4 Inputs
; NONE
; 5.5 Outputs
; NONE
;
; 5.6 Global
;
; Data structure: AR1
SPRA669
TMS320C54x Digital Filters 29
; Data Format: 16–bit pointer
; Modified: No
; Description: used for moving the twiddle tables from
; program to data
;
; 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 |NU |NU |NU |NU |NU |NU |NU |NU |NU |NU|NU|NU|NU |NU|NU
; | | | | | | | | | | | | | | | | | | | |
;out|U | 1 | 1 |NU | 1 |U |NU |UM |NU |NU |NU |NU |NU |NU |NU|NU|NU|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,FFT_TWID_P
	.sect ”rfft_prg”
rfft_task:
	STM #sine,FFT_TWID_P
	RPT #K_FFT_SIZE–1 		; move FIR coeffs from program
	MVPD #sine_table,*FFT_TWID_P+ 	; to data
	STM #cosine,FFT_TWID_P
	RPT #K_FFT_SIZE–1 		; move FIR coeffs from program
	MVPD #cos_table,*FFT_TWID_P+ 	; to data
	CALL bit_rev
	CALL fft
	CALL unpack
	CALLD power
	STM #K_ST1,ST1 			; restore the original contents of
					; ST1 since ASM field has changed
	RET 				; return to main program
	.end



; B.2 Bit Reversal Routine
; TEXAS INSTRUMENTS INCORPORATED
; DSP Data Communication System Development / ASP ;
;
; Archives: PVCS
; Filename: bit_rev.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).
;}
SPRA669
30 TMS320C54x Digital Filters
;(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:
; bit_rev
;
; 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 bit_rev.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 d_input_addr, fft_data
; 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 bit_rev
;}
; 5. SUBROUTINE CODE
; HeaderBegin
;==============================================================================
;
;––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
; 5.1 bit_rev
;
; 5.2 Functional Description
; This function is called from the main module of the ’C54x Real FFT code.
; It reorders the original 2N–point real input sequence by using
; bit–reversed addressing. This new sequence is stored into the data
; processing buffer of size 2N, where FFT will be performed in–place
; during Phase Two.
;
;––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––—
;
; 5.3 Activation
; Activation example:
; CALL bit_rev
; 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: used for bit reversed addressing
;
; Data structure: AR2
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to processed data in bit–reversed order
;
; Data structure: AR3
; Data Format: 16–bit pointer
; Modified: Yes
; Description: pointer to original input data in natural order
;
; Data structure: AR7
; Data Format: 16–bit pointer
; Modified: Yes
; Description: starting addressing 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 |NU |NU |NU |NU |NU |NU |NU |NU |NU |NU|NU|NU|NU |NU|NU |
; | | | | | | | | | | | | | | | | | | | | |
;out|U | 1 | 1 |NU | 1 |NU |UM |NU |UM |UM |NU |NU |NU |UM |NU|NU|NU|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 AR2,REORDERED_DATA
	.asg AR3,ORIGINAL_INPUT
	.asg AR7,DATA_PROC_BUF
	.sect ”rfft_prg”
bit_rev:
	SSBX FRCT 				; fractional mode is on
	MVDK d_input_addr,ORIGINAL_INPUT 	; AR3 –> 1 st original input
	STM #fft_data,DATA_PROC_BUF 		; AR7 –> data processing buffer
	MVMM DATA_PROC_BUF,REORDERED_DATA 	; AR2 –> 1st bit–reversed data
	STM #K_FFT_SIZE–1,BRC
	RPTBD bit_rev_end–1
	STM #K_FFT_SIZE,AR0 			; AR0 = 1/2 size of circ buffer
	MVDD *ORIGINAL_INPUT+,*REORDERED_DATA+
	MVDD *ORIGINAL_INPUT–,*REORDERED_DATA+
	MAR *ORIGINAL_INPUT+0B
bit_rev_end:

	RET 					; return to Real FFT main module
	.end


; B.3 256-Point Real FFT Routine

; TEXAS INSTRUMENTS INCORPORATED
; DSP Data Communication System Development / ASP
;
; Archives: PVCS
; Filename: fft.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
SPRA669
TMS320C54x Digital Filters 33
;
;}
;{
; 1. ABSTRACT
;
; 1.1 Function Type
; a.Core Routine
; b.Subroutine
;
; 1.2 Functional Description
; This file contains one subroutine:
; fft
;
; 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 fft.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, d_grps_cnt, d_twid_idx, d_data_idx, 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 fft
;}
; 5. SUBROUTINE CODE
; HeaderBegin
SPRA669
34 TMS320C54x Digital Filters
;==============================================================================
;
;–––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
; 5.1 fft
;

⌨️ 快捷键说明

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