MATLAB Examples

Area Reduction of Multichannel Filter Subsystem

To reduce the number of multipliers in the HDL implementation of a multichannel filter and surrounding logic, use the StreamingFactor HDL Coder™ optimization.

The model includes a two-channel sinusoidal signal source feeding a filter subsystem targeted for HDL code generation.

The subsystem contains a Discrete FIR Filter block and a constant multiplier. The multiplier is included to show the optimizations operating over all eligible logic in a subsystem.

The filter has 44 symmetric coefficients. With no optimizations enabled, the generated HDL code takes advantage of symmetry. The nonoptimized HDL implementation uses 46 multipliers: 22 for each channel of the filter and 1 for each channel of the Product block.

To enable streaming optimization for the Multichannel FIR Filter Subsystem, right-click the subsystem and select HDL Code > HDL Block Properties.

Set the StreamingFactor to 2, because this design is a two-channel system.

To observe the effect of the optimization, under Configuration Parameters > HDL Code Generation, select Generate resource utilization report and Generate optimization report. Then, to generate HDL code, right-click the Multichannel FIR Filter Subsystem and select HDL Code > Generate HDL for Subsystem.

With the streaming factor applied, the logic for one channel is instantiated once and run at twice the rate of the original model.

In the Code Generation Report window, click High-level Resource Report. The generated HDL code now uses 23 multipliers, compared to 46 in the nonoptimized code. The multipliers in the filter kernel and subsequent scaling are shared between the channels.

To apply SharingFactor to multichannel filters, set the SharingFactor to 23.

The optimized HDL now uses only 2 multipliers. The optimization tools do not share multipliers of different sizes.