Information Passed to the Code Generator

Descriptions of arguments received by the target generator function.

The target generator function receives three arguments: callbacks, wparams and sysparams. It creates the main.c file.

The callbacks include the name of all APIs provided by the body, generated by the inline code generator. wparams provide information regarding individual wrapper blocks and sysparams provide global information regarding the model.

callbacks

Structure containing three fields: init, step and terminate. init and terminate contain the name of the body APIs to be called at the beginning and at the end of the simulation/execution. step is an OML cell containing the list of body APIs associated with various activations in the model. These activations correspond to the mainloop activation and the activations of interrupts, if any.

wparams

An OML cell containing the list of wparam structures corresponding to different wrapper blocks present in the model. Each wparam contains the following fields:
  • nin: Number of wrapper block inputs.
  • nout: Number of wrapper block outputs.
  • nevin: Number of wrapper block activation inputs (0 or 1 only).
  • nevout: Number of wrapper block activation outputs.
  • evoutputs: OML structure containing a field named tags providing the list of event numbers associated with block’s activations in the body. This information is not needed in most cases for the creation of main. The list is contained in a cell of length nevout.
  • Inputs: OML structure providing properties of the block inputs. The fields of the structure are: o names: an OML cell of strings of length nin containing the input variable names.
    • size: Matrix of size nin by 2; each row provides the size of each input variable.
    • type: Vector of length nin.
    • tags: Vector of length nin providing the associated port numbers in the body.
    • isByVal: An OML cell of length nin indicating whether the corresponding variable is defined by value or by reference.
    • isglobal: An OML cell of length nin indicating whether the corresponding variable should be defined as global.
  • Outputs: Similar to inputs.
  • param: Structure containing block parameters (params). It contains the code snippets associated with various keywords indicating where the snippets should be placed in the generated code.

sysparams

A structure providing parameters at the model level. It is used mainly for configuration blocks, but any block can contribute to system parameters. sysparams provided by different blocks are merged. The structure contains the following fields:
  • nin: Number of inputs.
  • nout: Number of outputs.
  • clocks: An nx2 cell providing the activation names and their corresponding API names provided by the body.
  • folder: A string containing the path to the folder where the generated code is placed.
  • period: Derived from the Base frequency, which is provided if main loop activation is used (model contains activations other than interrupt activations).
  • extlibs: OML structure providing information on required external libraries. It contains three fields: dlls, libs and libpaths. They are cells of strings of the same length providing the information on each required external library.
  • Any sysparams field defined by wrapper blocks, such as "Include" statements. The contents provided by different wrapper blocks for the same fieldname are merged into a cell. Identical contents are discarded. For example, if two blocks indicate the same "Include" statements, only one is retained.
The Custom wrapper provides functions to facilitate the extraction of information from wparams and sysparams.