| Filter Design HDL Coder™ | ![]() |
| On this page… |
|---|
Code Generation Properties for Farrow Filters |
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.
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 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.
A user-defined stimulus vector. You can pass in a call to any function that returns a vector. Alternatively, create the vector in the workspace and pass it in as shown in the following code example:
D = .3;
hd = dfilt.farrowfd(D);
inputdata = generatetbstimulus(hd, 'TestBenchStimulus', {'ramp'});
mytestv = [0.5*ones(1, length(inputdata)/2), 0.2*ones(1, length(inputdata)/2)];
generatetb(hd, 'VHDL', 'TestBenchStimulus', {'noise'},...
'TestbenchFracDelayStimulus',mytestv);
Note A user-defined fractional delay stimulus signal must have the same length as the test bench input signal. If the two signals do not have equal length, test bench generation terminates with an error message. The error message displays the signal lengths, as shown in the following example: D = .3;
hd = dfilt.farrowfd(D);
inputdata = generatetbstimulus(hd, 'TestBenchStimulus', {'ramp'});
mytestv = [0.5*ones(1, length(inputdata)/2), 0.2*ones(1, length(inputdata)/2)];
generatetb(hd, 'VHDL', 'TestBenchStimulus', {'noise' 'chirp'},...
'TestbenchFracDelayStimulus',mytestv);
??? Error using ==> generatevhdltb
The lengths of specified vectors for FracDelay (1026) and Input (2052) do not match. |
This section describes Farrow filter code generation options that are available in the Filter Design HDL Coder GUI. These options correspond to the properties described in Code Generation Properties for Farrow Filters.
Note The Farrow filter options are displayed only when the a Farrow filter is selected for HDL code generation. |
The Farrow filter options are:
The Fractional delay port field in the More HDL Settings dialog box (shown in the following figure) specifies the name of the fractional delay port in generated code. The default name is filter_fd.

The Fractional delay stimulus pop-up list in the More Test Bench Settings dialog box (shown in the following figure) lets you select a stimulus signal applied to the fractional delay port in the generated test bench.

The Fractional delay stimulus list lets you select generation of any of the following types of stimulus signals:
Get value from filter: (default). A constant value is obtained from the FracDelay property of the Farrow filter object, and applied to the fractional delay port.
Ramp sweep. 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.
Random sweep. A vector of random values in 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.
User defined. When you select this option, the User defined stimulus field is enabled. You can enter a call to any function that returns a vector in the User defined stimulus field. Alternatively, create the vector as a workspace variable and enter the variable name, as shown in the following figure.

FDATool does not support design or import of Farrow filters. To generate HDL code for a Farrow filter, use one of the following methods:
Use the MATLAB command line to create a Farrow filter object and initiate code generation, and set Farrow-related properties, as in the examples shown in Code Generation Properties for Farrow Filters.
Use the MATLAB command line to create a Farrow filter object. Then use the fdhdltool function to open the Generate HDL dialog box. For example, the following commands create a Farrow linear fractional delay filter object Hd and pass it in to fdhdltool:
D = .3; Hd = dfilt.farrowlinearfd(D); Hd.arithmetic = 'fixed'; fdhdltool(Hd);
Use filterbuilder to design a Farrow (fractional delay) filter object. Then, select the Code Generation pane of the filterbuilder dialog box (shown in the following figure). Click the Generate HDL button to open the Generate HDL dialog box, specify code generation options, and generate code.

As shown in the following figure, some options are disabled or set to a fixed default value when the Generate HDL dialog box is opened with a Farrow filter. The options affected are:
Architecture. This option is set to it default (Fully parallel) and disabled.
Clock inputs. This option is set to it default (Single) and disabled.

![]() | Generating Code for Multirate Farrow Sample Rate Converters | Customizing the Test Bench | ![]() |
| © 1984-2008- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |