FIR 的静态参数可定义 FIR IP 的参数化方式,并指定非动态项,如输入和输出宽度、小数位数、系数值和内插与抽取速率。以上大部分配置都具有默认值:系数无默认值。
hls_fir.h 头文件可定义用于设置大部分静态参数的默认值的 struct hls::ip_fir::params_t
。
重要: 系数不含定义的默认值。因此,AMD 不建议使用预定义的结构体来直接初始化 FIR。应始终使用用户定义的用于指定系数的新结构体来执行静态参数化。
在此示例中,用户定义了 1 个新的 struct
my_config
,其中包含用作为系数的新值。这些系数指定为驻留在 coeff_vec
阵列内。FIR 的所有其他参数均使用默认值。
struct myconfig : hls::ip_fir::params_t {
static const double coeff_vec[sg_fir_srrc_coeffs_len];
};
static hls::FIR<myconfig> fir1;
fir1.run(fir_in, fir_out);
FIR 结构体参数
下表描述了用于参数化结构体 hls::ip_fir::params_t
的参数,并列出了参数的默认值和可能的值。
参数 | 描述 | C 语言类型 | 默认值 | 有效值 |
---|---|---|---|---|
input_width | 数据输入端口宽度 | 无符号 | 16 | 无限制 |
input_fractional_bits | 输入端口的小数位数 | 无符号 | 0 | 受 input_width 大小所限 |
output_width | 数据输出端口宽度 | 无符号 | 24 | 无限制 |
output_fractional_bits | 输出端口的小数位数 | 无符号 | 0 | 受 output_width 大小所限 |
coeff_width | 系数位宽 | 无符号 | 16 | 无限制 |
coeff_fractional_bits | 系数的小数位数 | 无符号 | 0 | 受 coeff_width 大小所限 |
num_coeffs | 系数的数量 | bool | 21 | Full |
coeff_sets | 系数集的数量 | 无符号 | 1 | 1-1024 |
input_length | 输入数据中的样本数 | 无符号 | 21 | 无限制 |
output_length | 输出数据中的样本数 | 无符号 | 21 | 无限制 |
num_channels | 指定要处理的数据通道数 | 无符号 | 1 | 1-1024 |
total_num_coeff | 系数总数 | 无符号 | 21 | num_coeffs * coeff_sets |
coeff_vec[total_num_coeff] | 系数阵列 | 双精度阵列 | 无 | 不适用 |
filter_type | 用于筛选的实现类型 | 无符号 | single_rate | single_rate、interpolation、decimation、hilbert_filter 或 interpolated |
rate_change | 指定整数或小数速率变化 | 无符号 | integer | integer 或 fixed_fractional |
interp_rate | 内插速率 | 无符号 | 1 | 1-1024 |
decim_rate | 抽取速率 | 无符号 | 1 | 1-1024 |
zero_pack_factor | 内插中使用的 0 系数数量 | 无符号 | 1 | 1-8 |
rate_specification | 指定以频率或周期形式来表示速率 | 无符号 | period | frequency 或 period |
hardware_oversampling_rate | 指定过采样速率 | 无符号 | 1 | 无限制 |
sample_period | 硬件过采样周期 | bool | 1 | 无限制 |
sample_frequency | 硬件过采样频率 | 无符号 | 0.001 | 无限制 |
quantization | 要使用的量化方法 | 无符号 | integer_coefficients | integer_coefficients、quantize_only 或 maximize_dynamic_range |
best_precision | 启用或禁用最佳精度 | 无符号 | false |
false true |
coeff_structure | 要使用的系数结构类型 | 无符号 | non_symmetric | inferred、non_symmetric、symmetric、negative_symmetric、half_band 或 hilbert |
output_rounding_mode | 输出上使用的舍入类型 | 无符号 | full_precision | full_precision、truncate_lsbs、non_symmetric_rounding_down、non_symmetric_rounding_up、symmetric_rounding_to_zero、symmetric_rounding_to_infinity、convergent_rounding_to_even 或 convergent_rounding_to_odd |
filter_arch | 选择脉动 (systolic) 架构或转置 (transposed) 架构 | 无符号 | systolic_multiply_accumulate | systolic_multiply_accumulate 或 transpose_multiply_accumulate |
optimization_goal | 指定最优化的速度或面积目标 | 无符号 | area | area 或 speed |
inter_column_pipe_length | DSP 列之间所需流水线长度 | 无符号 | 4 | 1-16 |
column_config | 指定 DSP 模块列的数量 | 无符号 | 1 | 受所用 DSP 宏单元数量所限 |
config_method | 指定 DSP 模块列的配置方式 | 无符号 | single | single 或 by_channel |
coeff_padding | 指定是否将填充 0 添加到滤波器之前 | bool | false | false true |
重要: 如果指定的参数值并非整数或布尔值,则应使用 HLS FIR 名称空间。例如,该表中显示
rate_change
的可能值为 integer
和 fixed_fractional
。C 语言程序中使用的值应为 rate_change = hls::ip_fir::integer
和 rate_change =
hls::ip_fir::fixed_fractional
。