Main Content

Single-Rate Farrow Filters

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 from 0 through 1.0. For general information how to construct and use Farrow filter objects, see the DSP System Toolbox™ documentation.

Supported Single-Rate Farrow Filters

You can generate HDL code for single-rate Farrow filters from these objects and structures:

  • dsp.VariableFractionalDelay System object™

  • dfilt.farrowfd filter structure

  • dfilt.farrowlinearfd filter structure

The coder provides generatehdl properties and equivalent UI options that let you:

  • Define the fractional delay port name used in generated code.

  • Apply various test bench stimulus signals to the fractional delay port, or define your own stimulus signal.

Code Generation Mechanics for Farrow Filters

Filter Designer does not support the design or import of Farrow filters. To generate HDL code for a Farrow filter, use one of these methods:

  • Use the MATLAB® command line to create a Farrow filter object. Initiate code generation, and set Farrow-related properties. See Code Generation Properties for Farrow Filters.

  • Use the MATLAB command line to create a Farrow filter object. Then pass this object in to fdhdltool.

    For example, these commands create a Farrow fractional delay System object, farrowfilt, and pass it to fdhdltool, together with its input and fractional delay data types.

    farrowfilt = dsp.VariableFractionalDelay('InterpolationMethod','Farrow');
    inputDataType = numerictype(1,18,17);
    fdDataType = numerictype(1,8,7);
    fdhdltool(farrowfilt,inputDataType,fdDataType);

    The fdhdltool tool opens the Generate HDL tool. See UI Options for Farrow Filters for more information how to set properties in the tool.

  • Use filterBuilder to design a Farrow (fractional delay) filter object. In the Filter Builder tool, select the Code Generation tab. To open the Generate HDL tool, click Generate HDL.

    Fractional Delay Design dialog box

    See UI Options for Farrow Filters for more information how to set properties in the Generate HDL tool.

Options Disabled for Farrow Filters

When the Generate HDL tool opens with a Farrow filter, the coder disables some options or sets them to fixed default values. The options affected are:

  • Architecture. The coder sets this option to its default (Fully parallel) and disables it.

  • Clock inputs. The coder sets this option to its default (Single) and disables it.

Code Generation Properties for Farrow Filters

These properties are supported for Farrow filter code generation:

  • FracDelayPort (character vector). This property specifies the name of the fractional delay port in the generated code. The default name is 'filter_fd'. In this example, the name 'FractionalDelay' is assigned to the fractional delay port.

    farrowfilt = dsp.VariableFractionalDelay('InterpolationMethod','Farrow');
    generatehdl(farrowfilt,'InputDataType',numerictype(1,18,17),...
                'FractionalDelayDataType',numerictype(1,8,7),...
                'FracDelayPort','FractionalDelay');
    
  • TestBenchFracDelayStimulus (character vector). This property specifies a stimulus signal applied to the fractional delay port in the test bench code.

    By default, an internal constant value is applied to the fractional delay port. To use the default, leave the TestBenchFracDelayStimulus property unspecified, or pass in the empty character vector (''):

    farrowfilt = dsp.VariableFractionalDelay('InterpolationMethod','Farrow');
    generatehdl(farrowfilt,'InputDataType',numerictype(1,18,17),...
                'FractionalDelayDataType',numerictype(1,8,7),...
                'GenerateHDLTestbench','on');

    Alternatively, you can specify generation of these types of stimulus vectors:

    • 'RandSweep': A vector of random values between 0 and 1. This stimulus signal has the same duration as the input to the filter, 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. For example:

      farrowfilt = dsp.VariableFractionalDelay('InterpolationMethod','Farrow');
      generatehdl(farrowfilt,'InputDataType',numerictype(1,18,17),...
                  'FractionalDelayDataType',numerictype(1,8,7),...
                  'GenerateHDLTestbench','on',...
                  'TestbenchFracDelayStimulus','RandSweep');

    • 'RampSweep': A vector of values incrementally increasing over the range from 0 to 1. This stimulus signal has the same duration as the input to the filter, 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.

    • A user-defined stimulus vector. You can pass in a vector to define your own stimulus. For example:

      farrowfilt = dsp.VariableFractionalDelay('InterpolationMethod','Farrow');
      mytestv = [0.5*ones(1, 512), 0.2*ones(1, 513)];
      generatehdl(farrowfilt,'InputDataType',numerictype(1,18,17),...
                 'FractionalDelayDataType',numerictype(1,8,7),...
                 'GenerateHDLTestbench','on',...
                 'TestBenchStimulus',{'chirp'},...
                 '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. For example:

      farrowfilt = dsp.VariableFractionalDelay('InterpolationMethod','Farrow');
      mytestv = [0.5*ones(1, 512), 0.2*ones(1, 513)];
      generatehdl(farrowfilt,'InputDataType',numerictype(1,18,17),...
                 'FractionalDelayDataType',numerictype(1,8,7),...
                 'GenerateHDLTestbench','on',...
                 'TestBenchStimulus',{'chirp' 'noise'},...
                 'TestbenchFracDelayStimulus',mytestv);
      Error using hdlfilter.abstractfarrow/genVecDataforFarrow
      The lengths of specified vectors for FracDelay (1025) and Input (2050) do not match.

UI Options for Farrow Filters

The Filter Design HDL Coder™ UI provides options for generating Farrow filter code. These options correspond to the properties described in Code Generation Properties for Farrow Filters.

Note

The Farrow filter options are displayed only when a Farrow filter is selected for HDL code generation.

These properties are supported for Farrow filter code generation:

  • In the Generate HDL tool, on the Global Settings > Ports tab, Fractional delay port specifies the name of the fractional delay port in the generated code. The default name is filter_fd.

    Global Settings tab of the Generate HDL tool

  • In the Generate HDL tool, on the Test Bench > Stimuli tab, use the Fractional delay stimulus to select a stimulus signal. This signal is applied to the fractional delay port in the generated test bench.

    Test Bench tab of the Generate HDL tool

    Use the Fractional delay stimulus to select the type of stimulus signal in the generated code:

    • Get value from filter (default). An internal constant value is 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 input to the filter, 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.

    • Random sweep. A vector of random values between 0 and 1. This stimulus signal has the same duration as the input to the filter, 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.

    • User defined. When you select this option, the User defined stimulus box is enabled. You can enter a vector to define your own stimulus as shown in this figure:

Related Topics