Documentation

Cascade Filters

Supported Cascade Filter Types

The coder supports code generation for the following types of cascade filters:

  • Multirate cascade of filter objects (mfilt.cascade)

  • Cascade of discrete-time filter objects (dfilt.cascade)

Generating Cascade Filter Code

Generating Cascade Filter Code with FDATool

To generate cascade filter code with FDATool:

  1. Instantiate the filter stages and cascade them in the MATLAB® workspace (see the DSP System Toolbox™ documentation for the dfilt.cascade and mfilt.cascade filter objects).

    The coder currently imposes certain limitations on the filter types allowed in a cascade filter. See Rules and Limitations for Code Generation with Cascade Filters before creating your filter stages and cascade filter object.

  2. Import the cascade filter object into FDATool, as described in Import and Export Quantized Filters in the DSP System Toolbox documentation.

  3. After you have imported the filter, open the Generate HDL dialog box, set the desired code generation properties, and generate code. See Rules and Limitations for Code Generation with Cascade Filters.

Generating Cascade Filter Code with the fdhdltool Function

To generate cascade filter code from the command line using fdhdltool:

  1. Instantiate the filter stages and cascade them in the MATLAB workspace (see the DSP System Toolbox documentation for the dfilt.cascade and mfilt.cascade filter objects).

    The coder currently imposes certain limitations on the filter types allowed in a cascade filter. SeeRules and Limitations for Code Generation with Cascade Filters before creating your filter stages and cascade filter object.

  2. Call fdhdltool to open the Generate HDL dialog box, passing in the cascade filter object as in the following example:

    fdhdltool(my_cascade)

  3. Set the desired code generation properties, and generate code. See .

    Rules and Limitations for Code Generation with Cascade Filters

Rules and Limitations for Code Generation with Cascade Filters

The following rules and limitations apply to cascade filters when used for code generation:

  • You can generate code for cascades that combine the following filter types:

    • Decimators and/or single-rate filter structures

    • Interpolators and/or single-rate filter structures

    Code generation for cascades that include both decimators and interpolators is not currently supported, however. If unsupported filter structures or combinations of filter structures are included in the cascade, code generation is disallowed.

  • For code generation, only a flat (single-level) cascade structure is allowed. Nesting of cascade filters is disallowed.

  • By default, input and output registers are removed from the stages of the cascade in generated code, except for the input of the first stage and the output of the final stage. However, if the Add pipeline registers option in Generate HDL dialog box is selected, the output registers for each stage are generated, and internal pipeline registers may be added, depending on the filter structures.

      Note:   Code generated for interpolators within a cascade includes input registers, regardless of the setting of the Add pipeline registers option.

  • When a cascade filter is passed in to the Generate HDL dialog box, the FIR adder style option is disabled. If you require tree adders for FIR filters in a cascade, select the Add pipeline registers option (since pipelines require tree style FIR adders).

  • The coder generates separate HDL code files for each stage of the cascade, in addition to the top-level code for the cascade filter itself. The filter stage code files are identified by appending the string _stage1, _stage2, ... _stageN to the filter name.

The following figure shows the default settings of the Generate HDL dialog box options for a cascade filter design.

Was this topic helpful?