주요 콘텐츠

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

불변 신호 인라인 처리

생성된 코드에서 불변 신호의 기호 이름을 변환

모델 구성 창: 코드 생성 / 최적화

설명

불변 신호 인라인 처리 파라미터는 코드 생성기가 불변 신호의 기호 이름을 상수 값으로 변환하도록 지시합니다.

불변 신호란 Simulink® 시뮬레이션 동안 변하지 않는 블록 출력 신호를 말합니다. 예를 들어, 다음 모델에서 신호 S3는 불변 신호입니다. 불변 신호불변 상수와 같지 않습니다. 두 상수(1과 2)와 이득 값 3은 불변 상수입니다. 불변 상수를 인라인으로 처리하려면 디폴트 파라미터 동작인라인로 설정하십시오.

Model containing two constant blocks that feed into a Sum block. The Sum block output feeds into a gain block, whose output is the signal s3.

범주: 최적화

종속성

디폴트 파라미터 동작인라인로 설정하면 이 파라미터가 활성화됩니다.

설정

off (디폴트 값) | on
켜짐

Simulink Coder™ 소프트웨어는 생성된 코드에서 모델 파라미터의 기호 이름 대신 숫자형 값을 사용합니다. 불변 신호는 스칼라가 아니거나 복소수이거나, 해당 신호가 연결된 블록 인포트가 신호의 주소를 참조하는 경우 인라인이 아닙니다.

꺼짐

생성된 코드에서 모델 파라미터의 기호 이름을 사용합니다.

예제

모두 확장

이 예제는 인라인 불변 신호를 사용하여 생성된 코드를 최적화하는 방법을 보여줍니다. 이 최적화는 불변 신호의 기호 이름을 상수 값으로 변환합니다.

InlineInvariantSignals 최적화:

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

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

예제 모델

InvariantSignalsInline 모델을 살펴봅니다.

model = 'InvariantSignalsInline';
open_system(model);

코드 생성

Simulink® Coder™를 사용하여 모델을 빌드합니다.

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

Build Summary

Top model targets:

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

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

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

cfile = fullfile('InvariantSignalsInline_grt_rtw',...
    'InvariantSignalsInline.c');
coder.example.extractLines(cfile,'/* Output and update for atomic system',...
    '/* Model output', 1, 0);
/* Output and update for atomic system: '<Root>/InlinedConstFcn' */
void InvariantSignal_InlinedConstFcn(int32_T rtu_In1,
  B_InlinedConstFcn_InvariantSi_T *localB, const ConstB_InlinedConstFcn_Invari_T
  *localC)
{
  /* Product: '<S1>/Product' */
  localB->Product = rtu_In1 * localC->Sum_p;
}

최적화 활성화

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

  2. 최적화 창에서 불변 신호 인라인 처리를 선택합니다.

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

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

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

생성된 코드는 별도의 구조체를 생성하는 대신, 접힌 상수의 숫자형 값을 사용합니다.

Simulink Coder를 사용하여 모델을 빌드합니다.

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

Build Summary

Top model targets:

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

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

InvariantSignalsInline.c에서 최적화를 적용하여 생성된 코드를 확인합니다.

coder.example.extractLines(cfile,...
    '/* Output and update for atomic system', '/* Model output', 1, 0);
/* Output and update for atomic system: '<Root>/InlinedConstFcn' */
void InvariantSignal_InlinedConstFcn(int32_T rtu_In1,
  B_InlinedConstFcn_InvariantSi_T *localB)
{
  /* Product: '<S1>/Product' */
  localB->Product = rtu_In1 << 5;
}

모델 및 코드 생성 리포트를 닫습니다.

bdclose(model)

권장 설정

응용 사례설정
디버그Off
추적성Off
효율성On
안전 예방 조치영향 없음

프로그래밍 방식 사용

파라미터: InlineInvariantSignals
유형: 문자형 벡터
값: 'on' | 'off'
디폴트 값: 'off'

버전 내역

R2006a 이전에 개발됨