ERT code generation customization

3 ビュー (過去 30 日間)
TAB
TAB 2011 年 8 月 8 日
編集済み: Guilherme T Silva 2019 年 2 月 15 日
I want to customize the code generated by ERT target, but i dont know where to start. One of my customization requirement is -- ERT packs the external inputs & outputs in structure in generated code as below
/* External inputs (root inport signals with auto storage) */
typedef struct {
uint8_T U8_Num1; /* '<Root>/U8_Num1' */
uint8_T U8_Num2; /* '<Root>/U8_Num2' */
} ExternalInputs_cmp;
/* External outputs (root outports fed by signals with auto storage) */
typedef struct {
uint16_T U16_ProductOut; /* '<Root>/U16_ProductOut' */
boolean_T B_CompRes; /* '<Root>/B_CompRes' */
} ExternalOutputs_cmp;
I want to use external ips and ops names (eg. U8_Num1 and U8_Num2) as global variable in my code. So generated code should process them as it is
uint8_T U8_Num1; /* '<Root>/U8_Num1' */
uint8_T U8_Num2; /* '<Root>/U8_Num2' */
I want to know which TLCs should be modified and how? Can someone help? Thanks.

採用された回答

Kaustubha Govind
Kaustubha Govind 2011 年 8 月 8 日
You shouldn't need to modify TLC files to do this. You only have to specify the right storage class for your input/output signals. See Interfacing Signals to External Code for documentation.
Here's what you should do:
  1. Right click on an input/signal signal (make sure you click on the signal - not inport/outport block)
  2. Select "Signal Properties"
  3. In the dialog window, enter a name (eg. U8_Num1) for "Signal Name"
  4. In the "Code Generation" tab, select storage class as ImportedExtern or ExportedGlobal (for ImportedExtern, you need to provide a header with the declarations)
  5. The generated datatype is the same as the one specified on the inport/outport block
  3 件のコメント
Naini Dawar
Naini Dawar 2017 年 3 月 14 日
how can we create local variables. I need the variable to be declared locally in the same function rather than being the extern.
Guilherme T Silva
Guilherme T Silva 2019 年 2 月 15 日
編集済み: Guilherme T Silva 2019 年 2 月 15 日
You can try the Localizable storage class:

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Coder についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by