Why does Real-Time Workshop 6.0 (R14) include an extra copy of bus signals in a model's generated code?
4 次查看(过去 30 天)
显示 更早的评论
If the following conditions exist, Real-Time Workshop 6.0 (R14) includes an extra copy of bus signals in a model's generated code:
- A virtual bus passes into an atomic subsystem.
- On the subsystem's Block Parameters dialog box, the "Real-Time Workshop system code" option is set to 'Inline'.
- One or more bus signals connect directly to the output port of the atomic subsystem without passing through an intermediate nonvirtual block.
采纳的回答
MathWorks Support Team
2009-6-27
Simulink requires that atomic subsystems own the memory they output. In part, this defines the system as an atomic unit. Hence, all outputs must originate from blocks inside the atomic subsystem. When an input port feeds its signal directly to an output port in the atomic subsystem, the input port becomes nonvirtual and makes a copy of its input signal. When passing bus signals through atomic subsystems, this rule still applies, and the result is often perceived as unnecessary copies of bus signals in the generated code.
For example, suppose a model has a bus signal with 100 elements. This bus signal is input to an atomic subsystem, where only one of the 100 elements is fed directly from the subsystem's inport to its outport. Consequently, a copy of the entire bus signal (i.e., all 100 bus elements) is included in the generated code, which is quite inefficient compared to copying only the sole direct-feedthrough element. To work around this issue, follow these steps:
1. For each bus signal that connects an atomic subsystem's input port directly to its output port, insert a Signal Conversion block between the two ports.
2. Set the Signal Conversion block's "Output" parameter appropriately:
* If the block operates on a vector or scalar signal, specify the parameter as 'Contiguous copy'.
* If the block operates on a bus signal, specify the parameter as 'Bus copy'.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Schedule Model Components 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!