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

📄 fir.cpp

📁 浮点fir设计工具
💻 CPP
字号:
//       AccelDSP 9.1.00 build 868 Production, compiled Feb 16 2007 
// 
//    THIS IS UNPUBLISHED, LICENSED SOFTWARE THAT IS THE CONFIDENTIAL 
//        AND PROPRIETARY PROPERTY OF XILINX OR ITS LICENSORS 
// 
//      Copyright(c) Xilinx, Inc., 2000-2007, All Rights Reserved. 
//   Reproduction or reuse, in any form, without the explicit written 
//          consent of Xilinx, Inc., is strictly prohibited. 
// 
//  User: WangQian 
//  Machine: A2D3DF917F70473 (i1586, Windows XP Service Pack 2, 5.01.2600) 
//  Date: Mon May 12 10:45:42 2008 
// 


#include "AccelCommon.h"
#include <math.h>
#include "fir.h"

/*       AccelDSP 9.1.00 build 868 Production, compiled Feb 16 2007 */
/* */
/*    THIS IS UNPUBLISHED, LICENSED SOFTWARE THAT IS THE CONFIDENTIAL */
/*        AND PROPRIETARY PROPERTY OF XILINX OR ITS LICENSORS */
/* */
/*      Copyright(c) Xilinx, Inc., 2000-2007, All Rights Reserved. */
/*   Reproduction or reuse, in any form, without the explicit written */
/*          consent of Xilinx, Inc., is strictly prohibited. */
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
/*% Description : Function definition for general FIR filter design            %*/
/*%                                                                            %*/
/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/


TAccelQuantizer ac_fixed_wrap_floor_12_8 = 0;
TAccelQuantizer ac_fixed_wrap_floor_24_20 = 0;
TAccelQuantizer ac_fixed_wrap_floor_26_20 = 0;
TAccelQuantizer ac_fixed_wrap_floor_29_20 = 0;
TAccelQuantizer ac_ufixed_wrap_floor_12_12 = 0;
TAccelQuantizer ac_ufixed_wrap_floor_4_0 = 0;
TAccelQuantizer ac_ufixed_wrap_floor_5_0 = 0;


void fir( double indatabuf, double & outdatabuf )
{
    double ac_input_mtimes_1[16];
    double coeff[16];
    double coeff_1[16];
    double colon_expr_1[16];
    double colon_expr_2[15];
    static double tap_delay[16];
    double tap_delay_1[15];
    static double tap_delay_is_empty = 1;

    static int ac_static_var_for_quantizer_definition = 1;

    if ( ac_static_var_for_quantizer_definition ) 
    {
        ac_static_var_for_quantizer_definition = 0;
        ac_fixed_wrap_floor_12_8 = accel_quantizer( "fixed", "wrap", "floor", 12, 8 );
        ac_fixed_wrap_floor_24_20 = accel_quantizer( "fixed", "wrap", "floor", 24, 20 );
        ac_fixed_wrap_floor_26_20 = accel_quantizer( "fixed", "wrap", "floor", 26, 20 );
        ac_fixed_wrap_floor_29_20 = accel_quantizer( "fixed", "wrap", "floor", 29, 20 );
        ac_ufixed_wrap_floor_12_12 = accel_quantizer( "ufixed", "wrap", "floor", 12, 12 );
        ac_ufixed_wrap_floor_4_0 = accel_quantizer( "ufixed", "wrap", "floor", 4, 0 );
        ac_ufixed_wrap_floor_5_0 = accel_quantizer( "ufixed", "wrap", "floor", 5, 0 );
    }

    /* The following lines were automatically inserted to insure correct input quantization */
    indatabuf = accel_quantize( ac_fixed_wrap_floor_12_8, indatabuf,_AT_);
    /* end of input quantization */

    /* Load the filter coefficients*/
    accel_load( "C:\\AccelDSP\\AccelWork\\FIR\\coefficients.txt", 1, 16, coeff);
    accel_cp_arr_to_arr( coeff, 16, coeff, ac_ufixed_wrap_floor_12_12,_AT_);

    /* Clear tap delay line at beginning*/
    if ( tap_delay_is_empty ) {
        accel_zeros( 1, 16, tap_delay);
        accel_cp_arr_to_arr( tap_delay, 16, tap_delay, ac_fixed_wrap_floor_12_8,_AT_);
        tap_delay_is_empty = 0.0;
    }


    /* Perform sum of products*/
    accel_colon_expr_to_arr( 15, -1, 0, colon_expr_1);
    accel_cp_arr_elts_to_arr( coeff, colon_expr_1, 16, coeff_1, 0,_AT_);
    accel_cp_arr_to_arr( ac_input_mtimes_1, 16, coeff_1, ac_ufixed_wrap_floor_12_12,_AT_);
    mtimes_001( tap_delay, ac_input_mtimes_1, outdatabuf);
    outdatabuf = accel_quantize( ac_fixed_wrap_floor_26_20, outdatabuf ,_AT_);
    /* Shift tap delay line*/
    accel_colon_expr_to_arr( 1, 1, 15, colon_expr_2);
    accel_cp_arr_elts_to_arr( tap_delay, colon_expr_2, 15, tap_delay_1, 0,_AT_);
    accel_cp_arr_to_arr_range( tap_delay_1, tap_delay, 0, 14, 0,_AT_);
    tap_delay[15] = indatabuf;

}

⌨️ 快捷键说明

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