📄 port_c_c_source_code_from_vdsp_to_uclinux.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html><head> <title></title> <link rel="stylesheet" media="screen" type="text/css" href="./style.css" /> <link rel="stylesheet" media="screen" type="text/css" href="./design.css" /> <link rel="stylesheet" media="print" type="text/css" href="./print.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head><body><a href=start.html>start</a></br><div class="toc"><div class="tocheader toctoggle" id="toc__header">Table of Contents</div><div id="toc__inside"><ul class="toc"><li class="level1"><div class="li"><span class="li"><a href="#port_c_c_source_code_from_vdsp_to_uclinux" class="toc">Port C/C++ source code from VDSP to uClinux</a></span></div><ul class="toc"><li class="level2"><div class="li"><span class="li"><a href="#pragmas" class="toc">Pragmas</a></span></div></li><li class="level2"><div class="li"><span class="li"><a href="#built-in_functions" class="toc">Built-in functions</a></span></div><ul class="toc"><li class="level3"><div class="li"><span class="li"><a href="#fractional_value_built-in_functions_in_c" class="toc">Fractional Value Built-in Functions in C</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#etsi_support" class="toc">ETSI Support</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#viterbi_history_and_decoding_functions" class="toc">Viterbi History and Decoding Functions</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#circular_buffer_built-in_functions" class="toc">Circular Buffer Built-In Functions</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#endian-swapping_intrinsics" class="toc">Endian-Swapping Intrinsics</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#system_built-in_functions" class="toc">System Built-In Functions</a></span></div></li><li class="level3"><div class="li"><span class="li"><a href="#compiler_performance_built-in_functions" class="toc">Compiler Performance Built-in Functions</a></span></div></li></ul></li></ul></li></ul></div></div><h1><a name="port_c_c_source_code_from_vdsp_to_uclinux" id="port_c_c_source_code_from_vdsp_to_uclinux">Port C/C++ source code from VDSP to uClinux</a></h1><div class="level1"><p> In many cases, to port C/C++ source code to uClinux involves simply recompiling the code using Blackfin uClinux GCC. But you will need to take care of the differences between VDSP C/C++ compiler and GCC - since every compiler defines its own set of extensions. How to translate between these dialects is the focus of this page. Whenever possible, please refer to the manuals of both compilers.</p></div><!-- SECTION [1-454] --><h2><a name="pragmas" id="pragmas">Pragmas</a></h2><div class="level2"><p> Pragmas are implementation-specific directives that modify the compiler鈥檚 behavior. </p><ul><li class="level1"><div class="li"> #pragma linkage_name mylinkname </div></li></ul><p> Example: </p><pre class="code">// For VDSP #pragma linkage_name _foo_1 int foo (int);// For GCC int foo (int) asm ("_foo_1"); </pre><ul><li class="level1"><div class="li"> More to come –</div></li></ul></div><!-- SECTION [455-754] --><h2><a name="built-in_functions" id="built-in_functions">Built-in functions</a></h2><div class="level2"><p> Both VDSP and GCC supports built-in or intrinsic functions to enable efficient use of Blackfin HW resources. For example, complex fractional computing. Here are the current intrinsic functions implemented in GCC:</p></div><!-- SECTION [755-1000] --><h3><a name="fractional_value_built-in_functions_in_c" id="fractional_value_built-in_functions_in_c">Fractional Value Built-in Functions in C</a></h3><div class="level3"></div><h4><a name="fract16_built-in_functions" id="fract16_built-in_functions">fract16 Built-in Functions</a></h4><div class="level4"><p> All the built-in functions described here are saturating unless otherwise stated. These builtins operate primarily on the fract16 type, although one of the multiplies returns a fract32. All gcc calls are prefixed by <code>__builtin_bfin_</code> </p><table class="inline"> <tr> <th class="leftalign"> VDSP++ </th><th class="centeralign"> gcc </th><th class="centeralign"> arguments </th><th class="centeralign"> returns </th><th class="leftalign"> Description </th> </tr> <tr> <td class="leftalign"> <code>add_fr1x16</code> </td><td class="leftalign"> <code>add_fr1x16</code> </td><td class="leftalign"> <code>(fract16 f1, fract16 f2)</code> </td><td class="centeralign"> <code>fract16</code> </td><td class="leftalign"> Performs 16-bit addition of the two input parameters (f1+f2) </td> </tr> <tr> <td class="leftalign"> <code>sub_fr1x16</code> </td><td class="leftalign"> <code>sub_fr1x16</code> </td><td class="leftalign"> <code>(fract16 f1, fract16 f2)</code> </td><td class="leftalign"> <code>fract16</code> </td><td class="leftalign"> Performs 16-bit subtraction of the two input parameters (f1-f2) </td> </tr> <tr> <td class="leftalign"> <code>mult_fr1x16</code> </td><td class="leftalign"> <code>mult_fr1x16</code> </td><td class="leftalign"> <code>(fract16 f1, fract16 f2)</code> </td><td class="leftalign"> <code>fract16</code> </td><td class="leftalign"> Performs 16-bit multiplication of the input parameters (f1*f2). The result is truncated to 16 bits. </td> </tr> <tr> <td class="leftalign"> <code>multr_fr1x16</code> </td><td class="leftalign"> <code>multr_fr1x16</code> </td><td class="leftalign"> <code>(fract16 f1, fract16 f2)</code> </td><td class="leftalign"> <code>fract16</code> </td><td class="leftalign"> Performs a 16-bit fractional multiplication (f1*f2) of the two input parameters. The result is rounded to 16 bits. Whether the rounding is biased or unbiased depends on what the RND_MOD bit in the ASTAT register is set to. </td> </tr> <tr> <td class="leftalign"> <code>mult_fr1x32</code> </td><td class="leftalign"> <code>mult_fr1x32</code> </td><td class="leftalign"> <code>(fract16 f1, fract16 f2)</code> </td><td class="leftalign"> <code>fract32</code> </td><td class="leftalign"> Performs a fractional multiplication on two 16-bit fractions, returning the 32-bit result. There will be loss of precision. </td> </tr> <tr> <td class="leftalign"> <code>abs_fr1x16</code> </td><td class="leftalign"> <code>abs_fr1x16</code> </td><td> <code>(fract16 f1)</code> </td><td class="leftalign"> <code>fract16</code> </td><td class="leftalign"> Returns the 16-bit value that is the absolute value of the input parameter. Where the input is 0×8000, saturation occurs and 0x7fff is returned. </td> </tr> <tr> <td class="leftalign"> <code>min_fr1x16</code> </td><td class="rightalign"> </td><td class="leftalign"> <code>(fract16 f1, fract16 f2)</code> </td><td class="leftalign"> <code>fract16</code> </td><td class="leftalign"> Returns the minimum of the two input parameters. </td> </tr> <tr> <td> <code>max_fr1x16</code> </td><td class="rightalign"> </td><td class="leftalign"> <code>(fract16 f1, fract16 f2)</code> </td><td class="leftalign"> <code>fract16</code> </td><td class="leftalign"> Returns the maximum of the two input parameters. </td> </tr> <tr> <td class="leftalign"> <code>negate_fr1x16</code> </td><td class="leftalign"> <code>negate_fr1x16</code> </td><td class="leftalign"> <code>(fract16 f1)</code> </td><td class="leftalign"> <code>fract16</code> </td><td class="leftalign"> Returns the 16-bit result of the negation of the input parameter (-f1). If the input is 0×8000, saturation occurs and 0x7fff is returned. </td> </tr> <tr> <td class="leftalign"> <code>shl_fr1x16</code> </td><td class="leftalign"> <code>shl_fr1x16</code> </td><td class="leftalign"> <code>(fract16 src, short shft)</code> </td><td class="leftalign"> <code>fract16</code> </td><td class="leftalign"> Arithmetically shifts the src variable left by shft places. The empty bits are zero-filled. If shft is negative, the shift is to the right by abs(shft) places with sign extension. </td> </tr> <tr> <td class="leftalign"> <code>shl_fr1x16_clip</code> </td><td class="rightalign"> </td><td class="leftalign"> <code>(fract16 src, short shft)</code> </td><td class="leftalign"> <code>fract16</code> </td><td class="leftalign"> Arithmetically shifts the src variable left by shft (clipped to 5 bits) places.The empty bits are zero filled. If shft is negative, the shift is to the right by abs(shft) places with sign extension. </td> </tr> <tr> <td class="leftalign"> <code>shr_fr1x16</code> </td><td class="rightalign"> </td><td class="leftalign"> <code>(fract16 src, short shft)</code> </td><td class="leftalign"> <code>fract16</code> </td><td class="leftalign"> Arithmetically shifts the src variable right by shft places with sign extension. If shft is negative, the shift is to the left by abs(shft) places, and the empty bits are zero-filled. </td> </tr> <tr> <td> <code>shr_fr1x16_clip</code> </td><td class="rightalign"> </td><td class="leftalign"> <code>(fract16 src, short shft)</code> </td><td class="leftalign"> <code>fract16</code> </td><td class="leftalign"> Arithmetically shifts the src variable right by shft (clipped to 5 bits) places with sign extension. If shft is negative, the shift is to the left by abs(shft) places, and the empty bits are zero-filled. </td> </tr> <tr> <td class="leftalign"> <code>shrl_fr1x16</code> </td><td class="rightalign"> </td><td class="leftalign"> <code>(fract16 src, short shft)</code> </td><td class="leftalign"> <code>fract16</code> </td><td class="leftalign"> Logically shifts a fract16 right by shft places. There is no sign extension and no saturation 鈥
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -