주요 콘텐츠

이 페이지는 기계 번역을 사용하여 번역되었습니다. 영어 원문을 보려면 여기를 클릭하십시오.

논리 신호에 대한 부울 데이터를 사용하여 생성된 코드 최적화

논리 신호를 부울 데이터로 저장하여 생성된 코드를 최적화합니다. 논리 신호를 부울 데이터로 구현(double 대신) 모델 파라미터를 선택하면, 논리 신호를 생성하는 블록은 부울 신호를 출력합니다.

최적화:

  • ROM 및 RAM 사용량을 줄입니다.

  • 실행 속도를 향상시킵니다.

예제 모델

LogicalAsBoolean 모델을 고려해 보자. Relational Operator, Logical OperatorHitCrossing 블록의 출력은 논리 데이터를 나타내지만, 모두 double입니다.

model = 'LogicalAsBoolean';
open_system(model);

코드 생성

모델을 빌드합니다.

slbuild(model)
### Searching for referenced models in model 'LogicalAsBoolean'.
### Total of 1 models to build.
### Starting build procedure for: LogicalAsBoolean
### Successful completion of build procedure for: LogicalAsBoolean

Build Summary

Top model targets:

Model             Build Reason                                         Status                        Build Duration
===================================================================================================================
LogicalAsBoolean  Information cache folder or artifacts were missing.  Code generated and compiled.  0h 0m 12.91s

1 of 1 models built (0 models already up to date)
Build duration: 0h 0m 14.866s

최적화가 적용되지 않은 생성된 코드를 확인합니다. 이 코드 라인들은 LogicalAsBoolean.h에 있습니다.

hfile = fullfile('LogicalAsBoolean_grt_rtw',...
    'LogicalAsBoolean.h');
coder.example.extractLines(hfile,'/* External outputs','/* Parameters (default storage) */',1,0);
/* External outputs (root outports fed by signals with default storage) */
typedef struct {
  real_T Out1;                         /* '<Root>/Out1' */
  real_T Out2;                         /* '<Root>/Out2' */
  real_T Out3;                         /* '<Root>/Out3' */
} ExtY_LogicalAsBoolean_T;

최적화 활성화

  1. 구성 파라미터 대화 상자를 엽니다.

  2. 논리 신호를 부울 데이터로 구현(double 대신) 파라미터를 선택하십시오.

또는 명령줄 API를 사용하여 최적화를 활성화할 수도 있습니다:

set_param(model,'BooleanDataType','on');

최적화를 적용하여 코드 생성

생성된 코드는 논리 신호 출력을 부울 데이터로 저장합니다.

모델을 빌드합니다.

slbuild(model)
### Searching for referenced models in model 'LogicalAsBoolean'.
### Total of 1 models to build.
### Starting build procedure for: LogicalAsBoolean
### Successful completion of build procedure for: LogicalAsBoolean

Build Summary

Top model targets:

Model             Build Reason                     Status                        Build Duration
===============================================================================================
LogicalAsBoolean  Generated code was out of date.  Code generated and compiled.  0h 0m 5.3721s

1 of 1 models built (0 models already up to date)
Build duration: 0h 0m 5.9906s

최적화가 적용된 생성된 코드를 확인합니다. 이 코드 라인들은 LogicalAsBoolean.h에 있습니다.

coder.example.extractLines(hfile,'/* External outputs','/* Parameters (default storage) */',1,0);
/* External outputs (root outports fed by signals with default storage) */
typedef struct {
  boolean_T Out1;                      /* '<Root>/Out1' */
  boolean_T Out2;                      /* '<Root>/Out2' */
  boolean_T Out3;                      /* '<Root>/Out3' */
} ExtY_LogicalAsBoolean_T;

모델 및 코드 생성 리포트를 닫으십시오.

bdclose(model)

참고 항목

도움말 항목