Use the C_CG::Configuration::EnableSegmentedMemory property to enable or disable the generation of memory segmentation code for your application.
Attributes are assigned to specific memory segments using the following properties:
Although they are attribute-level properties, the most efficient way to use these properties is as follows:
Use the memory segment properties as follows:
struct myClass {
uint8 attr1;
...
struct myClass_Seg1 <far> * itsSeg1;
struct myClass_Seg2 <far> * itsSeg2;
...
}
In this code sample, <far> would
be replaced by whatever code you specified using the FarPointerQualifier property.When you provide a segment name for the MemorySegmentName property, the generated code includes a new struct whose name concatenates the class name and the name of the memory segment. This struct contains all the attributes that have been assigned to this memory segment.
Since attributes will be declared in the relevant memory segment struct, you might have a situation where the attributes you defined in a given class in your model end up distributed among a number of these memory segment structs. The struct generated to represent the type of the class in your model will include pointers to these attributes.
#pragma data_seg("ROM")
#pragma data_seg(DEFAULT)
Because the attributes defined for a class in your model might end up distributed among different memory segment structs in the generated code, Rational Rhapsody provides macros for accessing this data without having to specify the memory segment it is assigned to. The format used for the macros is determined by the value of the C_CG::Attribute::SegmentedAttributeMacroName property.
For example, if you keep the default value of the property, $class_$attribute, the code generated will resemble: #define file_0_variable_0 file_0_Seg1.variable_0
In addition, with the MicroC profile you can assign all relations and flow ports to a specific memory segment.
To assign relations and flow ports to a specific memory segment:
This example shows how the values specified for the memory segmentation properties are reflected in the code that is generated by Rational Rhapsody.
| Property name | Property value |
|---|---|
| C_CG::Configuration::DefaultROMSegmentName | ROM |
| C_CG::Configuration::FarPointerQualifier | far |
| for first segment (stereotype applied to variable_0 in file_0 model): | |
| C_CG::Attribute::MemorySegmentName | Seg1 |
| C_CG::Attribute::MemorySegmentSpecificationProlog | #pragma DATA_SEG $seg |
| C_CG::Attribute::MemorySegmentSpecificationEpilog | #pragma DATA_SEG DEFAULT |
| C_CG::Attribute::MemorySegmentImplementationProlog | #pragma DATA_SEG $seg |
| C_CG:Attribute:MemorySegmentImplementationEpilog | #pragma DATA_SEG DEFAULT |
| C_CG::Attribute::SegmentedAttributeMacroName | $class_$attribute |
| for second segment (stereotype applied to variable_1 in file_0 in model): | |
| C_CG::Attribute::MemorySegmentName | Seg2 |
| C_CG::Attribute::MemorySegmentSpecificationProlog | #pragma DATA_SEG "$seg" |
| C_CG::Attribute::MemorySegmentSpecificationEpilog | #pragma DATA_SEG DEFAULT |
| C_CG::Attribute::MemorySegmentImplementationProlog | #pragma DATA_SEG "$seg" |
| C_CG:Attribute:MemorySegmentImplementationEpilog | #pragma DATA_SEG DEFAULT |
| C_CG::Attribute::SegmentedAttributeMacroName | $class_$attribute |
#ifndef file_0_H
#define file_0_H
/*## auto_generated */
#include "mxf\Ric.h"
/*## auto_generated */
#include "Default.h"
/*## package Default */
/*## class TopLevel::file_0 */
/*#[ ignore */
typedef struct file_0_Seg1_t {
int variable_0; /*## attribute variable_0 */
} file_0_Seg1_t;
#define file_0_variable_0 file_0_Seg1.variable_0
typedef struct file_0_Seg2_t {
int variable_1; /*## attribute variable_1 */
} file_0_Seg2_t;
#define file_0_variable_1 file_0_Seg2.variable_1
/*#[ ignore */
#pragma DATA_SEG Seg1
/*#]*/
extern struct file_0_Seg1_t file_0_Seg1;
/*#[ ignore */
#pragma DATA_SEG DEFAULT
/*#]*/
/*#[ ignore */
#pragma DATA_SEG "Seg2"
/*#]*/
extern struct file_0_Seg2_t file_0_Seg2;
/*#[ ignore */
#pragma DATA_SEG DEFAULT
/*#]*/
/*#]*/
/*** User explicit entries ***/
#endif
/******************************************************************
File Path : DefaultComponent\DefaultConfig\file_0.h
*****************************************************************/
/*## auto_generated */ #include "file_0.h" /*## package Default */ /*## class TopLevel::file_0 */ /*#[ ignore */ /*#[ ignore */ #pragma DATA_SEG Seg1 /*#]*/ struct file_0_Seg1_t file_0_Seg1; /*#[ ignore */ #pragma DATA_SEG DEFAULT /*#]*/ #pragma DATA_SEG "Seg2"struct file_0_Seg2_t file_0_Seg2; /*#[ ignore */ #pragma DATA_SEG DEFAULT /*#]*/ /*#]*/ /********************************************************************* File Path : DefaultComponent\DefaultConfig\file_0.c *********************************************************************/