Data Placement Rules and Effects

Effects of Ownership Settings

Row NumberModule Naming SettingOwner SettingEffect*

1

Not specified**

Blank**

There is a definition for the selected data object. The code generator places this definition in the .c/.cpp source file that uses it. There is also an extern declaration for this data object. The code generator places this extern declaration in one or more .h header files, as needed.

2

Not specified**

A name is specified.

Same effect as stated above.

3

Either Same as model or User specified is selected.

Blank**

Same as Row 1.

4

Either Same as model or User specified is selected, and this name is the same as that specified as the Owner property.

A name is specified and it is the same as that specified in the Module naming > Module name field.

Same as Row 1.

5

Either Same as model or User specified is selected, and this name is different than that specified as the Owner property.

A name is specified but it is different from that specified in the Module naming > Module name field.

There is no definition for the selected data object. However, there is an extern declaration for the object. The extern declaration is placed in one or more header files, as needed.

* See also Ownership Settings.
** Default.

Example Settings and Resulting Generated Files

 Data Defined In...Data Declared In...Owner-
ship*
Defined File**Header FileGenerated Files

Example Settings 1
(Rd-Write Example)

Source file

Source file

Blank

Blank

Blank

.c/.cpp source file

Example Settings 2 (Owner- ship Example)

Source file

Source file

Name of module specified

Blank

Blank

.c/.cpp source file

Example Settings 3 (Header File Example)

Source file

Source file

Blank

Blank

Desired include filename specified.

.c/.cpp source file
.h definition file

Example Settings 4 (Def. File Example)

Source file

Source file

Blank

Desired definition filename specified.

Desired include filename specified.

.c/.cpp source file
.c/.cpp definition file*
.h definition file*

Example Settings 5

Single separate source file

Source file

Blank

Blank

Blank

.c/.cpp source file
global .c/.cpp

Example Settings 6

Single separate source file

Single separate header file

Blank

Blank

Blank

.c/.cpp source file
global .c/.cpp
global.h

Example Settings 7

Single separate source file

Single separate header file

Name of module specified

Blank

Blank

.c/.cpp source file
global.c/.cpp
global.h

Example Settings 8

Single separate source file

Single separate header file

Blank

Blank

Desired include filename specified.

.c/.cpp source file
global.c/.cpp
global.h
.h definition file

* "Blank" in ownership setting means Not specified is selected in the Module naming field on the Data Placement pane, and the Owner field on the Model Explorer is blank. "Name of module specified" can be a variety of ownership settings as defined in Effects of Ownership Settings.

