www.gusucode.com > hdlcoder 案例代码 matlab源码程序 > hdlcoder/DiscreteFIRSharingExample.m
%% Area Reduction of Filter Subsystem % To reduce the number of multipliers in the HDL implementation of a multifilter % design, use the *SharingFactor* HDL Coder(TM) optimization. open_system('DiscreteFIRSharing') %% % The model includes a sinusoidal signal source feeding a filter subsystem % targeted for HDL code generation. % % <<../DiscreteFIRSharing_SubSystem.png>> % % The subsystem contains a Discrete FIR Filter block and a Biquad Filter % block. This design demonstrates how the optimization tools share resources % between multiple filter blocks. %% % The Discrete FIR Filter block has 43 symmetric coefficients. The Biquad % Filter block has 6 coefficients, two of which are unity. With no optimizations % enabled, the generated HDL code takes advantage of symmetry and unity % coefficients. The nonoptimized HDL implementation of the subsystem uses % 27 multipliers. % % <<../DiscreteFIRSharing_NoOptims.png>> % % To enable streaming optimization for the *Multi-Filter Subsystem*, % right-click the subsystem and select *HDL Code* > *HDL Block Properties*. % % <<../DiscreteFIRSharing_HDLBlkProps.png>> % % Set the *SharingFactor* to 27 to reduce the design to a single multiplier. % The optimization tools attempt to share multipliers with matching data % types. To reduce to a single multiplier, you must set the internal data % types of the filter blocks to match each other. %% % 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 % Multi-Filter Subsystem and select *HDL Code* > *Generate HDL for Subsystem*. %% % With the *SharingFactor* applied, the subsystem upsamples the rate by 27 % to share a single multiplier for all the coefficients. % % <<../DiscreteFIRSharing_Arch.png>> % % In the *Code Generation Report* window, click *High-level Resource % Report*. The generated HDL code now uses one multiplier. % % <<../DiscreteFIRSharing_Resource.png>> %