⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _algorithm.asm

📁 在ADSP-2126x上编写的优化过的FIR滤波器程序(用c和汇编编写)。
💻 ASM
字号:
/////////////////////////////////////////////////////////////
//                                                         //
//     Process the audio stream                            //
//                                                         //
/////////////////////////////////////////////////////////////

#include <def21262.h>
.global _Stereo_FIR_Filter_SIMD;
.extern inbuf;
.extern outbuf;
.extern delaybuf;
.extern coefficients;



.section /pm seg_pmco;

_Stereo_FIR_Filter_SIMD:

/**************************************************************************
 The algorithm:

   An FIR filter is defined as

            m-1
     y[n] = sum a[k]*x[n-k]
            k=0

   where

     x[n-k] is the previous history of inputs
     y[k]   is the filter output at time n
     a[k]   is a vector of filter coefficients

   As implied by the equation, there are two substantial buffer associated
   with this algorithm.  'delaybuf' is a time history of input samples x[n]
   and 'coefficients' is a time series that defines the filter.  The output
   y[n] is a finite-length convolution of the input with the filter
   coefficients.

   In this implementation, the two SIMD processing elements are used to
   compute the filter for the left and right channels simultaneously.  The
   two buffers of each twice their normal length because the left and right
   values of both buffer are interleaved.  Note also that the filter looks
   "backward" in time, so the filter is stored in the .dat file and in the
   buffer in reverse order (k=M-1 to k=0).

   The given filter coefficients are just one follow by an array of zeros.
   Since this is an ideal impulse in the digital domain, the filter will
   calculate an output series identical to the input.  The coefficients
   can be easily changed, and the filter length is controlled by the
   constant TAPS in initAlgorithm.asm.

 **************************************************************************/

  /*  Subroutine that implements the pseudocode above */

    bit set mode1 CBUFEN | PEYEN ;          // Enable SIMD mode
    nop;
    nop;

    f0=dm(i1,0);

    r12=r12 xor r12, dm(i0,m0)=f0;  /* set r12=0 and read left and right   */
                                    /*   inputs to the first two locations */

    r8=r8 xor r8, f0=dm(i0,m0), f4=pm(i8,m8);  /* set r8=0 and read the    */
                                    /* first the first delayed value and   */
                                    /* the first coefficient (tap).        */

    r1=(@coefficients >> 1) - 1;   /* Multiply-accumulate TAPS-1 times for */
                                          /*   each channel */
    lcntr=r1, do macs until lce;
      macs: f12=f0*f4, f8=f8+f12, f0=dm(i0,m0), f4=pm(i8,m8);  /* mult-acc */

    f12=f0*f4, f8=f8+f12;  /* multiply last two and do 2nd to last add */

    f0=f8+f12;     /* do the last addition... */
    dm(i2,0)=f0;   /* ...and write to outbuf. */

    bit clr mode1 CBUFEN | PEYEN;                 // disable SIMD mode
    rts;

_Stereo_FIR_Filter_SIMD.end:



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -