Main Content

Starting Filter Design HDL Coder

Opening the Filter Design HDL Coder UI from Filter Designer

To open the initial Generate HDL tool from Filter Designer, do this:

  1. Enter the filterDesigner command at the MATLAB® command prompt. The Filter Designer tool opens.

    Filter Designer tool

  2. If the filter design is quantized, skip to step 3. Otherwise, quantize the filter by clicking the Set Quantization Parameters button. The Filter arithmetic menu appears in the bottom half of the window.

    Filter Designer tool showing the Filter arithmetic menu


    Supported filter structures allow both fixed-point and floating-point (double) realizations.

  3. If desired, adjust the setting of the Filter arithmetic option. The Filter Designer displays the first of three tabbed panes.

    Filter Designer tool showing the Coefficients tab at the bottom of the window

  4. Select Targets > Generate HDL. The Filter Designer displays the Generate HDL tool.

    Generate HDL tool

    If the coder does not support the structure of the current filter in the Filter Designer, an error message appears.

Opening the Filter Design HDL Coder UI from the Filter Builder

If you are not familiar with the Filter Builder UI, see the DSP System Toolbox™ documentation.

To open the Generate HDL tool from Filter Builder, do this:

  1. At the MATLAB command prompt, type a filterBuilder command that corresponds to the filter response or filter object you want to design.

    This figure shows the default settings of the main pane of the Filter Builder Lowpass Design dialog box.

    Lowpass Design dialog box

  2. Set the filter design parameters as required.

  3. Optionally, select the check box Use a System object to implement filter.

  4. Click the Data Types tab. Set Arithmetic to Fixed point and select data types for internal calculations.

    Lowpass Design dialog box showing fixed-point data types settings

  5. Click the Code Generation tab.

    Code Generation tab of Lowpass Design dialog box

  6. In the Code Generation pane, click the Generate HDL button. This button opens the Generate HDL tool, passing in the current filter object from Filter Builder.

    Generate HDL tool

  7. Set the desired code generation and test bench options and generate code in the Generate HDL tool.

Opening the Filter Design HDL Coder UI Using the fdhdltool Command

You can use the fdhdltool command to open the Generate HDL tool directly from the MATLAB command line. The syntax is:


where Hd is a type of filter object that is supported for HDL code generation. If the filter is a System object™, you must specify the input data type.


The fdhdltool function is particularly useful when you must use the Filter Design HDL Coder™ UI to generate HDL code for filter structures that are not supported by Filter Designer or Filter Builder. For example, this code creates a Farrow fractional delay filter object farrowfilt, which is passed in to the fdhdltool function.

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

fdhdltool operates on a copy of the filter object, rather than the original object in the MATLAB workspace. Changes made to the original filter object after invoking fdhdltool do not apply to the copy and do not update the Generate HDL tool.

The name of the copied filter object by default is dobj_copy. This is reflected in the filter Name field. Likewise, the test bench file name is dobj_tb_copy. This is reflected in the File name field on the Test Bench pane. Update these default values to user-defined names if required.

Generate HDL tool