Why does Real-Time Workshop 6.0 (R14) include an extra copy of bus signals in a model's generated code?

2 views (last 30 days)
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.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
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'.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!