dsp_minerror.h

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

H
140
字号
/* ======================================================================== */
/*  TEXAS INSTRUMENTS, INC.                                                 */
/*                                                                          */
/*  DSPLIB  DSP Signal Processing Library                                   */
/*                                                                          */
/*      Release:        Revision 1.04b                                      */
/*      CVS Revision:   1.8     Sun Sep 29 03:32:25 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_minerror -- Minimum Energy Error Search                         */
/*                                                                          */
/*  REVISION DATE                                                           */
/*      11-Feb-2002                                                         */
/*                                                                          */
/*  USAGE                                                                   */
/*      This routine is C-callable and can be called as:                    */
/*                                                                          */
/*      int DSP_minerror                                                    */
/*      (                                                                   */
/*          const short *restrict GSP0_TABLE,                               */
/*          const short *restrict errCoefs,                                 */
/*          int         *restrict max_index                                 */
/*      );                                                                  */
/*                                                                          */
/*      GSP0_TABLE[256*9] :  Pointer to GSP0 terms array.                   */
/*                           Must be double-word aligned.                   */
/*      errCoefs[9]       :  Array of error coefficients.                   */
/*      max_index         :  Index to GSP0_TABLE[max_index], the first      */
/*                           element of the 9-element vector that resulted  */
/*                           in the maximum dot product.                    */
/*      return int        :  Maximum dot product result.                    */
/*                                                                          */
/*  DESCRIPTION                                                             */
/*      Performs a dot product on 256 pairs of 9 element vectors and        */
/*      searches for the pair of vectors which produces the maximum dot     */
/*      product result. This is a large part of the VSELP vocoder codebook  */
/*      search.                                                             */
/*                                                                          */
/*  C CODE                                                                  */
/*      This is the C equivalent of the assembly code without restrictions  */
/*      Note that the assembly code is hand optimized and restrictions may  */
/*      apply.                                                              */
/*                                                                          */
/*      int DSP_minerror                                                    */
/*      (                                                                   */
/*          const short *restrict GSP0_TABLE,                               */
/*          const short *restrict errCoefs,                                 */
/*          int         *restrict max_index                                 */
/*      )                                                                   */
/*      {                                                                   */
/*          int val, maxVal = -50;                                          */
/*          int i, j;                                                       */
/*                                                                          */
/*          for (i = 0; i < GSP0_NUM; i++)                                  */
/*          {                                                               */
/*              for (val = 0, j = 0; j < GSP0_TERMS; j++)                   */
/*                  val += GSP0_TABLE[i*GSP0_TERMS+j] * errCoefs[j];        */
/*                                                                          */
/*              if (val > maxVal)                                           */
/*              {                                                           */
/*                  maxVal = val;                                           */
/*                  *max_index = i*GSP0_TERMS;                              */
/*              }                                                           */
/*          }                                                               */
/*                                                                          */
/*          return (maxVal);                                                */
/*      }                                                                   */
/*                                                                          */
/*  TECHNIQUES                                                              */
/*      Load double word instruction is used to simultaneously              */
/*      load four values in a single clock cycle.                           */
/*      The jloop is totally unrolled                                       */
/*      The iloop is unrolled 4 times                                       */
/*      A flag is used to set the exit program location                     */
/*      The MV is used to move the data                                     */
/*      The loop is software pipelined.                                     */
/*                                                                          */
/*  ASSUMPTIONS                                                             */
/*      Array GSP0_TABLE[] must be double-word aligned.                     */
/*                                                                          */
/*  MEMORY NOTE                                                             */
/*      No memory bank hits under any conditions.                           */
/*                                                                          */
/*  NOTES                                                                   */
/*      This code is LITTLE ENDIAN.                                         */
/*      This code is interrupt-tolerant but not interruptible.              */
/*                                                                          */
/*  CYCLES                                                                  */
/*     256/4 * 9 + 17 = 593                                                 */
/*                                                                          */
/*  CODESIZE                                                                */
/*      352 bytes                                                           */
/*                                                                          */
/* ------------------------------------------------------------------------ */
/*            Copyright (c) 2003 Texas Instruments, Incorporated.           */
/*                           All Rights Reserved.                           */
/* ======================================================================== */
#ifndef DSP_MINERROR_H_
#define DSP_MINERROR_H_ 1

int DSP_minerror
(
    const short *restrict GSP0_TABLE,
    const short *restrict errCoefs,
    int         *restrict max_index
);

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

⌨️ 快捷键说明

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