Detailed instructions for use are in the User's Guide.
[. . . ] Filter Design HDL CoderTM 2 User's Guide
How to Contact The MathWorks
Web Newsgroup www. mathworks. com/contact_TS. html Technical Support
www. mathworks. com comp. soft-sys. matlab suggest@mathworks. com bugs@mathworks. com doc@mathworks. com service@mathworks. com info@mathworks. com
Product enhancement suggestions Bug reports Documentation error reports Order status, license renewals, passcodes Sales, pricing, and general information
508-647-7000 (Phone) 508-647-7001 (Fax) The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site. Filter Design HDL CoderTM User's Guide © COPYRIGHT 20042010 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. [. . . ] We first design % a single rate Farrow filter, then convert it to a multirate Farrow filter. N = 3; % Polynomial Order
ffar = fdesign. fracdelay(0, 'N', N); hfar = design(ffar, 'lagrange'); [L, M]=rat(1. 378125); % Interpolation and decimation factors hfar = mfilt. farrowsrc(L, M, hfar. Coefficients); % The overall filter is obtained by cascading the two filters. % For HDL code generation compatibility, the cascade of FIR filters is flattened. % Note that the mfilt. farrowsrc filter is at the end of the cascade. h2 = cascade(hfir. Stage(1), hfir. Stage(2), hfar);
3-102
Generating Code for Multirate Farrow Sample Rate Converters
Generating Code for mfilt. farrowsrc Filters in the GUI
FDATool and filterbuilder do not currently support mfilt. farrowsrc filters. If you want to generate code an mfilt. farrowsrc filter in the HDL code generation GUI, you can use the fdhdltool command, as in the following example:
[L, M] = rat(48/44. 1); m = mfilt. farrowsrc(L, M); fdhdltool(m); fdhdltool opens the Generate HDL dialog box for the mfilt. farrowsrc
filter, as shown in the following figure.
3-103
3
Generating HDL Code for a Filter Design
The following code generation options are not supported for mfilt. farrowsrc filters and are disabled in the GUI: · Add pipeline registers · Distributed Arithmetic architecture · Fully or partially serial architectures · Multiple clock inputs
3-104
Generating Code for Single-Rate Farrow Filters
Generating Code for Single-Rate Farrow Filters
In this section. . . "Overview" on page 3-105 "Code Generation Properties for Farrow Filters" on page 3-105 "GUI Options for Farrow Filters" on page 3-107 "Farrow Filter Code Generation Mechanics" on page 3-110
Overview
The coder supports HDL code generation for the following single-rate Farrow filter structures: · dfilt. farrowlinearfd · dfilt. farrowfd A Farrow filter differs from a conventional filter because it has a fractional delay input in addition to a signal input. The fractional delay input enables the use of time-varying delays, as the filter operates. The fractional delay input receives a signal taking on values between 0 and 1. 0. For general information how to construct and use Farrow filter objects, see the farrow function reference page of the Filter Design Toolbox documentation. The coder provides generatetb and generatehdl properties and equivalent GUI options that let you: · Define the fractional delay port name used in generated code. · Apply a variety of test bench stimulus signals to the fractional delay port, or define your own stimulus signal.
Code Generation Properties for Farrow Filters
The following properties support Farrow filter code generation: · FracDelayPort (string). This property specifies the name of the fractional delay port in generated code. The default name is 'filter_fd'. In the
3-105
3
Generating HDL Code for a Filter Design
following example, the name 'FractionalDelay' is assigned to the fractional delay port.
D = . 3; hd = dfilt. farrowfd(D); generatehdl(hd, 'FracDelayPort', 'FractionalDelay');
· TestBenchFracDelayStimulus (string). This property specifies a stimulus signal applied to the fractional delay port in test bench code. By default, a constant value is obtained from the FracDelay property of the Farrow filter object, and applied to the fractional delay port. To use the default, leave the TestBenchFracDelayStimulus property unspecified, or pass in the empty string (''). In the following example, the filter's FracDelay property is set to 0. 6, and this value is used (by default) as the fractional delay stimulus.
D = . 3; hd = dfilt. farrowfd(D); hd. Fracdelay = 0. 6; generatetb(hd, 'VHDL');
Alternatively, you can specify generation of any of the following types of stimulus vectors:
-
'RandSweep': A vector of random values within the range from 0 to 1.
This stimulus signal has the same duration as the filter's input signal, but changes at a slower rate. Each fractional delay value obtained from the vector is held for 10% of the total duration of the input signal before the next value is obtained.
'RampSweep' : A vector of values incrementally increasing over the
-
range from 0 to 1. This stimulus signal has the same duration as the filter's input signal, but changes at a slower rate. Each fractional delay value obtained from the vector is held for 10% of the total duration of the input signal before the next value is obtained. [. . . ] Optionally, you can also specify that hdlgetserialpartition returns serial partition values and corresponding values of folding factor and number of multipliers to a cell array.
hdlgetserialpartition (Hd): for the filter object Hd, displays an
exhaustive table of serial partition values with corresponding values of folding factor and number of multipliers.
hdlgetserialpartition (Hd, 'FoldingFactor, ff): for the filter object Hd, displays the serial partition values and number of multipliers corresponding the folding factor ff. hdlgetserialpartition (Hd, 'Multipliers, nmults): for the filter object Hd, displays the serial partition values and folding factor corresponding to the number of multipliers nmults. hdlgetserialpartition (Hd, 'SerialPartition', [p1 p2. . . pN]):
for the filter object Hd, displays the folding factor and number of multipliers corresponding to the serial partition vector [p1p2. . . pN].
[sp, fold, nm] = hdlgetserialpartition(Hd): for the filter object Hd, returns an exhaustive table of serial partition values with corresponding values of folding factor and number of multipliers to a cell array. [sp, fold, nm] = hdlgetserialpartition(Hd, 'FoldingFactor, ff): for the filter object Hd, returns the serial partition values and number of multipliers corresponding to the folding factor ff to a cell array. [. . . ]