首页 DSP编程中使用的预编译指令

DSP编程中使用的预编译指令

举报
开通vip

DSP编程中使用的预编译指令DSP编程中使用的预编译指令 #pragma (2008-12-10 10:55:09) 转载▼ 标签: 杂谈 【原创】 转载请注明出处 ****  TypeWritter: Li Hui   *** Start Time: Nov.19.2008   *** Version 1.3 **    ** use word to instead 2 * 16bit short data's access ** void vecsum4(short *restrict sum, restri...

DSP编程中使用的预编译指令
DSP编程中使用的预编译指令 #pragma (2008-12-10 10:55:09) 转载▼ 标签: 杂谈 【原创】 转载请注明出处 ****  TypeWritter: Li Hui   *** Start Time: Nov.19.2008   *** Version 1.3 **    ** use word to instead 2 * 16bit short data's access ** void vecsum4(short *restrict sum, restrict short *in1, restrict short *in2, unsigned int N) {  int i;  #pragma MUST_ITERATE(10);  for(i=0;i<(N/2);i++)   _amem4(&sum[i]) = add2(_amem4_const(&in1[i]),_amem4_const(&in2[i])); } ** near variable's access ** LDW *dp(_address),a1   ** far variables' access ** MVKL _address,a1 MVKH _address,a1 LDW *a1,a0   ** far function call ** MVKL _func,a1 MVKH _func,a1 B a1   ** default is near type ** ** if you use -mr1 option, all the func are 'far'      if you don't use -mr1, default is 'near'      if you use -mr0, then all the array or matrix are 'far', program is 'near'      if you use -mr1, then all the array or matrix are 'near', program is 'far'      if you use -mr2, then all the array, matrix, program are 'far'      if you use -mr3, then all data and program are 'far' **   ** not-related ** void foo(int * restrict a, int * restrict b) void foo(int c[restrict], int d[restrict])   ** difference of const-pointer and point to const** int * const p = &x;  ** a const pointer who point to a variable named x ** const int * p = &x;  ** a pointer who point to a const named x, the pointer can point another variable **   ** volatile - to guarantee a variable can not be optimized by optimizer ** unsigned int *ctrl; while(*ctrl !=0xFF)  ... ** optimizer will treat ctrl a const  ** ** so we should specify the ctrl's type is 'volatile' ** volatile unsigned int * ctrl; ** That's ok **   ** Embedded the assembly language into the .C file ** asm(" Assembly Language... ");   ** Useful Pragma Directive ** ** (1) CODE_SECTION ** ** Allocate space for symbol in the section named "section name" ** #pragma CODE_SECTION(symbol,"section name");  // in C language ** (2) DATA_ALIGN ** ** align symbol to the column edge specfied by the constant ** #pragma DATA_ALIGN(symbol,constant); // constant must be power of 2 eg1:  #pragma DATA_ALIGN(inputArray,8);// when you use DSPLIB FFT functions   ** (3) DATA_MEM_BANK ** ** align the symbol and variables to the page edge specified by the constant ** ** avoid the data's overlapped storage ** #pragma DATA_MEM_BANK(symbol,constant); ** C64 : constant must be 0-15 and must be even ** ** (4) DATA_SECTION ** ** Allocate space for symbol in the section named "section name" ** ** 4-1 C Language ** #pragma DATA_SECTION(symbol,"section name"); ** 4-2 C++ Language ** #pragma DATA_SECTION("section name"); ** 4-3 Assembly Language ** .global _bufferA .bss  _bufferA,512,4 .global _bufferB _bufferB .usect "section name",512,4 ** (5) FUNC_CANNOT_INLINE ** ** this function can not be inline, even the function is defined 'inline' ** #pragma FUNC_CANNOT_INLINE(func);   ** (6) FUNC_EXT_CALLED ** ** if you add -pm options in the compile period, the compiler will erase the function which haven't been called by main, but acturally, the function may be called by .asm file. ** #pragma FUNC_EXT_CALLED(func); ** restriction: func can not be _c_int00 **   ** (7) FUNC_INTERRUPT_THRESHOLD ** #pragma FUNC_INTERRUPT_THRESHOLD(func,threshold); eg1: #pragma FUNC_INTERRUPT_THRESHOLD(func1,2000); ** the period between the func1's interrupts must lager than 2000 clock cycle ** eg2: #pragma FUNC_INTERRUPT_THRESHOLD(func2,1); ** the func2 can always be interrupted ** eg3: #pragma FUNC_INTERRUPT_THRESHOLD(func3,-1); ** the func2 can not be interrupted ** ** (8) FUNC_IS_PURE ** ** This function has no side-effect, if you do not need the value returned by func, you can delete its' call     you can delete the copy of the func** #pragma FUNC_IS_PURE(func); ** (9) FUNC_IS_SYSTEM ** ** this function has the ANSI standard operation, the directive must be used for ANSI standard function  ** ** for example: memcpy, strcmp and so on ** #pragma FUNC_IS_SYSTEM(func); ** (10) FUNC_NEVER_RETURNS ** ** this function never returns, so compiler can not terminate this function or free stack and so on ** #pragma FUNC_NEVER_RETURNS(func); ** (11) FUNC_NO_GLOBAL_ASG ** ** this function will not assign global variables and not contains .asm sentences ** #pragma FUNC_NO_GLOBAL_ASG(func); ** (12) FUNC_NO_IND_ASG ** ** this function will not allocate space via pointer and not contains .asm sentences ** #pragma FUNC_NO_IND_ASG(func); ** (13) INTERRUPT ** ** you can use the function to handle the DSP's interrupt  ** #pragma INTERRUPT(func); ** (14) MUST_ITERATE ** ** Specify the cycle's minimum times, maximun times and the times must be multiple of 'multiple' ** #pragma MUST_ITERATE(min,max,multiple); ** (15) NMI_INTERRUPT ** ** you can use the function to handle the Non Maskable Interrupt(NMI) ** #pragma NMI_INTERRUPT(func); ** (16) PROB_ITERATE ** ** Specify the cycle's minimum times, maximun times ** #pragma PROB_ITERATE(min,max); ** (17) STRUCT_ALIGN ** ** Like to DATA_ALIGN, using for defination of struct and class ** #pragma STRUCT_ALIGN(type,constact expression); eg: typedef strct st_tag {  int a;  short b; }st_typedef; #pragma STRUCT_ALIGN(st_tag,128);   ** (18) UNROLL ** ** Specify which number of cycle times can not be unfolded ** #pragma UNROLL(n);
本文档为【DSP编程中使用的预编译指令】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_474834
暂无简介~
格式:doc
大小:36KB
软件:Word
页数:10
分类:互联网
上传时间:2012-02-10
浏览量:19