Main Content

资源共享

Resource sharingis 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.

资源共享的工作原理

您可以指定一个共享因素SF对于子系统或MATLABFunction堵塞。HDL编码器试图确定一定数量的相同的可共享资源n取决于SF。代码生成器如何共享这些资源取决于n,,,,SF,和过采样因子

默认情况下,过采样因子是1,资源共享超频共享resources by an overclocking factor (OCF) that depends on the remainder ofSFandn

如果rem(sf,n)== 0 ocf = n;别的OCF= SF;结尾

如果您指定过采样因子大于1的设计,您的设计在目标硬件上运行更快的时钟速率,因为默认情况下启用了时钟速率管道。指定一个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)×过采样

您可以使用验证模型来验证优化的DUT的输出是否对原始DUT产生的结果进行了位真实。要了解有关验证模型的更多信息,请参见Generated Model and Validation Model

资源共享的利益和成本

资源共享可以大大减少您的芯片区域。例如,生成的代码可以使用一个乘法器来执行原始模型中几个相同配置的乘数的操作。但是,资源共享具有以下成本:

  • 使用更多的多路复用器,可以使用更多的寄存器。

  • 减少分布式管道或重新安装的机会,因为HDL编码器不会在时钟速率边界范围内管道。

  • Multiplies the clock rate of the target hardware by the sharing factor.

在不同块中共享资源

如果您指定一个非零共享因素MATLABFunctionblock, HDL Coder identifies and shares functionally equivalent multipliers.

如果您指定一个非零共享因素子系统,HDL编码器识别并共享以下类型的块功能等效实例:

  • Gain

  • 产品

  • Multiply-Add

  • 添加or有两个输入

  • Atomic Subsystem

  • MATLABFunction

代码生成器在功能上共享MATLABFunction具有固定点类型的块。当您使用浮点类型或使用MATLABDatapath架构MATLABFunction具有固定点类型的块,HDL编码器对待MATLABFunctionblock as a regular子系统。然后,您可以在该功能上共享功能等效资源MATLABFunction堵塞。To learn more, see使用MATLAB DATAPATH架构与MATLAB功能块共享

Specify Resource Sharing

To specify resource sharing from the UI:

  • 在里面应用tab, selectHDL Coder。TheHDL Codetab appears. Select the subsystem, model reference, orMATLABFunction阻止,然后单击HDL块属性。在里面SharingFactor字段,输入可共享资源的数量。

  • 右键单击子系统,模型参考或MATLABFunction块并选择HDL Code>HDL块属性。在里面SharingFactor字段,输入可共享资源的数量。

在命令行,设置SharingFactor使用HDLSET_PARAM,,,,as in the following example.

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

资源共享的限制

  • Multirate sharing cannot share resources that have different number of pipelines inserted from adaptive pipelining.

  • 资源共享不支持模型参考。金宝app

Block Requirements for Resource Sharing

Blocks to be shared must have the following requirements:

  • Single-rate.

  • 没有无限的样本率。DUT不得包含与采样时间调成Inf。例如,Constant块必须具有采样时间设置为-1。将样本时间设置为-1的所有Constantblocks in your DUT, use the following MATLAB code:

    blks = find_system(dut,'blocktype',,,,'Constant');为了i = 1:length(blks) set_param(blks{i},'SampleTime',,,,'-1');结尾

  • 没有总线输入或输出。

  • no tunable mask parameters. To share these blocks, in the Mask Editor, clear theTunable复选框。

  • 如果块在反馈循环中,则至少一个Unit Delayor延迟块必须连接到每个输出端口。

要了解特定区块的设置和资源共享的要求,请参见:

资源共享报告

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 theHDL Codetab, selectReport Options,和n select生成优化报告

When you generate the optimization report, in the流and Sharingsection, 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.

如果资源共享成功,报告将显示SharingFactor,以及包含共享资源的块组的表。该表包含:

  • 组ID: A unique ID for a group of similar Simulink®blocks, such as add or product blocks, that share resources.

  • 资源类型:共享组中的simulink金宝app块的类型。

  • I/O Wordlengths:从共享组中从块中输入和输出的输入的单词长度。

  • 小组大小:共享组中同一类型的块数。

  • 块名:属于共享组的块的名称。

  • 彩色传奇: Color that highlights all the blocks in a sharing group.

To see the shared resources in your Simulink model and in the generated model, click theHighlight shared resources and diagnosticslink.

相关示例

更多关于