Why does HDL Code Generation fail for a FIR Filter, in the case that all of my filter coefficients reduce to zero value, when using Simulink HDL Coder 2.2 (R2011b) ?

2 ビュー (過去 30 日間)
I have a complex subsystem which contains several FIR filters. The coefficients for each FIR filter are computed by the mask of the subsystem. In some cases, the coefficients for some FIR filters are thereby set to zero, and the Simulink simulation is working fine and automatically produces the correct result based on the coefficients.
But when a developer hits the "Generate HDL" button, he gets an error. It would be very nice, if HDL Coder could still generate code for this scenario, and automatically take care of the all-zero coefficient filter condition.

採用された回答

MathWorks Support Team
MathWorks Support Team 2012 年 1 月 13 日
By default Simulink HDL Coder 2.2 (R2011b) will generate an error if it has to realize the HDL code for a FIR filter whose all coefficients are set to zero.
In order to work-around this behavior:
You can create a N-tap FIR Filter and generate a Simulink subsystem with the coefficients as ports.You can then set the coefficients programmatically in a variable. This subsystem will be supported for HDL Code Generation.
This can be done something like this:
N = 9; % number of taps -1
nums = fir1(N, 0.4);
Hd = dfilt.dffir(nums);
Hd.arithmetic = 'fixed';
realizemdl(Hd, 'MapCoeffsToPorts', 'on');
However, there are a couple of limitations of this approach:
1.) You will have to fix the maximum number of taps or coefficients before hand.
2.) The architecture implementations (available under rt. click menu on the Filter block in HDL Block Properties) will not be available for such a subsystem.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHDL Code Generation についてさらに検索

製品


リリース

R2011b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by