dsp_fir_r4.h

来自「dm642函数库」· C头文件 代码 · 共 136 行

H
136
字号
/* ======================================================================== */
/*  TEXAS INSTRUMENTS, INC.                                                 */
/*                                                                          */
/*  DSPLIB  DSP Signal Processing Library                                   */
/*                                                                          */
/*      Release:        Revision 1.04b                                      */
/*      CVS Revision:   1.7     Sun Sep 29 03:32:22 2002 (UTC)              */
/*      Snapshot date:  23-Oct-2003                                         */
/*                                                                          */
/*  This library contains proprietary intellectual property of Texas        */
/*  Instruments, Inc.  The library and its source code are protected by     */
/*  various copyrights, and portions may also be protected by patents or    */
/*  other legal protections.                                                */
/*                                                                          */
/*  This software is licensed for use with Texas Instruments TMS320         */
/*  family DSPs.  This license was provided to you prior to installing      */
/*  the software.  You may review this license by consulting the file       */
/*  TI_license.PDF which accompanies the files in this library.             */
/* ------------------------------------------------------------------------ */
/*          Copyright (C) 2003 Texas Instruments, Incorporated.             */
/*                          All Rights Reserved.                            */
/* ======================================================================== */
/* ======================================================================== */
/*  Assembler compatibility shim for assembling 4.30 and later code on      */
/*  tools prior to 4.30.                                                    */
/* ======================================================================== */
/* ======================================================================== */
/*  End of assembler compatibility shim.                                    */
/* ======================================================================== */
/* ======================================================================== */
/*  TEXAS INSTRUMENTS, INC.                                                 */
/*                                                                          */
/*  NAME                                                                    */
/*      DSP_fir_r4: FIR Filter (radix 4)                                    */
/*                                                                          */
/*                                                                          */
/*  REVISION DATE                                                           */
/*      10-Aug-2001                                                         */
/*                                                                          */
/*  USAGE                                                                   */
/*      This routine is C-callable and can be called as:                    */
/*                                                                          */
/*      void DSP_fir_r4                                                     */
/*      (                                                                   */
/*          const short *restrict x,  // Input array [nr+nh-1 elements] //  */
/*          const short *restrict h,  // Coeff array [nh elements]      //  */
/*          short       *restrict r,  // Output array [nr elements]     //  */
/*          int nh,                   // Number of coefficients.        //  */
/*          int nr                    // Number of output samples.      //  */
/*      )                                                                   */
/*                                                                          */
/*  ARGUMENTS PASSED                                                        */
/*      *x    ->      A4                                                    */
/*      *h    ->      B4                                                    */
/*      *r    ->      A6                                                    */
/*      nh    ->      B6                                                    */
/*      nr    ->      A8                                                    */
/*                                                                          */
/*  DESCRIPTION                                                             */
/*      Computes a real FIR filter (direct-form) using coefficients         */
/*      stored in vector h.  The real data input is stored in vector x.     */
/*      The filter output result is stored in vector r.  Input data and     */
/*      filter taps are 16-bit, with intermediate values kept at 32-bit     */
/*      precision.  Filter taps are expected in Q15 format.                 */
/*                                                                          */
/*      The following is a natural C implementation with no restrictions.   */
/*      This version has restrictions as noted in the ASSUMPTIONS below.    */
/*                                                                          */
/*      void DSP_fir_r4                                                     */
/*      (                                                                   */
/*          const short *restrict x,                                        */
/*          const short *restrict h,                                        */
/*          short       *restrict r,                                        */
/*          int nh,                                                         */
/*          int nr                                                          */
/*      )                                                                   */
/*      {                                                                   */
/*          int i, j, sum;                                                  */
/*                                                                          */
/*          for (j = 0; j < nr; j++)                                        */
/*          {                                                               */
/*              sum = 0;                                                    */
/*              for (i = 0; i < nh; i++)                                    */
/*                  sum += x[i + j] * h[i];                                 */
/*              r[j] = sum >> 15;                                           */
/*          }                                                               */
/*      }                                                                   */
/*                                                                          */
/*  ASSUMPTIONS                                                             */
/*      Number of taps:    'nh' >= 8, multiple of 4                         */
/*      Number of samples: 'nr' >= 4, multiple of 4                         */
/*                                                                          */
/*  NOTES                                                                   */
/*      This function blocks interrupts for its entire duration.  It is     */
/*      interrupt tolerant, but not interruptible.                          */
/*                                                                          */
/*  MEMORY NOTE                                                             */
/*      No memory bank hits under any conditions.                           */
/*      This code is a LITTLE ENDIAN implementation                         */
/*                                                                          */
/*  TECHNIQUES                                                              */
/*      1.  Load double word instruction is used to simultaneously          */
/*          load four values in a single clock cycle.                       */
/*      2.  The inner loop is unrolled four times                           */
/*                                                                          */
/*  CYCLES                                                                  */
/*      (8 + nh) * nr/4 + 9                                                 */
/*                                                                          */
/*      For nh = 12 and nr = 12, cycles = 69                                */
/*                                                                          */
/*  CODESIZE                                                                */
/*      308 bytes.                                                          */
/* ------------------------------------------------------------------------ */
/*            Copyright (c) 2003 Texas Instruments, Incorporated.           */
/*                           All Rights Reserved.                           */
/* ======================================================================== */
#ifndef DSP_FIR_R4_H_
#define DSP_FIR_R4_H_ 1

void DSP_fir_r4
(
    const short *restrict x,  /* Input array [nr+nh-1 elements] */
    const short *restrict h,  /* Coeff array [nh elements]      */
    short       *restrict r,  /* Output array [nr elements]     */
    int nh,                   /* Number of coefficients.        */
    int nr                    /* Number of output samples.      */
);

#endif
/* ======================================================================== */
/*  End of file:  dsp_fir_r4.h                                              */
/* ------------------------------------------------------------------------ */
/*            Copyright (c) 2003 Texas Instruments, Incorporated.           */
/*                           All Rights Reserved.                           */
/* ======================================================================== */

⌨️ 快捷键说明

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