完整word版基于DSP的快速傅立叶变换FFT的实现汇编语言.docx
- 文档编号:26960889
- 上传时间:2023-06-24
- 格式:DOCX
- 页数:24
- 大小:131.70KB
完整word版基于DSP的快速傅立叶变换FFT的实现汇编语言.docx
《完整word版基于DSP的快速傅立叶变换FFT的实现汇编语言.docx》由会员分享,可在线阅读,更多相关《完整word版基于DSP的快速傅立叶变换FFT的实现汇编语言.docx(24页珍藏版)》请在冰豆网上搜索。
完整word版基于DSP的快速傅立叶变换FFT的实现汇编语言
快速傅立叶变换(FFT)的实现
一、实验目的
1.了解FFT的原理及算法;
2.了解DSP中FFT的设计及编程方法;
3.熟悉FFT的调试方法;
二、实验原理
FFT是一种高效实现离散付立叶变换的算法,把信号从时域变换到频域,在频域分析处理信息。
对于长度为N的有限长序列x(n),它的离散傅里叶变换为:
,称为旋转因子,或蝶形因子。
在x(n)为复数序列的情况下,计算X(k):
对某个k值,需要N次复数乘法、(N-1)次复数加法;
对所有N个k值,需要
次复数乘法和N(N-1)次复数加法。
对于N相当大时(如1024)来说,直接计算它的DFT所作的计算量是很大的,
FFT的基本思想在于:
利用
的周期性即:
对称性:
将原有的N点序列分成两个较短的序列,这些序列的DFT可以很简单的组合起来得到原序列的DFT。
按时间抽取的FFT——DITFFT信号流图如图5.1所示:
图5.1时间抽取的FFT—DITFFT信号流图
FFT算法主要分为以下四步。
第一步输入数据的组合和位倒序
把输入序列作位倒序是为了在整个运算最后的输出中得到的序列是自然顺序。
第二步实现N点复数FFT
第一级蝶形运算;第二级蝶形运算;第三级至log2N级蝶形运算;
FFT运算中的旋转因子
是一个复数,可表示:
为了实现旋转因子
的运算,在存储空间分别建立正弦表和余弦表,每个表对应从0度到180度,采用循环寻址来对正弦表和余弦表进行寻址。
第三步功率谱的计算
X(k)是由实部
和虚部
组成的复数:
;计算功率谱时只需将FFT变换好的数据,按照实部
和虚部
求它们的平方和,然后对平方和进行开平方运算。
第四步输出FFT结果。
三、实验内容与步骤
1.本实验要求使用FFT变换求一个时域信号的频域特性,并从这个频域特性求出该信号的频率值,然后使用DSP汇编语言对FFT的DSP编程。
2.将计算机与DES-320PP—A教学实验系统连接好,打开实验箱电源,然后运行CCS软件。
2.新建fft.pjt工程文件,并输入FFT的DSP程序及命令链接文件。
如下:
**************************************
*Radix-2,DIT,Real-inputFFTProgram*
*fft.asm*
*************************************
.mmregs
.globalreset,start,sav_sin,sav_idx,sav_grp
.defstart,_c_int00
.data
DATA.space1024
.copy"fft.inc"
N.set128
LOGN.set7
sav_grp.usect"tempv",3
sav_sin.setsav_grp+1
sav_idx.setsav_grp+2
OUTPUT.usect"OUTPUT",256
BOS.usect"stack",0Fh
TOS.usect"stack",1
.copy"twiddle1.inc"
.copy"twiddle2.inc"
.text
_c_int00
bstart
nop
nop
start:
STM#TOS,SP
LD#0,DP
SSBXFRCT
STM#2*N,BK
STM#INPUT,AR3
STM#DATA,AR7
MVMMAR7,AR2
STM#N-1,BRC
RPTBDplend-1
STM#N,AR0
LDMAR3,A
READA*AR2+
ADD#1,A
READA*AR2+
MAR*AR3+0B
plend:
STM#0,BK
LD#-1,ASM
MVMMAR7,AR2
STM#DATA+2,AR3
STM#N/2-1,BRC
LD*AR2,16,A
RPTBDs1end-1
STM#3,AR0
SUB*AR3,16,A,B
ADD*AR3,16,A
STHA,ASM,*AR2+
STB,*AR3+
||LD*AR2,A
SUB*AR3,16,A,B
ADD*AR3,16,A
STHA,ASM,*AR2+0
STB,*AR3+0%
||LD*AR2,A
s1end:
MVMMAR7,AR2
STM#DATA+4,AR3
STM#N/4-1,BRC
LD*AR2,16,A
RPTBDs2end-1
STM#5,AR0
SUB*AR3,16,A,B
ADD*AR3,16,A
STHA,ASM,*AR2+
STB,*AR3+
||LD*AR2,A
SUB*AR3,16,A,B
ADD*AR3,16,A
STHA,ASM,*AR2+
STHB,ASM,*AR3+
MAR*AR3+
ADD*AR2,*AR3,A
SUB*AR2,*AR3-,B
STHA,ASM,*AR2+
SUB*AR2,*AR3,A
STB,*AR3
||LD*AR3+,B
STA,*AR2
||ADD*AR2+0%,A
STA,*AR3+0%
||LD*AR2,A
s2end:
STM#512,BK
ST#128,@sav_sin
STM#128,AR0
STM#TWI2,AR4
STM#TWI1,AR5
STM#-3+LOGN,AR7
ST#-1+N/8,@sav_grp
STM#3,AR6
ST#8,@sav_idx
stage:
STM#DATA,AR2
LD@sav_idx,A
ADD*(AR2),A
STLMA,AR3
MVDK@sav_grp,AR1
group:
MVMDAR6,BRC
RPTBDbend-1
LD*AR4,T
MPY*AR3+,A
MACR*AR5+0%,*AR3-,A
ADD*AR2,16,A,B
STB,*AR2
||SUB*AR2+,B
STB,*AR3
||MPY*AR3+,A
MASR*AR3,*AR4+0%,A
ADD*AR2,16,A,B
STB,*AR3+
||SUB*AR2,B
LD*AR4,T
STB,*AR2+
||MPY*AR3+,A
bend:
PSHMAR0
MVDKsav_idx,AR0
MAR*AR2+0
MAR*AR3+0
BANZDgroup,*AR1-
POPMAR0
MAR*AR3-
LDsav_idx,A
SUB#1,A,B
STLMB,AR6
STLA,1,sav_idx
LDsav_grp,A
STLA,ASM,sav_grp
LDsav_sin,A
STLA,ASM,sav_sin
BANZDstage,*AR7-
MVDKsav_sin,AR0
STM#DATA+2,AR2
STM#DATA+2*N-2,AR3
STM#DATA+2*N+3,AR7
STM#DATA+4*N-1,AR6
STM#-2+N/2,BRC
RPTBDp3end-1
STM#3,AR0
ADD*AR2,*AR3,A
SUB*AR2,*AR3,B
STHA,ASM,*AR2+
STHA,ASM,*AR3+
STHB,ASM,*AR6-
NEGB
STHB,ASM,*AR7-
ADD*AR2,*AR3,A
SUB*AR2,*AR3,B
STHA,ASM,*AR2+
STHA,ASM,*AR3-0
STHB,ASM,*AR6-
NEGB
STHB,ASM,*AR7+0
p3end:
ST#0,*AR6-
ST#0,*AR6
p3test:
STM#DATA,AR2
STM#DATA+1,AR4
STM#DATA+2*N+1,AR5
ADD*AR2,*AR4,A
SUB*AR2,*AR4,B
STHA,ASM,*AR2+
ST#0,*AR2
MVDD*AR2+,*AR5-
STHB,ASM,*AR5
STM#DATA+4*N-1,AR3
STM#TWI2+512/N,AR4
STM#TWI1+512/N,AR5
STM#N-2,BRC
RPTBDp4end-1
STM#512/N,AR0
LD*AR2+,16,A
MACR*AR4,*AR2,A
MASR*AR5,*AR3-,A
LD*AR3+,16,B
MASR*AR5+0%,*AR2-,B
MASR*AR4+0%,*AR3,B
STHA,ASM,*AR2+
STHB,ASM,*AR2+
NEGB
STHB,ASM,*AR3-
STHA,ASM,*AR3-
p4end:
power:
STM#OUTPUT,AR3;AR3指向输出缓冲地址
STM#255,BRC;块循环计数器设置为255
RPTBDpower_end-1;带延迟方式的重复执行指令
STM#DATA,AR2;AR2指向AR[0]
SQUR*AR2+,A;A:
=AR2
SQURA*AR2+,A;A:
=AR2+AI2
STHA,7,*AR3;将A中的数据存入输出缓冲中,
ANDM#7FFFH,*AR3+;避免输出数据过大在虚拟示波器中显示错误
power_end:
Bpower_end
.end
命令链接文件:
/*fft.cmd*/
fft.obj
-mfft.map
-offt.out
MEMORY
{
PAGE0:
ROM(RIX):
origin=8000h,length=1000h
ROM1:
origin=9000h,length=0200h
PAGE1:
B2A(RW):
origin=0060h,length=10h
B2B(RW):
origin=0070h,length=10h
INTRAM1(RW):
origin=0400h,length=0200h
INTRAM2(RW):
origin=0800h,length=0200h
INTRAM3(RW):
origin=1400h,length=0800h
OTHER:
origin=2000h,length=800h
}
SECTIONS
{
.text:
{}>ROMPAGE0
INPUT:
{}>ROM1PAGE0
.data:
{}>INTRAM3PAGE1
twiddle1:
{}>INTRAM1PAGE1
twiddle2:
{}>INTRAM2PAGE1
tempv:
{}>B2APAGE1
stack:
{}>B2BPAGE1
OUTPUT:
{}>OTHERPAGE1
.stack:
{}>OTHERPAGE1
}
三角因子:
TWI1:
.sect"twiddle1"
.int0,201,402,603
.int804,1005,1206,1407
.int1607,1808,2009,2210
.int2410,2611,2811,3011
.int3211,3411,3611,3811
.int4011,4210,4409,4609
.int4808,5006,5205,5403
.int5602,5800,5997,6195
.int6392,6589,6786,6983
.int7179,7375,7571,7766
.int7961,8156,8351,8545
.int8739,8933,9126,9319
.int9512,9704,9896,10087
.int10278,10469,10659,10849
.int11039,11228,11416,11605
.int11793,11980,12167,12353
.int12539,12725,12910,13094
.int13278,13462,13645,13828
.int14010,14191,14372,14552
.int14732,14912,15090,15269
.int15446,15623,15800,15976
.int16151,16325,16499,16673
.int16846,17018,17189,17360
.int17530,17700,17869,18037
.int18204,18371,18537,18703
.int18868,19032,19195,19358
.int19519,19681,19841,20001
.int20159,20318,20475,20631
.int20787,20942,21097,21250
.int21403,21555,21706,21856
.int22005,22154,22301,22448
.int22594,22740,22884,23027
.int23170,23312,23453,23593
.int23732,23870,24007,24144
.int24279,24414,24547,24680
.int24812,24943,25073,25201
.int25330,25457,25583,25708
.int25832,25955,26077,26199
.int26319,26438,26557,26674
.int26790,26905,27020,27133
.int27245,27356,27466,27576
.int27684,27791,27897,28002
.int28106,28208,28310,28411
.int28511,28609,28707,28803
.int28898,28993,29086,29178
.int29269,29359,29447,29535
.int29621,29707,29791,29874
.int29956,30037,30117,30196
.int30273,30350,30425,30499
.int30572,30644,30714,30784
.int30852,30919,30985,31050
.int31114,31176,31237,31298
.int31357,31414,31471,31526
.int31581,31634,31685,31736
.int31785,31834,31881,31927
.int31971,32015,32057,32098
.int32138,32176,32214,32250
.int32285,32319,32351,32383
.int32413,32442,32469,32496
.int32521,32545,32568,32589
.int32610,32629,32647,32663
.int32679,32693,32706,32718
.int32728,32737,32745,32752
.int32758,32762,32765,32767
.int32767,32767,32765,32762
.int32758,32752,32745,32737
.int32728,32718,32706,32693
.int32679,32663,32647,32629
.int32610,32589,32568,32545
.int32521,32496,32469,32442
.int32413,32383,32351,32319
.int32285,32250,32214,32176
.int32138,32098,32057,32015
.int31971,31927,31881,31834
.int31785,31736,31685,31634
.int31581,31526,31471,31414
.int31357,31298,31237,31176
.int31114,31050,30985,30919
.int30852,30784,30714,30644
.int30572,30499,30425,30350
.int30273,30196,30117,30037
.int29956,29874,29791,29707
.int29621,29535,29447,29359
.int29269,29178,29086,28993
.int28898,28803,28707,28609
.int28511,28411,28310,28208
.int28106,28002,27897,27791
.int27684,27576,27466,27356
.int27245,27133,27020,26905
.int26790,26674,26557,26438
.int26319,26199,26077,25955
.int25832,25708,25583,25457
.int25330,25201,25073,24943
.int24812,24680,24547,24414
.int24279,24144,24007,23870
.int23732,23593,23453,23312
.int23170,23027,22884,22740
.int22594,22448,22301,22154
.int22005,21856,21706,21555
.int21403,21250,21097,20942
.int20787,20631,20475,20318
.int20159,20001,19841,19681
.int19519,19358,19195,19032
.int18868,18703,18537,18371
.int18204,18037,17869,17700
.int17530,17360,17189,17018
.int16846,16673,16499,16325
.int16151,15976,15800,15623
.int15446,15269,15090,14912
.int14732,14552,14372,14191
.int14010,13828,13645,13462
.int13278,13094,12910,12725
.int12539,12353,12167,11980
.int11793,11605,11416,11228
.int11039,10849,10659,10469
.int10278,10087,9896,9704
.int9512,9319,9126,8933
.int8739,8545,8351,8156
.int7961,7766,7571,7375
.int7179,6983,6786,6589
.int6392,6195,5997,5800
.int5602,5403,5205,5006
.int4808,4609,4409,4210
.int4011,3811,3611,3411
.int3211,3011,2811,2611
.int2410,2210,2009,1808
.int1607,1407,1206,1005
.int804,603,402,201
TWI2:
.sect"twiddle2"
.int32767,32767,32765,32762
.int32758,32752,3
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 完整 word 基于 DSP 快速 傅立叶 变换 FFT 实现 汇编语言