FIR Compiler C-model如何设置参数

作者:Nathan Xu,AMD工程师;来源:AMD开发者社区

不少用户, 在使用FIR Compiler IP提供的C-model, 不确定如何配置C-model的参数, 和Vivado IP catalog里的FIR Compiler IP参数匹配。这篇blog介绍如何配置C-model参数和IP匹配。

首先, C-model本身提供了例子“run_fir_compiler_v7_2_mex.m”, 这个例子提供了几个example, 来演示如何设置参数。

示例1: fir1 = fir_compiler_v7_2_bitacc()

这个例子使用缺省参数。

示例2: fir2 = fir_compiler_v7_2_bitacc('reloadable',1)

rld_coeff = [-238 -1022 -1506 878 7844 16526 20564 16526 7844 878 -1506 -1022 -238 -238 -1022 -1506 878 7844 16526 20564];

reload_send(fir2,struct('fsel',0,'coeff',rld_coeff));

config_send(fir2,struct('fsel',[0]));

这个例子演示如何reload新系数。

示例3: fir3 = fir_compiler_v7_2_bitacc('filter_type',1,'interp_rate',2,'num_channels',2)

这个例子演示设置filter类型, interpolating rate, number of channels。

示例4: coeff = cfirpm(fl,f,@lowpass);

fir4=fir_compiler_v7_2_bitacc('coeff',coeff,'num_coeffs',fl+1,'coeff_width',16,'coeff_fract_width',15,'data_width',16,'data_fract_width',14)

这个例子演示设置系数, 系数个数, 系数位宽, 小数点位置, 数据位宽, 数据小数点位置。

上面这些例子示例了如何设置C-model参数, 但是, 这些参数的名字是从哪里来的. 这是一个问题, 我们可以在C-model里的“fir_compiler_v7_2_bitacc_cmodel.h” 找到这些参数, 见下:

typedef struct

{

const char* name; //@- Instance name to use in error/warning reporting

unsigned int filter_type; //@- Select from: XIP_FIR_SINGLE_RATE, XIP_FIR_INTERPOLATION, XIP_FIR_DECIMATION, XIP_FIR_HILBERT, XIP_FIR_INTERPOLATED

unsigned int rate_change; //@- Select from: XIP_FIR_INTEGER_RATE, XIP_FIR_FRACTIONAL_RATE

unsigned int interp_rate; //@- Specifies the interpolation (or up-sampling) factor

unsigned int decim_rate; //@- Specifies the decimation (or down-sampling) factor

unsigned int zero_pack_factor; //@- Specifies the zero packing factor for Interpolated filters

const double* coeff; //@- Pointer to coefficient array

unsigned int coeff_padding; //@- Specifies the amount zero padding added to the front of the filter

unsigned int num_coeffs; //@- Specifies the number of coefficients in one filter

unsigned int coeff_sets; //@- Specifies the number of coefficient sets in the coeff array

unsigned int reloadable; //@- Specifies if the coefficients are reloadable; 0 = No, 1 = Yes

unsigned int is_halfband; //@- Specifies if halfband coefficients have been used; 0 = No, 1 =Yes

unsigned int quantization; //@- Specifies how the coeff array should quantized, select from: XIP_FIR_INTEGER_COEFF, XIP_FIR_QUANTIZED_ONLY, XIP_FIR_MAXIMIZE_DYNAMIC_RANGE

unsigned int coeff_width; //@- Used to quantize the supplied coefficients.

unsigned int coeff_fract_width; //@- Used to quantize the supplied coefficients.

unsigned int chan_seq; //@- Specifies the channel sequence type, select from: XIP_FIR_BASIC_CHAN_SEQ, XIP_FIR_ADVANCED_CHAN_SEQ

unsigned int num_channels; //@- Specifies the number of data channels supported

xip_fir_v7_2_pattern init_pattern; //@- Specifies the initial channel pattern used by the core

unsigned int num_paths; //@- Specifies the number of data paths supported

unsigned int data_width; //@- Used to quantize the input data

unsigned int data_fract_width; //@- Used to quantize the input data

unsigned int output_rounding_mode; //@- Select from: XIP_FIR_FULL_PRECISION, XIP_FIR_TRUNCATE_LSBS, XIP_FIR_SYMMETRIC_ZERO, XIP_FIR_SYMMETRIC_INF, XIP_FIR_CONVERGENT_EVEN, XIP_FIR_CONVERGENT_ODD, XIP_FIR_NON_SYMMETRIC_DOWN, XIP_FIR_NON_SYMMETRIC_UP

unsigned int output_width; //@- Ignored when XIP_FIR_FULL_PRECISION

unsigned int output_fract_width; //@- READ ONLY: Provides the number of fractional bits present in output word

unsigned int config_method; //@- Specifies the form of the configuration packets, select from: XIP_FIR_CONFIG_SINGLE, XIP_FIR_CONFIG_BY_CHANNEL

} xip_fir_v7_2_config;

C-Model需要设置的参数名字定义在xip_fir_v7_2_config。

这里还有一个问题, 比如filter type这个参数, 在 xip_fir_v7_2_config可以看到, 这个参数能够设置的值为XIP_FIR_SINGLE_RATE, XIP_FIR_INTERPOLATION, XIP_FIR_DECIMATION, XIP_FIR_HILBERT, XIP_FIR_INTERPOLATED, 但是, 这些值是如何对应为0,1,2, 3等这些数值的. 这些, 也都可以在“fir_compiler_v7_2_bitacc_cmodel.h”这个头文件找到 . 见下:

/**

* Filter Types

*/

#define XIP_FIR_SINGLE_RATE 0

#define XIP_FIR_INTERPOLATION 1

#define XIP_FIR_DECIMATION 2

#define XIP_FIR_HILBERT 3

#define XIP_FIR_INTERPOLATED 4

希望这篇文章对设置C-model参数有些帮助。

最新文章

最新文章