Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Solutions Academia Support User Community Company
spacer spacer spacer spacer spacer spacer

Technical Solutions

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


Date Last Modified: Friday, June 26, 2009
Solution ID:   1-1RPS3Z
Product:   Simulink
Reported in Release:   R14
Platform:   All Platforms
Operating System:   All OS
 

Subject:

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

Problem Description:

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.

Solution:

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'.

Please provide feedback to help us improve this Solution
Contact support
E-mail this page
Print this page