Resource Sharing - MATLAB & Simulink (original) (raw)

Resource sharing is an area optimization in which HDL Coder™ identifies multiple functionally equivalent resources and replaces them with a single resource. The data is time-multiplexed over the shared resource to perform the same operations.

How Resource Sharing Works

You can specify a sharing factor for a subsystem or a MATLAB Function block. HDL Coder tries to identify a certain number of identical, shareable resources up to the value of the sharing factor. How HDL Coder shares these resources depends on the number of resources, the sharing factor, and the oversampling value for your design. To learn how to set an oversampling value for your design, see Specifying the Oversampling Value.

By default, the oversampling value is 1, and resource sharing overclocks the shared resources by an overclocking factor that depends on the remainder of the sharing factor and the number of resources. In this code, OCF is the overclocking factor, N is the number of sharable resources, and SF is the sharing factor:

if rem(SF,N) == 0 OCF = N; else OCF = SF; end

If you specify an oversampling value greater than 1, either automatically by using the Treat Simulink rates as actual hardware rates parameter or manually by using the Oversampling factor parameter, your design operates a faster clock rate on the target hardware when clock-rate pipelining is enabled. When you specify a SharingFactor, the resource sharing optimization tries to share up to N resources and overclocks the shared resources by a factor given by:

Overclocking factor = (block_rate ÷DUT_base_rate) × Oversampling value

You can use the validation model to verify that the output of the optimized DUT is bit-true to the results produced by the original DUT. To learn more about the validation model, see Generated Model and Validation Model.

Benefits and Costs of Resource Sharing

Resource sharing can substantially reduce your chip area. For example, the generated code can use one multiplier to perform the operations of several identically configured multipliers from the original model. However, resource sharing has the following costs:

Shareable Resources in Different Blocks

If you specify the sharing factor for a MATLAB Function block to a value greater than 1, HDL Coder identifies and shares functionally equivalent multipliers.

If you specify the sharing factor for a Subsystem to a value greater than 1, HDL Coder identifies and shares functionally equivalent instances of the following types of blocks:

The code generator shares functionally equivalent MATLAB Function blocks with fixed-point types. When you use floating-point types or use theMATLAB Datapath architecture for MATLAB Function blocks with fixed-point types, HDL Coder treats the MATLAB Function block as a regularSubsystem. You can then share functionally equivalent resources inside the MATLAB Function block. To learn more, see Use MATLAB Datapath Architecture for Sharing with MATLAB Function Blocks.

Specify Resource Sharing

To specify resource sharing from the UI:

At the command-line, set the SharingFactor usinghdlset_param, as in the following example.

modelname = 'sfir_fixed' dut = 'sfir_fixed/symmetric_fir'; open_system(modelname) hdlset_param(dut,'SharingFactor', 4);

Block Requirements for Resource Sharing

For blocks to be shared, they must meet these requirements:

To learn about block-specific settings and requirements for resource sharing, see:

Resource Sharing Report

To see the resource sharing information in the report, before you generate code for each subsystem or model reference, enable the optimization report. To enable this report, in the HDL Code tab, select Report Options, and then select Generate optimization report.

When you generate the optimization report, in the Streaming and Sharing section, you see the effect of the resource sharing optimization. If resource sharing is unsuccessful, the report shows diagnostic messages and offending blocks that cause resource sharing to fail.

If resource sharing is successful, the report displays the SharingFactor, and a table that contains groups of blocks that shared resources. The table contains:

To see the shared resources in your Simulink model and in the generated model, click the Highlight shared resources and diagnostics link.

Limitations for Resource Sharing

More About