Main Content

Resource Sharing of Subsystems and Floating-Point IPs

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. To learn more about how resource sharing works, see Resource Sharing.

You can follow these guidelines to learn how to use the resource sharing optimization effectively for subsystems such as atomic subsystems and MATLAB Function blocks, and with floating-point IPs. Each guideline has a severity level that indicates the level of compliance requirements. To learn more, see HDL Modeling Guidelines Severity Levels.

General Considerations for Sharing of Subsystems

Guideline ID

3.1.5

Severity

Recommended

Description

To share resources for identical subsystems, such as when grouping Product, Add, and Delay blocks to map to one DSP slice, the subsystems to be shared must be Atomic Subsystem blocks, Virtual Subsystem blocks, or MATLAB Function blocks.

  • Determine whether you want to share resources at the existing clock rate or at a higher clock rate.

  • Sharing of enabled subsystems is not supported. For sharing resources, use atomic or virtual subsystems without enable semantics.

  • Specify a SharingFactor that is greater than or equal to the number of subsystems that you want to share.

    For example, if you have 10 subsystems, and you set the SharingFactor to 5, HDL Coder cannot implement the resource sharing to 2 instances of the subsystem. To share the subsystems, divide the subsystems, and then share the instances of the smaller subsystems.

  • Check the SharingFactor that you specify for various subsystems. The resource sharing optimization overclocks the shared resources by the LCM (Least Common Multiple) of the SharingFactor of various subsystems.

    For example, if you specify a SharingFactor of 5 for one Subsystem, and a SharingFactor of 7 for another Subsystem, the resource sharing optimization overclocks the shared resources by 35. In such cases, it is recommended that you use the same SharingFactor for both subsystems, such as 5 or 7. To learn more about this calculation, see How Resource Sharing Works.

Use MATLAB Datapath Architecture for Sharing with MATLAB Function Blocks

Guideline ID

3.1.6

Severity

Recommended

Description

HDL Coder shares MATLAB Function blocks that have:

Make sure that the blocks do not use:

  • Persistent variables

  • Loop streaming

  • Output pipelining

By using the MATLAB Datapath architecture, you can share resources inside the MATLAB Function block and across the MATLAB Function block with other blocks in your Simulink model. When you use this architecture, the code generator treats the MATLAB Function block like a regular Subsystem block. This capability enables you to more widely apply various speed and area optimizations with MATLAB Function blocks. See HDL Optimizations Across MATLAB Function Block Boundary Using MATLAB Datapath Architecture.

Sharing of Subsystems

Guideline ID

3.1.7

Severity

Recommended

Description

HDL Coder can share Subsystem blocks that have the same Simulink checksum and the same HDL block properties.

To share Subsystem blocks, the state elements that the blocks can contain are:

  • Delay

  • Unit Delay

  • Unit Delay Enabled Synchronous

  • Unit Delay Resettable Synchronous

  • Unit Delay Enabled Resettable Synchronous

The state elements must have the Initial condition parameter set to 0.

Sharing of subsystems inside enabled subsystems with synchronous semantics is not supported. To share resources, use enabled subsystems with classic semantics.

You cannot share subsystems that contain the following blocks or block implementations:

  • Detect Change

  • Discrete Transfer Fcn

  • HDL FFT

  • HDL FIFO

  • Math Function (conj, hermitian, transpose)

  • MATLAB Function blocks that contain persistent variables

  • Sqrt

  • Cascade architecture (MinMax, Product, Sum)

  • Reciprocal Newton architecture

  • Filter blocks including Discrete FIR Filter

  • Communications Toolbox™ blocks

  • DSP System Toolbox™ blocks, except Discrete FIR Filter

  • Stateflow® blocks

  • Blocks that are not supported for delay balancing. For details, see Delay Balancing Limitations.

Limitations

Resource sharing of atomic subsystems might cause a mismatch in the initialization cycles of the validation model if your model has:

  • Logic in the subsystems shared that produce non-zero output when the input is zero.

  • Subsystems shared that are in a serial configuration in your design under test (DUT) subsystem.

Resource Sharing of Floating-Point IPs

Guideline ID

3.1.8

Severity

Recommended

Description

To share multiple:

  • Floating-point adders, set ShareAdders to on.

  • Floating-point multipliers, make sure ShareMultipliers is set to on.

  • Other floating-point resources, set ShareFloatingPointIPs to on.

See also Modeling with Native Floating Point.

Related Examples

More About