📄 exp5.html
字号:
<p align=center style='text-align:center'> </p><p align=center style='text-align:center'>Table E5-6 Symmetric FIR filterassembly routine.</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="firsymm.asm">; ; firsymm.asm - Symmetric FIR filter ; (for even # of coefficients) ; ; prototype: unsigned int firsymm(int *, unsigned int, int *, ; unsigned int, int *, int *, unsigned int);	 ; ; Entry: arg0: AR0 - filter input buffer pointer ; arg1: T0 - number of samples in the input buffer ; arg2: AR1 - FIR coefficients array pointer ; arg3: T1 - FIR filter order ; arg4: AR2 - filter output buffer pointer ; arg5: AR3 - signal buffer pointer ; arg6: AR4 - signal buffer index ; ; Return: T0 = signal buffer index ; .def _firsymm .sect "fir_code" 	 _firsymm pshm ST1_55 ; Save ST1, ST2, and ST3 pshm ST2_55 pshm ST3_55 mov	 mmap(T1),BK03 ; Set signal buffer size = L	 or #0x340,mmap(ST1_55) ; Set FRCT,SXMD,SATD bset SMUL ; Set SMUL mov XAR1,XCDP ; CDP as coefficient pointer mov mmap(AR1),BSAC ; Set up base address for CDP sfts T1,#-1 ; T1 = L/2 || mov #0,CDP ; Start from the 1st coefficient mov mmap(T1),BKC ; Set the coefficient array size mov XAR3,XAR1 ; AR1 & AR3 are signal buffer pointers mov mmap(AR3),BSA01 ; Set base address of AR1 mov mmap(AR3),BSA23 ; Set base address of AR3 or #0x10A,mmap(ST2_55) ; CDP, AR1, AR3 are circular pointers mov AR4,AR3 ; AR3 is the Head of signal buffer mov AR4,AR1 ; AR1 is the Tail of signal buffer sub #1,T0 amar *AR1- ; Adjust tail starting point || mov T0,BRC0 ; Outer loop counter M blocks sub #3,T1,T0 ; Inner loop for (L/2-2) iteration mov T0,CSR mov T1,T0 ; Set up update offset for AR1 sub #2,T1 ; Set up update offset for AR3 mov *AR0+,AC1 ; Get the first sample || rptblocal sample_loop-1 ; To prevent overflow in addition mov #0,AC0 ; the input is scaled to Q14 format || mov AC1<<#-1,*AR3 ; Put input to signal buffer in Q14 add *AR3+,*AR1-,AC1 ; AC1=[x(n)+x(n-L+1)]<<16 || rpt CSR ; Do L/2-2 iterations firsadd *AR3+,*AR1-,*CDP+,AC1,AC0 firsadd *(AR3-T0),*(AR1+T1),*CDP+,AC1,AC0 macm *CDP+,AC1,AC0 ; Finish the last macm instruction mov	 rnd(hi(AC0<<1)),*AR2+ ; Store the rounded & scaled result || mov *AR0+,AC1 ; Get next sample sample_loop popm ST3_55 ; Restore ST1, ST2, and ST3 popm ST2_55 popm ST1_55 mov AR3,T0 ; Return signal buffer index || ret .end </TEXTAREA></p><p align=center style='text-align:center'> </p><p style='margin-right:72.0pt;margin-left:72.0pt'>To conduct Experiment 5B,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:l3 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"'>exp5b</span> and includethe linker command file <span style='font-family:"Courier New"'>exp5.cmd</span>,the function <span style='font-family:"Courier New"'>exp5b()</span>, and theFIR filter routine <span style='font-family:"Courier New"'>firsymm()</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:l3 level1 lfo3;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:l3 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>3.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Seta break point at the <span style='font-family:"Courier New"'>for(;;) </span>statementof the <span style='font-family:"Courier New"'>main()</span> function and useCCS graphic function to view the 16-bit integer output in the buffer <spanstyle='font-family:"Courier New"'>out[]</span>, set data length to 128 for viewingone block data a time.</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:l3 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Animatethe filtering process and observe the filter out as a clean sine wave of 800Hz.</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:l3 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>5.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Profilethe symmetric FIR filter and compare the result with Experiment 5A.</p></form><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 align=center style='text-align:center'><strong><span style='font-size:13.5pt;color:blue'>Experiment 5C - FIR Filter Implementation Using Dual_MAC</span></strong></p><p style='margin-right:72.0pt;margin-left:72.0pt'>Since the TMS320C55x hasdual_MAC units. It is possible to compute two FIR filter output samples inparallel. Experiment 5C demonstrates how an FIR filter can be implemented inparallel using the dual-MAC characteristics of the DSP. Table E5-7 and TableE5-8 give the function <a href="exp5/exp5c.c"><span style='font-family:"Courier New"'>exp5c.c</span></a>and assembly fir routine<span style='font-family:"Courier New"'> </span><ahref="exp5/fir2macs.asm"><span style='font-family:"Courier New"'>fir2mac.asm</span></a>,respectively.</p><p style='margin-right:72.0pt;margin-left:72.0pt'> </p><p align=center style='text-align:center'>Table E5-7 List of C function forExperiment 5C.</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="exp5c.c">/* exp5c.c - Dual-MAC block FIR filter function experiment using input data file */ #define M 128 /* Input sample size */ #define L 48 /* Number of FIR filter coefficients */ #define SN L+1 /* Signal buffer size */ extern unsigned int fir2macs(int *, unsigned int, int *, unsigned int, int *, int *, unsigned int); /* Define DSP system memory map */ #pragma DATA_SECTION(LP_h, "fir_coef"); #pragma DATA_SECTION(x, "fir_data"); #pragma DATA_SECTION(index, "fir_data"); #pragma DATA_SECTION(out, "output"); #pragma DATA_SECTION(in, "input"); #pragma DATA_SECTION(input, "input"); #pragma CODE_SECTION(main, "fir_code"); /* Input data */ #include "input5.dat" /* Low-pass FIR filter coefficients */ static int LP_h[L]={ -6,28,46,27,-35,-100,-93,26,191,240,52,-291,-497,-278, 337,888,773,-210,-1486,-1895,-442,2870,6793,9445, 9445,6793,2870,-442,-1895,-1486,-210,773,888,337, -278,-497,-291,52,240,191,26,-93,-100,-35,27,46,28,-6}; int x[SN]; /* Signal buffer */ unsigned int index; /* Signal buffer index */ int out[M]; /* Output buffer */ int in[M]; /* Input buffer */ void main(void) { unsigned int i,j; /* Initialize filter signal buffer */ for (i=0; i<SN;i++) x[i]=0;	 index=0; /* Processing samples using dual_MAC block FIR filter */ j=0; for (;;) { for (i=0; i<M; i++) { in[i]=input[j++];	/* Get a buffer of samples */ if (j == 160) j=0; } index=fir2macs(in,M,LP_h,L,out,x,index); /* FIR filter */ } } </TEXTAREA></p><p align=center style='text-align:center'> </p><p align=center style='text-align:center'>Table E5-8 FIR filter assemblyroutine that uses dual-MAC.</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="fir2macs.asm">; ; fir2macs.asm - Dual-MAC Block FIR filter ; ; prototype: unsigned int fir2macs(int *, unsigned int, int *, ; unsigned int, int *, int *, unsigned int);	 ; ; Entry: arg0: AR0 - filter input buffer pointer ; arg1: T0 - number of samples in the input buffer ; arg2: AR1 - FIR coefficients array pointer ; arg3: T1 - FIR filter order ; arg4: AR2 - filter output buffer pointer ; arg5: AR3 - signal buffer pointer ; arg6: AR4 - signal buffer index ; ; Return: T0 = signal buffer index ; .def _fir2macs .sect "fir_code" 	 _fir2macs pshm ST1_55 ; Save ST1, ST2, and ST3 pshm ST2_55 pshm ST3_55 or #0x340,mmap(ST1_55); Set FRCT,SXMD,SATD bset SMUL ; Set SMUL mov XAR1,XCDP ; CDP as coefficient pointer mov mmap(AR1),BSAC ; Set up base address for CDP mov #0,CDP ; Start from the 1st coefficient mov mmap(T1),BKC ; Set the coefficient array size mov XAR3,XAR1 ; AR1 & AR3 as signal buffer pointers mov mmap(AR3),BSA01 ; Set base address for AR1 mov mmap(AR3),BSA23 ; Set base address for AR3 add #1,T1 mov mmap(T1),BK03 ; Set signal buffer x[] size as L+1 mov AR4,AR3 ; AR3 signal buffer index mov AR4,AR1 	 or #0x10A,mmap(ST2_55); CDP, AR1, AR3 circular pointers amar *AR1+ ; AR1 delayline index+1 || sfts T0,#-1 ; Use half of data samples sub #1,T0 ; as outer repeat counter mov T0,BRC0 ; Outer loop couter	 sub #4,T1,T0 mov T0,CSR ; Inner loop counter as L/2-2 || rptblocal sample_loop-1 mov *AR0+,*AR1 ; Put new sample to signal buffer x[n] mov *AR0+,*AR3 ; Put next new sample to location x[n+1] mpy *AR1+,*CDP+,AC0 ; The first operation :: mpy *AR3+,*CDP+,AC1 || rpt CSR mac *AR1+,*CDP+,AC0 ; The rest MAC iterations :: mac *AR3+,*CDP+,AC1 macr *AR1,*CDP+,AC0 :: macr *AR3,*CDP+,AC1 ; The last MAC operation mov pair(hi(AC0)),dbl(*AR2+); Store two output data sample_loop 	 popm ST3_55 ; Restore ST1, ST2, and ST3 popm ST2_55 popm ST1_55 mov AR3,T0 ; Return signal buffer index || ret .end </TEXTAREA></p><p align=center style='text-align:center'> </p><p style='margin-right:72.0pt;margin-left:72.0pt'>To conduct Experiment 5C,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 lfo4;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"'>exp5c</span> and includethe linker command file <span style='font-family:"Courier New"'>exp5.cmd</span>,the function <span style='font-family:"Courier New"'>exp5c()</span>, and theFIR filter routine <span style='font-family:"Courier New"'>fir2macs()</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 lfo4;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:l1 level1 lfo4;tab-stops:list 36.0pt'><![if !supportLists]>3.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Seta break point at the <span style='font-family:"Courier New"'>for(;;) </span>statementof the <span style='font-family:"Courier New"'>main()</span> function and useCCS graphic function to view the 16-bit integer output in the buffer <spanstyle='font-family:"Courier New"'>out[]</span>, set data length to 128 forviewing one block data a time.</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 lfo4;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Animatethe filtering process and observe the filter out as a clean sine wave of 800Hz.</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 lfo4;tab-stops:list 36.0pt'><![if !supportLists]>5.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Profilethe dual-MAC FIR filter and compare the result with Experiment 5A and 5B.</p></form><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><p><i><u><span style='font-size:7.5pt'>copyright
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -