Inspect Generated Code for Nonvirtual Buses

This example shows how nonvirtual buses appear in the generated code for a model. The steps require a Simulink® Coder™ license.

Open and simulate the example model, which contains a nonvirtual bus.

Open the Simulink Coder app. On the Apps tab, click the arrow on the far right of the Apps section. Under Code Generation, click Simulink Coder.

To generate code for the model, on the C Code tab, click Generate Code.

To see the generated files, open the NonvirtualBusCodeGenModel_grt_rtw folder.

NonvirtualBusCodeGenModel_types.h defines the Simulink.Bus object as a struct.

typedef struct {
  real_T a;
  real_T b;
  real_T c;
} BusObject;

NonvirtualBusCodeGenModel.h defines the Unit Delay block using the BusObject struct.

typedef struct {
  BusObject UnitDelay_DSTATE;          /* '<Root>/Unit Delay' */
} DW_NonvirtualBusCodeGenModel_T;

NonvirtualBusCodeGenModel.c implements the Unit Delay block, which passes the nonvirtual bus to the Outport block.

NonvirtualBusCodeGenModel_Y.Out1 =

See Also



Related Topics