** The code generator generates a definition .c/.cpp file for every data object for which you specified a definition filename (unless you selected #DEFINE for the Memory section field). For example, if you specify the same definition filename for all data objects, only one definition .c/.cpp file is generated. The code generator places declarations in model.h by default, unless you specify Data declared in single separate header file for the Data declaration option on the Real-Time Workshop > Data Placement pane of the Configuration Parameter dialog box. If you select that data placement option, the code generator places declarations in global.h. If you specify a definition filename for each data object, the code generator generates one definition .c/.cpp file for each data object and places declarations in model.h by default, unless you specify Data declared in single separate header file for Data declaration. If you select that data placement option, the code generator places declarations in global.h.

Data Placement Rules

 Global Settings: Override Settings for Specific Data Object: Results in Generated Files:

Storage Class Setting

Data Def.

Data Dec.

Def. File

Owner

Header File

Where Data Def. Is

Where Data Dec. Is

Dec. Inclusion

mpt or Simulink Noncustom Storage Classes:

auto

N/A

N/A

N/A

N/A

N/A

Note 12

model.h

Note 1

Exported-Global

N/A

N/A

N/A

N/A

N/A

model.c

model.h

Note 1

Imported-Extern, Imported-Extern-Pointer

N/A

N/A

N/A

N/A

N/A

None. External

model_private.h

Note 2

Simulink-Global

N/A

N/A

N/A

N/A

N/A

Note 13

model.h

Note 1

mpt or Simulink Custom Storage Class: Imported Data:

Imported-FromFile

D/C

D/C

D/C

N/A

null

None

model_private.h

Note 3

Imported-FromFile

D/C

D/C

D/C

N/A

hdr.h

None

model_private.h

Note 4

Simulink Custom Storage Class: #define Data:

Define

D/C

D/C

N/A

N/A

N/A

N/A

#define, model.h

Note 5

mpt Custom Storage Class: #define Data:

Define

D/C

D/C

N/A

N/A

null

N/A

#define, model.h

Note 5

Define

D/C

D/C

N/A

N/A

hdr.h

N/A

#define, model.h

Note 6

mpt or Simulink Custom Storage Class: GetSet:

GetSet

D/C

D/C

N/A

N/A

hdr.h

N/A

External hdr.h

Note 4

mpt or Simulink Custom Storage Class: Bitfield, Struct:

Bitfield, Struct

D/C

D/C

N/A

N/A

N/A

model.c

model.h

Note 7

mpt Custom Storage Class: Global, Const, ConstVolatile, Volatile:

Global, Const, Const-Volatile, Volatile

auto

auto

null

null or locally owned

null

model.c

model.h

Note 1

Global, Const, Const-Volatile, Volatile

src

auto

null

null or locally owned

null

src.c

model.h

Note 1

Global, Const, Const-Volatile, Volatile

sep

auto

null

null or locally owned

null

glb.c

model.h

Note 1

Global, Const, Const-Volatile, Volatile

auto

src

null

null or locally owned

null

model.c

src.c

Note 8

Global, Const, Const-Volatile, Volatile

src

src

null

null or locally owned

null

src.c

src.c

Note 8

Global, Const, Const-Volatile, Volatile

sep

src

null

null or locally owned

null

glb.c

src.c

Note 8

Global, Const, Const-Volatile, Volatile

auto

sep

null

null or locally owned

null

model.c

glb.h

Note 9

Global, Const, Const-Volatile, Volatile

src

sep

null

null or locally owned

null

src.c

glb.h

Note 9

Global, Const, Const-Volatile, Volatile

sep

sep

null

null or locally owned

null

glb.c

glb.h

Note 9

Global, Const, Const-Volatile, Volatile

D/C

D/C

data.c

D/C

null

data.c

See Note 10.

Note 10

Global, Const, Const-Volatile, Volatile

D/C

D/C

data.c

D/C

hdr.h

data.c

hdr.h

Note 11

Global, Const, Const-Volatile, Volatile

auto

D/C

null

null

hdr.h

model.c

hdr.h

Note 11

Global, Const, Const-Volatile, Volatile

src

D/C

null

null

hdr.h

src.c

hdr.h

Note 11

Global, Const, Const-Volatile, Volatile

sep

D/C

null

null

hdr.h

glb.c

hdr.h

Note 11

Global, Const, Const-Volatile, Volatile

D/C

auto

null

External owner

null

External user-supplied file

model.h

Note 1

Global, Const, Const-Volatile, Volatile

D/C

src

null

External owner

null

External user-supplied file

src.c

Note 8

Global, Const, Const-Volatile, Volatile

D/C

sep

null

External owner

null

External user-supplied file

glb.h

Note 9

Global, Const, Const-Volatile, Volatile

D/C

D/C

null

External owner

header.h

External user-supplied file

hdr.h

Note 11

Global, Const, Const-Volatile, Volatile

D/C

D/C

null

External owner

header.h

External user-supplied file

hdr.h

Note 11

mpt Custom Storage Class: Exported Data:

ExportTo-File

auto

auto

null

null

null

model.c

model.h

Note 1

ExportTo-File

src

auto

null

null

null

src.c

model.h

Note 1

ExportTo-File

sep

auto

null

null

null

glb.c

model.h

Note 1

ExportTo-File

auto

src

null

null

null

model.c

src.c

Note 8

ExportTo-File

src

src

null

null

null

src.c

src.c

Note 8

ExportTo-File

sep

src

null

null

null

glb.c

src.c

Note 8

ExportTo-File

auto

sep

null

null

null

model.c

glb.h

Note 9

ExportTo-File

src

sep

null

null

null

src.c

glb.h

Note 9

ExportTo-File

sep

sep

null

null

null

glb.c

glb.h

Note 9

ExportTo-File

D/C

D/C

data.c

null

null

data.c

See Note 10.

Note 10

ExportTo-File

D/C

D/C

data.c

null

hdr.h

model.c

hdr.h

Note 11

ExportTo-File

auto

D/C

null

null

hdr.h

src.c

hdr.h

Note 11

ExportTo-File

sep

D/C

null

null

hdr.h

glb.c

hdr.h

Note 11

Simulink Custom Storage Class: Default, Const, ConstVolatile, Volatile:

Default, Const, Const-Volatile, Volatile

auto

auto

N/A

N/A

N/A

model.c

model.h

Note 1

Default, Const, Const-Volatile, Volatile

src

auto

N/A

N/A

N/A

src.c

model.h

Note 1

Default, Const, Const-Volatile, Volatile

sep

auto

N/A

N/A

N/A

glb.c

model.h

Note 1

Default, Const, Const-Volatile, Volatile

auto

src

N/A

N/A

N/A

model.c

src.c

Note 8

Default, Const, Const-Volatile, Volatile

src

src

N/A

N/A

N/A

src.c

src.c

Note 8

Default, Const, Const-Volatile, Volatile

sep

src

N/A

N/A

N/A

glb.c

src.c

Note 8

Default, Const, Const-Volatile, Volatile

auto

sep

N/A

N/A

N/A

model.c

glb.h

Note 9

Default, Const, Const-Volatile, Volatile

src

sep

N/A

N/A

N/A

src.c

glb.h

Note 9

Default, Const, Const-Volatile, Volatile

sep

sep

N/A

N/A

N/A

glb.c

glb.h

Note 9

Simulink Custom Storage Class: Exported Data:

ExportTo-File

auto

auto

N/A

N/A

null

model.c

model.h

Note 1

ExportTo-File

src

auto

N/A

N/A

null

src.c

model.h

Note 1

ExportTo-File

sep

auto

N/A

N/A

null

glb.c

model.h

Note 1

ExportTo-File

auto

src

N/A

N/A

null

model.c

src.c

Note 8

ExportTo-File

src

src

N/A

N/A

null

src.c

src.c

Note 8

ExportTo-File

sep

src

N/A

N/A

null

glb.c

src.c

Note 8

ExportTo-File

auto

sep

N/A

N/A

null

model.c

glb.h

Note 9

ExportTo-File

src

sep

N/A

N/A

null

src.c

glb.h

Note 9

ExportTo-File

sep

sep

N/A

N/A

null

glb.c

glb.h

Note 9

ExportTo-File

auto

D/C

N/A

N/A

hdr.h

model.c

hdr.h

Note 11

ExportTo-File

src

D/C

N/A

N/A

hdr.h

src.c

hdr.h

Note 11

ExportTo-File

sep

D/C

N/A

N/A

hdr.h

glb.c

hdr.h

Note 11

Notes

In the previous table:

Note 1: model.h is included directly in all source files.

Note 2: model_private.h is included directly in all source files.

Note 3: extern is included in model_private.h, which is in source.c.

Note 4: header.h is included in model_private.h, which is in source.c.

Note 5: model.h is included directly in all source files that use #define.

Note 6: header.h is included in model.h, which is in source files that use #define.

Note 7: model.h is included in all source.c files.

Note 8: extern is inlined in source files where data is used.

Note 9: global.h is included in model.h, which is in all source files.

Note 10: When you specify a definition filename for a data object, no header file is generated for that data object. The code generator declares the data object according to the data placement priorities.

Note 11: header.h is included in model.h, which is in all source files.

Note 12: Signal: Either not defined because it is expression folded, or local data, or defined in a structure in model.c, all depending on model's code generation settings. Parameter: Either inlined in the code, or defined in model_data.c.

Note 13: Signal: In a structure that is defined in model.c. Parameter: In a structure that is defined in model_data.c.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS