MATLAB: How to avoid receiving the error “Scale value is beyond the range of the filter input” when trying to generate HDL code for the filter in the Filter Design Toolbox 3.3 (R14SP3) and Filter Design HDL Coder 1.3 (R14SP3)

Filter Design HDL Coder

When I generate HDL code using the attached file in FDATOOL, with an input signal fraction length of [20 0], I receive the following error:
"Scale value 0.000008 is beyond the range of the filter input"
I would like methods to generate HDL code without changing the fraction length of
my input signal.

Best Answer

This enhancement has been incorporated in Release 2008a (R2008a). For previous product releases, read below for any possible workarounds:
The ability to generate HDL code for a filter when the input fraction length falls outside the input range is not available in Filter Design HDL Coder.
The fraction length is required to interpret the real world value of the signals.
For example, consider the input data in integer terms:
The command:
intdata = fi(16384,1,20,0)
returns:
intdata =
16384
s20,0
It is possible to rescale the signal without changing its bit pattern:
The command:
fracdata = fi(intdata*2^-19,1,20,19)
returns:
fracdata =
0.0313
s20,19
The bit pattern of the two variables, expressed in binary belo, is the same.
intdata.bin = 00000100000000000000
fracdata.bin = 00000100000000000000
In other words, use [20 19] as the input format and scale the input signal before sending it to the filter if necessary.