您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 质量控制/管理 > 离散余弦变换(DCT)的DSP程序设计与实现
《DSP技术及应用实习》1DSP课程设计论文题目离散余弦变换(DCT)的DSP实现专业电气工程及其自动化姓名陈梦泽班级11东电气学号11811527执行学期2014-2015《DSP技术及应用实习》2离散余弦变换(DCT)的DSP实现一、实验目的1.掌握离散余弦变换的概念和实现方法;2.掌握用C语言或汇编语言编写DSP程序的方法;3.熟悉DCT原理;二、实验设备1.一台装有CCS软件的计算机;2.DSP实验箱的TMS320C5410主控板;3.DSP硬件仿真器;三、实验原理论述1、原理离散余弦变换(DiscreteCosineTransform,简称DCT变换)是一种与傅立叶变换紧密相关的数学运算。在傅立叶级数展开式中,如果被展开的函数是实偶函数,那么其傅立叶级数中只包含余弦项,再将其离散化可导出余弦变换,因此称之为离散余弦变换。对于给定的实际数据序列x(0),X(1),x(2)....X(N-1)的DCT(FDCT)算法如下:z(k)N()()cos()221201kxnnkNnN(1)其中:()()kk12fork=01fork0(2)二维离散余弦变换(FDCT):z(k,)()()(,)cos()cos()lNklxmnmkNnlNmNnN22122120101(3)其逆运算是:《DSP技术及应用实习》3xmnNklzklmkNnlNlNkN(,)()()(,)cos()cos()22122120101(4)其中N=8为8x8DCT.2、DCT的DSP程序设计无论是C语言还是汇编语言,程序流程均分为初始化、行变换、列变换和移位输出四个步骤。行、列变换具有相似性,如果对行变换的结果矩阵转置,则列变换程序跟行变换一样。对于汇编而言,初始化部分主要初始化FP指针以指向前一函数地址,初始化数据和指针寄存器以保存返回数据等。由于DCT行变和列变换过程相似,且列变换是在行变换操作的基础上进行的。则可利用多种索引寻址寄存器的灵活组合,把行变换结果直接以转置方式存储而不增加实际的存储时间,这样行列变换可使用同一代码循环两次实现,减小了实际代码大小。本程序实现的是FDCT,可以使用2次一维DCT变换来实现二维DCT变换。3、DCT的DSP实现二维DCT变换时结果为两次无理数sqrt(8)相乘,产生了有理项,因此,在程序里首先多乘一次sqrt(8),然后在两次DCT变换结束以后,使用右移3位以达到正常输出。四、方案论证及系统设计本次实习有两种方案,C语言和汇编语言实现,由于考虑到DSP程序的特点,我采用汇编语言实现。1.打开CCS软件,编制程序简化行列变换的代码如下:2.B0=R0;B3=R1;B2=R2;…LSETUP(DCT_START,DCT_END)LC0=P0;DCT_START:…LSETUP(ROW_START,ROW_END)LC1=P2;《DSP技术及应用实习》4ROW_START:…ROW_END:…B1=B0;B0=B2;DCT_END:B2=B1;五、一维DCT变换流程图《DSP技术及应用实习》5六、程序模块源程序DSP程序:.mmregs.defentry.sectINIT**Initialise*entryNOPNOPSSBXSXM;setsignextensionmodeSSBXOVM;enablesaturationLD#0,DP;setdatapageSTM0FFE0h,PMST;InitPMSTreg.RSBXFRCT.includefdct_dat.inc;FDCTdatastoragedeclarationMODE.SET1;MODE=1TESTONSIMULATORPAGE0.SET0PAGE4.SET4PAGE24.SET24dPAGE25.SET25dB0.SET0200hB1.SET0300hB2.SET060hPA1BIS.SET1PA2BIS.SET2PA3BIS.SET3PA4BIS.SET4PA5BIS.SET5《DSP技术及应用实习》6PA6BIS.SET6*Initializationoftheregisters.sectFDCTINITLD#PAGE24,DPST#21407,E_P6ST#8867,F_P6ST#2000H,ROUND1TBL:LD#PAGE25,DPST#21407,E_P7ST#8867,F_P7ST#4000H,ROUND2ST#40H,ROUND3START*IFMODE=SIMULATOR.IFMODE=1STM#63,AR0;AR0=#ofinputstobetaken-1STM#X,AR1;AR1=addressoffirstinputBEGPORTR#PA1BIS,*AR1+;Readandstoretoaddr(AR1)BANZBEG,*AR0-;Repeatabovecode64times;tillall64pixelsareread.ENDIFSTM#3,AR0STM#X,AR1;ResetAR1tofirstinputSTM#Y00,AR2;SetAR2tofirstYblockDCT1NOPNOPLD#PAGE24,DPLD*AR1+,4,A;+(16)*(X0)ADD*AR1+,4,A;+(16)*(X1)《DSP技术及应用实习》7ADD*AR1+,4,A;+(16)*(X2)ADD*AR1+,4,A;+(16)*(X3)ADD*AR1+,4,A;+(16)*(X4)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iplyprevsummationby16;=Y06RPTZA,#7MACP*AR1-,COEF_F4,A;64(D*X0-C*X1+B*X2-A*X3+A*X4-B*X5SFTAA,4;+C*X6-D*X7)MAR*AR1+ADDROUND1,A;+4*ROUND1STHA,2,Y07;=Y07MAR*+AR1(8);SetAR1topointtothenextset;of8inputsDCT3NOPNOP**PLACEFDCTCOEFFICIENTSINFILEPOINTEDBYPA2.IFMODE=1STM#63,AR0;AR0=#ofoutputs-1STM#Z00,AR1;AR1=addroffirstoutputBEG1PORTW*AR1+,#PA2BIS;SendoutputvalueBANZBEG1,*AR0-;Repeataboveprocess(64x).ENDIFEXITNOPBSTART;Gotostartofprogram.;Grabanother64pixelsCOEF_F1.WORD-22725,-19266,-12873,-4520,4520,12873,19266,22725《DSP技术及应用实习》10COEFF2.WORD19266,-4520,-22725,-12873,12873,22725,4520,-19266COEFF3.WORD12873,-22725,4520,19266,-19266,-4520,22725,-12873COEF_F4.WORD-4520,12873,-19266,22725,-22725,19266,-12873,4520*with:A=cos(?16)*?*16384=22725*B=cos(3?16)*?*16384=19266*C=cos(5?16)*?*16384=12873*D=cos(7?16)*?*16384=4520*E=cos(?8)*?*16384=21407*F=cos(3?8)*?*16384=8867*.END链接文件:-mfdct.map-ofdct.out-eentryfdct.objMEMORY{PAGE0:OCDARAM1:origin=00080hlength=00880h/*on-chipDARAM*/OCDARAM2:origin=00900hlength=00300hOCDARAM4:origin=00C00hlength=00400hOCDARAM5:origin=01000hlength=00400hEXTERNAL:origin=01400hlength=0EB80hINTRVECS:origin=0FF80hlength=00079h《DSP技术及应用实习》11PAGE1:MMREGS:origin=00000hlength=00060hSPRAM:origin=00060hlength=00020hOCDARAM1:origin=00080hlength=00400h/*on-chipDARAM*/OCDARAM2:origin=00480hlength=0077FhOCDARAM4:origin=00C00hlength=00400hOCDARAM5:origin=01000hlength=00400hEXTERNAL:origin=01400hlength=0EC00h}SECTIONS{INITOCDARAM1PAGE0FDCTOCDARAM1PAGE0.bssOCDARAM4PAGE1}七、仿真调试及性能分析与实验1.开电,运行CCS软件,打开项目文件fdct.prj,编译运行并下载。2.设置断点,再点击“运行”按钮,如下图所示。这里的相关
本文标题:离散余弦变换(DCT)的DSP程序设计与实现
链接地址:https://www.777doc.com/doc-3357653 .html