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

📄 intrinsics_iir.c

📁 CHP 5 - Real-Time Digital Signal Processing: Implementations and Applications, Second Edition by Sen
💻 C
字号:
//
//  Project: Experiment 5.7.4: implementation of direct form-II IIR filter in intrinsics - Chapter 5
//  File name: intrinsics_IIR.c   
//
//  Description: This is the intrinsics implementation of a fixed-point IIR filter in direct form II
//
//  For the book "Real Time Digital Signal Processing: 
//                Implementation and Application, 2nd Ed"
//                By Sen M. Kuo, Bob H. Lee, and Wenshun Tian
//                Publisher: John Wiley and Sons, Ltd
//
//  intrinsics_IIR.c - IIR direct form II biquads implementation
//  prototype: void intrinsics_IIR(short *, short, short *, float *, short, float *);
//
//  Entry: arg0: pointer to the input sample buffer
//         arg1: size of the input sample buffer
//         arg2: pointer to the output sample buffer
//         arg3: pointer to the coefficients array
//         arg4: number of second-order IIR sections
//         arg5: pointer to the filter delay-line buffer
//
//  Return: None
//
//  Tools used: CCS v.2.12.07
//              TMS320VC5510 DSK Rev-C
//

#include <intrindefs.h>
#include "intrinsics_IIR.h"

void intrinsics_IIR(short *x, short Nx, short *y, 
                    short *coef, short Ns, short *w)
{      
  short i,j,n,m,k,l;
  short temp16;
  long  w_0;
        
  m=Ns*5;                            // Setup for circular buffer coef[]  
  k=Ns*2-1;                          // Setup for circular buffer w[]  

  for (j=0,l=0,n=0; n<Nx; n++)       // IIR filter begin 
  {
    w_0 = (long)x[n]<<12;            // Scale input to prevent overflow  
    for (i=0; i<Ns; i++)
    {
      w_0 = _smas(w_0,*(w+l),*(coef+j)); j++; l=(l+Ns)&k;
      w_0 = _smas(w_0,*(w+l),*(coef+j)); j++; 

      temp16 = *(w+l);
      *(w+l) = (short)(w_0>>15);    // Save in Q15  

      w_0 = _lsmpy(   temp16,*(coef+j)); j++; 
      w_0 = _smac(w_0,*(w+l),*(coef+j)); j++; l=(l+Ns)&k; 
      w_0 = _smac(w_0,*(w+l),*(coef+j)); j=(j+1)%m; l=(l+1)&k;
    }
    y[n] = (short)(w_0>>12);        // Q15 format output 
  }
}

⌨️ 快捷键说明

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