📄 exp3.html
字号:
<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:l5 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>2.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Use<spanstyle='font-family:"Courier New"'> rts55.lib</span> for <span style='font-family:"Courier New"'>main()</span> function initialization and build 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:l5 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:l5 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>UsingCCS to display all output buffers <span style='font-family:"Courier New"'>out16[]</span>,<span style='font-family:"Courier New"'>out12[]</span>, <span style='font-family:"Courier New"'>out8[]</span>, and <span style='font-family:"Courier New"'>out6[]</span>,set integer data type with data length 40 for viewing, see Figure E3-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:l5 level1 lfo2;tab-stops:list 36.0pt'><![if !supportLists]>5.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Comparethe results of each output stream and describe the differences between thewaveform represented by different wordlength.</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=794height=471 id="_x0000_i1027" src="exp3/fe3-1.jpg"></p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'>FigureE3-1 Quantization effects of 12, 8, and 6 bits to a sinusoid signal.</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 3B - Quantization of Speech Signals</span></strong></p><p style='margin-right:72.0pt;margin-left:72.0pt'>Speech is one of most usedsignals in DSP applications, from cell phone to MP3 player. To understand thequztization effects to the speech signals, this experiment uses a digitizedspeech file <a href="exp3/timit1.asc"><span style='font-family:"Courier New"'>timit1.asc</span></a>as input for demonstration. The function <a href="exp3/exp3b.c"><spanstyle='font-family:"Courier New"'>exp3b.c</span></a> for this experiment islisted below.</p><p style='margin-right:72.0pt;margin-left:72.0pt'> </p><p align=center style='text-align:center'>Table E3-2 List of C function forExperiment 3B.</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="exp3bc">/* --------------------------------------------------------------- exp3b.c 	 Quantization effect 	 1. Use timit1.asc as input file	 2. Add the format line to timit1.asc for CCS probe point Example: 1651 2 c4 1 1 ^ ^ ^ ^ ^ | | | | |_ one data a time | | | |___ data page | | |_____ variable address (it may change in your case) | |________ deciaml formated data |____________ magic number 3. Set probe points on each C statement inside the for loop	 4. Connect input file, timit1.asc to the 1st statement 5. Connect 4 output files to the 4 statements 6. After obtained output files, remove the format header from each file 	 ------------------------------------------------------------------- */ #define	FILELENGTH 27956 /* # of sample of input file timit1.asc */ int indata,out16,out12,out8,out4; void main(void) { int i; 		 for(i = 0; i < FILELENGTH; i++) {		 out16 = indata&0xffff; /* Direct output to simulate a 16-bit A/D */ out12 = indata&0xfff0; /* Direct output to simulate a 12-bit A/D */ out8 = indata&0xff00; /* Direct output to simulate an 8-bit A/D */ out4 = indata&0xf000; /* Direct output to simulate a 4-bit A/D */	 } }	 </TEXTAREA></p><p align=center style='text-align:center'> </p><p style='margin-right:72.0pt;margin-left:72.0pt'>To conduct Experiment 3B,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 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"'>exp3b</span> and includethe linker command file <span style='font-family:"Courier New"'>exp3.cmd</span>,the function <span style='font-family:"Courier New"'>exp3b()</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 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:l0 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>3.<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:l0 level1 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Usethe File I/O capability of the CCS to connect the speech data file timit1.ascto your project using probe points.</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 lfo3;tab-stops:list 36.0pt'><![if !supportLists]>5.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Afterquantizing the speech file to 12-bit, 8-bit, and 4-bit, using File I/O to savethe quantized speech files to disk. Then, using MATLAB or other programs tolisten to the original speech file and comparing it with three quantized speechfiles at 12, 8, and 4 bits.</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><p align=center style='text-align:center'><strong><span style='font-size:13.5pt;color:blue'>Experiment 3C - Overflow and Saturation Arithmetic</span></strong></p><p style='margin-right:72.0pt;margin-left:72.0pt'>Overflow may occur infixed-point DSP system when the number is larger than the register or memorycan handle. In this experiment, we use assembly routine <ahref="exp3/ovf_sat.asm"><span style='font-family:"Courier New"'>ovf_sat.asm</span></a>to demonstrate the overflow and overflow handling. The function<spanstyle='font-family:"Courier New"'> </span><a href="exp3/exp3c.c"><spanstyle='font-family:"Courier New"'>exp3c.c</span></a><span style='font-family:"Courier New"'> </span>for this experiment and the assembly routine <ahref="exp3/ovf_sat.asm"><span style='font-family:"Courier New"'>ovf_sat.asm</span></a><spanstyle='font-family:"Courier New"'> </span>are listed in Table E3-3 and TableE3-4, respectively.</p><p style='margin-right:72.0pt;margin-left:72.0pt'> </p><p align=center style='text-align:center'>Table E3-3 List of C function forExperiment 3C.</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="exp3c.c">/* -------------------------------------------- exp3c.c 	 Understand overflow 	 ----------------------------------------------- */ 	 	 #define	BUF_SIZE 40 int sineTable[BUF_SIZE]={ 0x0000,0x000f,0x001e,0x002d,0x003a,0x0046,0x0050,0x0059, 0x005f,0x0062,0x0063,0x0062,0x005f,0x0059,0x0050,0x0046, 0x003a,0x002d,0x001e,0x000f,0x0000,0xfff1,0xffe2,0xffd3, 0xffc6,0xffba,0xffb0,0xffa7,0xffa1,0xff9e,0xff9d,0xff9e, 0xffa1,0xffa7,0xffb0,0xffba,0xffc6,0xffd3,0xffe2,0xfff1}; 			 extern int ovftest(int, int *); void main() { int ovrflow_flag; int *ptr=sineTable; while(1) {	 ovrflow_flag=0; ovrflow_flag=ovftest(ovrflow_flag, ptr); 	 if (ovrflow_flag != 0) ovrflow_flag=ovftest(ovrflow_flag, ptr); } 	 } </TEXTAREA></p><p align=center style='text-align:center'> </p><p align=center style='text-align:center'>Table E3-4 List of the overfolw andsaturation demo routine for Experiment 3C.</p><p align=center style='text-align:center'><TEXTAREA ROWS="7" COLS="70" NAME="ovf_sat.asm">; ; ovf_sat.asm ; ; perform add and sub with and without overflow protection ; .def	_ovftest 	 .bss	buff,(0x100)	 .bss	buff1,(0x100)		 ; ; Code start ; _ovftest bclr SATD ; Clear saturation bit if set xcc start,T0!=#0 ; If T0!=0, set saturation bit bset SATD 	 start	 pshboth XAR5 ; Save XAR5 mov #0,AC0	 amov #buff,XAR5 ; Set buffer pointer rpt #0x100-1 ; Clear buff mov AC0,*AR5+ amov #buff1,XAR5 ; Set buffer pointer rpt #0x100-1 ; Clear buff1 mov AC0,*AR5+ 	 mov #0x80-1,BRC0 ; Initialize loop counts for addition amov #buff+0x80,XAR5 ; Initialize buffer pointer 	 rptblocal add_loop_end-1 add #0x140<<#16,AC0 ; Use upper AC0 as a ramp up counter mov hi(AC0),*AR5+ ; Save the counter to buffer add_loop_end mov #0x80-1,BRC0 ; Initialize loop counts for subtraction mov #0,AC0 amov #buff+0x7f,XAR5 ; Initialize buffer pointer	 rptblocal sub_loop_end-1 sub #0x140<<#16,AC0 ; Use upper AC0 as a ramp down counter mov hi(AC0),*AR5- ; Save the counter to buffer sub_loop_end mov #0x100-1,BRC0 ; Initialize loop counts for sinewave amov #buff1,XAR5 ; Initialize buffer pointer	 mov mmap(@AR0),BSA01; Initialize base register mov #40,BK03 ; Set buffer as size 40 mov #20,AR0 ; Start with an offset of 20 samples bset AR0LC ; Active circular buffer rptblocal sine_loop_end-1 mov *ar0+<<#16,AC0 ; Get sine value into high AC0 sfts AC0,#9 ; Scale the sine value mov hi(AC0),*AR5+ ; Save scaled value sine_loop_end mov #0,T0 ; Return 0 if no overflow xcc	 set_ovf_flag,overflow(AC0) 	 mov #1,T0 ; Return 1 if overflow detected set_ovf_flag	 bclr AR0LC ; Reset circilar buffer bit bclr SATD ; Reset saturation bit	 popboth XAR5 ; Restore AR5 	 ret 	 .end </TEXTAREA></p><p style='margin-right:72.0pt;margin-left:72.0pt'>To conduct Experiment 3C,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 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"'>exp3c</span> and includethe linker command file <span style='font-family:"Courier New"'>exp3.cmd</span>,the function <span style='font-family:"Courier New"'>exp3c()</span>, andassembly routine <span style='font-family:"Courier New"'>ovf_sat.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:l3 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:l3 level1 lfo4;tab-stops:list 36.0pt'><![if !supportLists]>3.<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:l3 level1 lfo4;tab-stops:list 36.0pt'><![if !supportLists]>4.<spanstyle='font:7.0pt "Times New Roman"'> </span><![endif]>Usethe CCS graphic function to view the ramp counter and sinewave. See Figure E3-2for reference.</p><p align=center style='margin-right:72.0pt;margin-left:72.0pt;text-align:center'><imgborder=0 width=532 height=448 id="_x0000_i1030" src="exp3/fe3-2a.jpg"></p>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -