애플리케이션에 메모리 분석 방식 코드 생성을 사용하거나 사용하지 않으려면 C_CG::Configuration::EnableSegmentedMemory 특성을 사용하십시오.
속성은 다음 특성을 사용하여 특정 메모리 세그먼트에 지정됩니다.
속성 레벨 특성이긴 하지만 이러한 속성을 사용할 수 있는 가장 효율적인 방법은 다음과 같습니다.
다음과 같이 메모리 세그먼트 특성을 사용하십시오.
struct myClass {
uint8 attr1;
...
struct myClass_Seg1 <far> * itsSeg1;
struct myClass_Seg2 <far> * itsSeg2;
...
}
이 코드 샘플에서 <far>는 FarPointerQualifier 특성을 사용하여 지정한 코드로 대체됩니다.MemorySegmentName 특성에 세그먼트 이름을 제공하는 경우, 생성된 코드는 이름이 클래스 이름 및 메모리 세그먼트 이름을 연결하는 새 구조체를 포함합니다. 이 구조체는 이 메모리 세그먼트에 지정된 속성을 모두 포함합니다.
속성은 관련 메모리 세그먼트 구조체에 선언되기 때문에 모델의 주어진 클래스에 정의한 속성이 이러한 다수의 메모리 세그먼트 구조체 간에 분배되는 상황이 발생할 수 있습니다. 모델의 클래스 유형을 나타내기 위해 생성된 구조체는 이러한 속성을 가리키는 포인터를 포함합니다.
#pragma data_seg("ROM")
#pragma data_seg(DEFAULT)
모델의 클래스에 대해 정의된 속성이 생성된 코드에서 서로 다른 메모리 세그먼트 구조체 간에 분배될 수 있으므로 Rational Rhapsody는 데이터가 지정된 메모리 세그먼트를 지정하지 않고 이 데이터에 액세스할 수 있도록 매크로를 제공합니다. 매크로에 사용되는 형식은 C_CG::Attribute::SegmentedAttributeMacroName 특성 값을 통해 결정됩니다.
예를 들어, $class_$attribute 특성의 기본값을 보존하는 경우 생성된 코드는 #define file_0_variable_0 file_0_Seg1.variable_0과 같습니다.
또한 MicroC 프로파일을 사용하여 특정 메모리 세그먼트에 모든 관계 및 플로우 포트를 지정할 수 있습니다.
특정 메모리 세그먼트에 관계 및 플로우 포트를 지정하려면 다음을 수행하십시오.
다음 예제는 메모리 분석 방식 특성에 지정된 값을 Rational Rhapsody가 생성한 코드에 반영시키는 방법을 보여 줍니다.
| 특성 이름 | 특성 값 |
|---|---|
| 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 *********************************************************************/