📄 exp4.html
字号:
<p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="exp4.cmd">/* SPECIFY THE SYSTEM MEMORY MAP */ MEMORY { RAM (RWIX) : origin=0100h, length=00feffh /* Data Memory */ RAM1 (RWIX) : origin=010000h, length=000200h RAM2 (RWIX) : origin=010400h, length=000400h RAM3 (RWIX) : origin=040100h, length=040000h /* Program Memory */ ROM (RIX) : origin=020100h, length=000200h /* Program Memory */ ROM1 (RIX) : origin=020400h, length=000200h ROM2 (RIX) : origin=020600h, length=00FC00h VECS (RIX) : origin=0ffff00h length=00100h /* Reset Vector */ } /* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */ SECTIONS { vectors > VECS /* Interrupt vector table */ .text > ROM /* CODE */ .code > ROM1 .switch > RAM /* SWITCH TABLE INFO */ .const > RAM /* CONSTANT DATA */ .cinit > RAM3 /* INITIALIZATION TABLES */ .data > RAM /* INITIALIZED DATA */ indata > RAM1 outdata > RAM2 .bss > RAM /* GLOBAL & STATIC VARS */ .stack > RAM /* PRIMARY SYSTEM STACK */ } </TEXTAREA></p><p align=center style='margin-right:36.0pt;margin-left:36.0pt;text-align:center'> </p><p style='margin-right:72.0pt;margin-left:72.0pt'>The C function <spanstyle='font-family:"Courier New"'>exp4a()</span> calls the assembly routines tocompute an 128-point DFT and plot the frequency domain result as its spectrum.The <a href="exp4/dft_128.asm"><span style='font-family:"Courier New"'>dft_128.asm</span></a>performs 128-point complex DFT, while <a href="exp4/mag_128.asm"><spanstyle='font-family:"Courier New"'>mag_128.asm</span></a> calculates thespectrum of the DFT result. Table E4-3 and Table E4-4 are these two assemblyroutines, respectively.</p><p style='margin-right:72.0pt;margin-left:72.0pt'> </p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE4-3 128-point DFT routine</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="dft_128.asm">; ; DFT_128 - compute 128 points DFT ; ; Entry T0: AR0: pointer to complex input sample buffer ; AR1: pointer to complex output sample buffer ; Return: None ; .def	_dft_128 .ref	_sine_cos	 N .set 128 TWOPIN .set 0x7fff>>6 ; 2*PI/N, N=128 .bss Wn,2 ; Wn[0]=Wr, Wn[1]=Wi .bss angle,1 ; Angle for sine-cosine function .text	 _dft_128 pshboth XAR5 ; Save AR5 bset SATD mov #N-1,BRC0 ; Repeat counter for loop N times mov #N-1,BRC1 ; Repeat counter for loop N times mov XAR0,XAR5 ; AR5 pointer to sample buffer mov XAR0,XAR3 mov #0,T2 ; k = T2 = 0 rptb outer_loop-1 ; for(k=0;k<N;k++) { mov XAR3,XAR5 ; Reset x[] pointer mov #TWOPIN<<#16,AC0; hi(AC0) = 2*PI/N mpy T2,AC0 mov #0,AC2 ; Xr[k] = 0 mov #0,AC3 ; Xi[k] = 0 mov #0,*(angle)	 mov AC0,T3 ; angle=2*PI*k/N rptb inner_loop-1 ; for(n=0;n<N;n++) { mov *(angle),T0 ; T0=2*PI*k*n/N mov *(angle),AC0 add T3,AC0 mov AC0,*(angle) ; Update angle amov #Wn,XAR0 ; AR0 is the pointer to Wn call _sine_cos ; sine_cos(angle, Wn) bset SATD ; sine_cos turn off FRCT & SATD macm40 *AR5+,*AR0,AC2 ; XR[k]+Xin[n]*Wr macm40 *AR5-,*AR0+,AC3 ; XI[k]+Xin[n+1]*Wr masm40 *AR5+,*AR0,AC3 ; XI[k]+Xin[n+1]*Wr-Xin[n]*Wi macm40 *AR5+,*AR0-,AC2 ; XR[k]+Xin[n]*Wr+Xin[n+1]*Wi inner_loop ; } end of inner loop mov hi(AC2<<#-5),*AR1+ mov hi(AC3<<#-5),*AR1+ add #1,T2 outer_loop ; } end of outer loop popboth XAR5 bclr SATD ret .end </TEXTAREA></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'> </p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>TableE4-4 Computing spectrum</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="mag_128.asm">; ; Compute the magnitude of the input complex sample ; ; Entry: AR0: input buffer pointer ; AR1: output buffer pointer ; Exit: None ; .def _mag_128 N .set 128 .text _mag_128 bset SATD pshboth XAR5 mov #N-1,BRC0 ; Set BRC0 for loop N times mov XAR0,XAR5 bset FRCT rptblocal mag_loop-1 mpym *AR0+,*AR5+,AC0 ; Xr[i]*Xr[i] macm *AR0+,*AR5+,AC0 ; Xr[i]*Xr[i]+Xi[i]*Xi[i] mov hi(saturate(AC0)),*AR1+ mag_loop popboth XAR5 bclr SATD bclr FRCT ret .end </TEXTAREA></p><p style='margin-right:72.0pt;margin-left:72.0pt'>To conduct Experiment 4A,following these steps:</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>1.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Createthe project, <em>exp4a</em> and include the linker command file <spanstyle='font-family:"Courier New"'>exp4.cmd</span>, the function <spanstyle='font-family:"Courier New"'>exp4a()</span>, <span style='font-family:"Courier New"'>dft_128.asm</span>, and <span style='font-family:"Courier New"'>mag_128.asm</span>.</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>2.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Use<span style='font-family:"Courier New"'>rts55.lib</span> for <spanstyle='font-family:"Courier New"'>main()</span> function initialization andbuild the project.</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>3.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Buildthe project and debug if needed.</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>UsingCCS to display the time domain and frequency domain samples of <spanstyle='font-family:"Courier New"'>input.dat</span> and <span style='font-family:"Courier New"'>spectrum[]</span>, the DFT result see Figure E4-1.</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l0 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>5.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Profilethe DFT routine and record the memory usage.</p><p style='margin-right:72.0pt;margin-left:72.0pt'> </p><p style='margin-right:72.0pt;margin-left:72.0pt'><img border=0 width=1024height=768 id="_x0000_i1027" src="exp4/fe4-1.jpg"></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>FigureE4-1 DFT experiment results.</p><p><a href="#top"><span style='font-size:7.5pt'>Back to Top</span></a> <input type=button value="go back" onclick="history.go(-1)"></p><div class=MsoNormal align=center style='text-align:center'><hr size=3 width="100%" align=center></div></form><form><p align=center style='text-align:center'><strong><span style='font-size:13.5pt;color:blue'>Experiment 4B - Using Assembly Routines</span></strong></p><p style='margin-right:72.0pt;margin-left:72.0pt'>This is the first experimentthat we will conduct using only assembly routines. To do so, we will need toinitialize the system using an assembly routine called <ahref="exp4/vectors.asm"><span style='font-family:"Courier New"'>vectors.asm</span></a>.This routine will initialize the DSP system stocks, setting status registers,and start the execution upon power up or reset signals. The function <ahref="exp4/exp4b.asm"><span style='font-family:"Courier New"'>exp4b.asm</span></a>for this experiment is listed below in Table E4-5.</p><p style='margin-right:72.0pt;margin-left:72.0pt'> </p><p align=center style='text-align:center'>Table E4-5 List of C function forExperiment 4B</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="exp4b.asm">;	exp4b.asm: Call dft_128 to compute DFT ; N .set 128 stk_size	.set	0x100 stack	.usect ".stack",stk_size sysstack	.usect ".stack",stk_size _Xin 	.usect "in_data",2*N _Xout 	.usect "out_data",2*N _Spectrum	.usect "out_data",N .sect .data input .copy input.inc .def start .def _Xin,_Xout,_Spectrum .ref _dft_128,_mag_128	 .sect .text start bset SATD ; Set up saturation for D unit bset SATA ; Set up saturation for A unit bset SXMD ; Set up sign extension mode bclr C54CM ; Disable C54x compatibility mode bclr CPL ; Turn off compiler mode amov #(stack+stk_size),XSP ; Setup DSP stack mov #(sysstack+stk_size),SSP ; Setup system stack mov #N-1,BRC0 ; Init counter for loop N times amov #input,XAR0 ; Input data array pointer amov #_Xin,XAR1 ; Xin array pointer rptblocal complex_data-1 ; Form complex data mov *AR0+,*AR1+ mov #0,*AR1+ complex_data amov #_Xin,XAR0 ; Xin array pointer amov #_Xout,XAR1 ; Xout array pointer call _dft_128 ; Perform 128-ponts DFT amov #_Xout,XAR0 ; Xout pointer amov #_Spectrum,XAR1 ; Spectrum array pointer call _mag_128 ; Computer squared-mag response here	 b here .end </TEXTAREA></p><p align=center style='text-align:center'> </p><p align=center style='text-align:center'>Table E4-6 List of vectors.asm</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="vectors.asm">; ;	vectors.asm ; 	.def	rsv 	.ref	start 	.sect	"vectors" rsv	.ivec	start 	</TEXTAREA></p><p style='margin-right:72.0pt;margin-left:72.0pt'>To conduct Experiment 4B,following these steps:</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>1.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Createthe project, <span style='font-family:"Courier New"'>exp4b</span> and includethe linker command file <span style='font-family:"Courier New"'>exp4.cmd</span>,the assembly routine <span style='font-family:"Courier New"'>exp4b.asm</span>,and <span style='font-family:"Courier New"'>vectors.asm</span>.</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>2.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Buildthe project. Debug is needed.</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>3.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Use.sect, directive to allocate the data variables Xin[256], Xout[256], andSpectrum[128] at 0x8000 and 0x8800. Use .code to allocate the program routineexp4b.asm at address 0x20400.</p><p class=MsoNormal style='margin-right:72.0pt;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;margin-left:108.0pt;text-indent:-18.0pt;mso-list:l1 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Testthe DFT routine and verify the memory locations.</p><p><a href="#top"><span style='font-size:7.5pt'>Back to Top</span></a> <input type=button value="go back" onclick="history.go(-1)"></p><div class=MsoNormal align=center style='text-align:center'><hr size=3 width="100%" align=center></div></form><p><i><u><span style='font-size:7.5pt'>copyright
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -