Multirate Farrow Sample Rate Converters
Code Generation for Multirate Farrow Sample Rate Converters
The coder supports code generation for multirate Farrow sample rate converters
(dsp.FarrowRateConverter
). dsp.FarrowRateConverter
is a multirate filter structure that implements a sample rate converter with an arbitrary
conversion factor determined by its interpolation and decimation factors.
Unlike a single-rate Farrow filter (see Single-Rate Farrow Filters), a multirate Farrow sample rate
converter does not have a fractional delay input. For general information on this filter
structure, see the dsp.FarrowRateConverter
reference page in the
DSP System Toolbox™ documentation.
Generating Code for dsp.FarrowRateConverter Filters at the Command Line
You can generate HDL code for either a standalone
dsp.FarrowRateConverter
object, or a cascade that includes a
dsp.FarrowRateConverter
object. This section provides simple examples
for each case.
This example instantiates a standalone fixed-point Farrow sample rate converter. The object converts between two standard audio rates, from 44.1 kHz to 48 kHz. The example generates both VHDL code and a VHDL test bench.
Hm = dsp.FarrowRateConverter(48,44.1); generatehdl(Hm,'InputDataType',numerictype(1,16,15),... 'GenerateHDLTestbench','on')
This example generates HDL code for a cascade that includes a
dsp.FarrowRateConverter
filter. The coder requires that the
dsp.FarrowRateConverter
filter is in the last position of the cascade.
First, interpolate the original 8-kHz signal by four, using a cascade of FIR halfband filters.
Astop = 50; % Minimum stopband attenuation TW = .125; % Transition Width f2 = fdesign.interpolator(4,'Nyquist',4,'TW,Ast',TW,Astop); hfir = design(f2,'multistage','HalfbandDesignMethod','equiripple','Systemobject',true);
dsp.FarrowRateConverter
System object™ calculates a piecewise polynomial fit using Lagrange interpolation
coefficients.
N = 3; % Polynomial Order hfar = dsp.FarrowRateConverter(32,44.1,'PolynomialOrder',N)
dsp.FarrowRateConverter
filter is at the end of the
cascade.interp_cascade.addStage(hfar); generatehdl(interp_cascade,'InputDataType',numerictype(1,16,15),... 'GenerateHDLTestbench','on');
Generating Code for dsp.FarrowRateConverter
Filters in the UI
filterDesigner
and filterBuilder
do not currently
support dsp.FarrowRateConverter
filters. To generate code for a
dsp.FarrowRateConverter
filter in the HDL code generation UI, use the
fdhdltool
command, as in this example:
m = dsp.FarrowRateConverter(48,44.1); fdhdltool(m,numerictype(1,16,15));
fdhdltool
opens the Generate HDL tool for the
dsp.FarrowRateConverter
filter, as shown in this figure.
These code generation options are not supported for
dsp.FarrowRateConverter
filters and are disabled in the UI:
Use of pipeline registers (
AddPipelineRegisters
)Distributed Arithmetic architecture (
DARadix
and (DALUTPartition
))Fully or partially serial architectures (
SerialPartition
andReuseAccum
)Multiple clock inputs (
ClockInputs
)