Hello all,

Is there an equivalent function or a solution to utilize the filter coefficients formed from MATLAB's filter() function and use in VisualDSP++?

Thanks!

Hello all,

Is there an equivalent function or a solution to utilize the filter coefficients formed from MATLAB's filter() function and use in VisualDSP++?

Thanks!

Hi,

On Blackfin all filter functions supported in the DSP runtime library are of type fract16 (1.15 fixed point). On Sharc and TigerSharc the default type is a 32-bit float.

If you wish to compute a

**FIR filter**, the equivalent functions would be fir_fr16 for Blackfin, fir for TigerSharc and fir_vec for a 210xx Sharc as well as fir (from filter.h) for a 21xxx Sharc. All these functions operate on real vector data. On Sharc there is also support for a real scalar FIR function: fir (from filters.h).Two specialized FIR filters are available on all platforms: fir_decima_fr16 | fir_decima and fir_interp_fr16 | fir_interp. The decimation filter will compute a FIR before down-sampling while the interpolation filter will up-sample before computing the filter response.

For Blackfin you will also find a complex FIR filter cfir_fr16.

For a Direct Form 2

**IIR filter**, Sharc offers the vector based functions biquad_vec and iir_vec for a 210xx and biquad (from filter.h) as well as iir (from filter.h) for a 21xxx. A scalar version of the function biquad is also available (from filters.h). The biquad function uses 5 coefficients per stage, while the iir function only requires 4 coefficients (with B0 assumed to be 1).The DSP runtime library for TigerSharc includes the iiir function (again a Direct Form 2 implementation with biquad stages).

For Blackfin, you have the choice between a Direct Form 2 IIR function with biquad stages - iir_fr16 - or a Direct Form 1 implementation iirdf1_fr16 that uses coefficients in transfer function representation. The later function will allow you to use filter coefficients that exceed the range of a fract16 [-1..1).

All of the above functions are described in the online help or the respective C/C++ Compiler and Library manuals. Besides a description of the functions and how to call them, you will also find information regarding the correct ordering of the filter coefficients. This is particularly important for the IIR functions where not only the order can differ from that used by Matlab but also the expected sign of the A-coefficients can vary.

In case of the FIR functions, I would recommend starting off with a small set (around 8) of filter coefficients (each with a unique value) and an impulse signal (first value non-zero with the remaining values set to 0). In case of the IIR functions, I would zero all coefficients that are part of the feedback loop (A coefficients for a Direct Form2 filter), with the remaining coefficients assigned unique values. The signal should again be an impulse. Once you are happy that this is working as expected. you can then expand your example until you are confident that the conversion of the filter coefficients works and both the filter function in Matlab and the corresponding function in VisualDSP++ produce identical filter responses.

Andreas

Hi,

On Blackfin all filter functions supported in the DSP runtime library are of type fract16 (1.15 fixed point). On Sharc and TigerSharc the default type is a 32-bit float.

If you wish to compute a

FIR filter, the equivalent functions would be fir_fr16 for Blackfin, fir for TigerSharc and fir_vec for a 210xx Sharc as well as fir (from filter.h) for a 21xxx Sharc. All these functions operate on real vector data. On Sharc there is also support for a real scalar FIR function: fir (from filters.h).Two specialized FIR filters are available on all platforms: fir_decima_fr16 | fir_decima and fir_interp_fr16 | fir_interp. The decimation filter will compute a FIR before down-sampling while the interpolation filter will up-sample before computing the filter response.

For Blackfin you will also find a complex FIR filter cfir_fr16.

For a Direct Form 2

IIR filter, Sharc offers the vector based functions biquad_vec and iir_vec for a 210xx and biquad (from filter.h) as well as iir (from filter.h) for a 21xxx. A scalar version of the function biquad is also available (from filters.h). The biquad function uses 5 coefficients per stage, while the iir function only requires 4 coefficients (with B0 assumed to be 1).The DSP runtime library for TigerSharc includes the iiir function (again a Direct Form 2 implementation with biquad stages).

For Blackfin, you have the choice between a Direct Form 2 IIR function with biquad stages - iir_fr16 - or a Direct Form 1 implementation iirdf1_fr16 that uses coefficients in transfer function representation. The later function will allow you to use filter coefficients that exceed the range of a fract16 [-1..1).

All of the above functions are described in the online help or the respective C/C++ Compiler and Library manuals. Besides a description of the functions and how to call them, you will also find information regarding the correct ordering of the filter coefficients. This is particularly important for the IIR functions where not only the order can differ from that used by Matlab but also the expected sign of the A-coefficients can vary.

In case of the FIR functions, I would recommend starting off with a small set (around 8) of filter coefficients (each with a unique value) and an impulse signal (first value non-zero with the remaining values set to 0). In case of the IIR functions, I would zero all coefficients that are part of the feedback loop (A coefficients for a Direct Form2 filter), with the remaining coefficients assigned unique values. The signal should again be an impulse. Once you are happy that this is working as expected. you can then expand your example until you are confident that the conversion of the filter coefficients works and both the filter function in Matlab and the corresponding function in VisualDSP++ produce identical filter responses.

Andreas