Main Content

このページの翻訳は最新ではありません。ここをクリックして、英語の最新版を参照してください。

コード置換ライブラリの登録

登録ファイルでライブラリ名、コード置換テーブル、その他の情報を定義することにより、コード置換ライブラリを作成します。定義して登録したライブラリは、コード ジェネレーターでコード置換に使用できるようになります。

登録ファイルの対話的な開発と読み込み

  1. crtool で、[ファイル][登録ファイルの生成] を選択します。

  2. [登録ファイルの作成] ダイアログ ボックスで、登録情報を指定します。[OK] をクリックします。

    パラメーター説明
    レジストリ名 (必須)コード置換ライブラリ名。
    テーブル リスト (必須) ライブラリに必要な 1 つ以上のコード置換テーブルのコンマ区切りリスト。テーブルの指定には、その名前 (MATLAB 検索パス上にある場合)、絶対パス、または相対パスを使用します。
    基本 CRLライブラリ階層を指定できます。現在登録しているライブラリのベースとして機能する登録済みライブラリの名前を指定します。たとえば、TI デバイス ライブラリを TI C28x ライブラリのベースにすることができます。
    ターゲット HW デバイスこのライブラリでサポートされる 1 つ以上のハードウェア デバイスのコンマ区切りリスト。すべてのデバイスのサポートを示すにはアスタリスク (*) を使用します。
    説明ライブラリの目的と内容の説明。
    データ配置の仕様の生成 データ配置を有効にするフラグ。
  3. 登録済みのコード置換ライブラリを使用するには、現在の MATLAB セッションを次のコマンドで更新します。

    >> sl_refresh_customizations

登録ファイルのプログラムによる開発と読み込み

  1. MATLAB 関数ファイルを開きます。[MATLAB] メニューから、[新規][関数] を選択します。

  2. 関数ファイルを rtwTargetInfo.m という名前で保存します。

  3. 次のコードをコピーして、テンプレートとして使用するファイルに貼り付けます。

    function rtwTargetInfo(cm)
     
    cm.registerTargetInfo(@loc_register_crl);
    end
     
    function this = loc_register_crl 
     
    this(1) = RTW.TflRegistry; %instantiates a registration entry
    this(1).Name = 'Example Code Replacement Library';
    this(1).TableList = {'example_code_replacement_table.m'};
    this(1).TargetHWDeviceType = {'*'};
    this(1).Description = 'This registers an example library';
    
    end
    
  4. テンプレートで、以下の登録情報を指定します。

    パラメーター説明
    レジストリ名 (必須)コード置換ライブラリ名。
    テーブル リスト (必須) ライブラリに必要な 1 つ以上のコード置換テーブルのコンマ区切りリスト。テーブルの指定には、その名前 (MATLAB 検索パス上にある場合)、絶対パス、または相対パスを使用します。
    基本 CRLライブラリ階層を指定できます。現在登録しているライブラリのベースとして機能する登録済みライブラリの名前を指定します。たとえば、TI デバイス ライブラリを TI C28x ライブラリのベースにすることができます。
    ターゲット HW デバイスこのライブラリでサポートされる 1 つ以上のハードウェア デバイスのコンマ区切りリスト。すべてのデバイスのサポートを示すにはアスタリスク (*) を使用します。
    説明ライブラリの目的と内容の説明。
    データ配置の仕様の生成 データ配置を有効にするフラグ。
  5. ファイルを MATLAB パス上に保存します。

  6. 登録済みのコード置換ライブラリを使用するには、現在の MATLAB セッションを次のコマンドで更新します。

    >> sl_refresh_customizations

1 つのコード置換ライブラリの登録

function rtwTargetInfo(cm)
 
cm.registerTargetInfo(@loc_register_crl);
end
 
function this = loc_register_crl 
 
this(1) = RTW.TflRegistry; %instantiates a registration entry
this(1).Name = 'Example Code Replacement Library';
this(1).TableList = {'example_code_replacement_table.m'};
this(1).TargetHWDeviceType = {'*'};
this(1).Description = 'This registers an example library';

end

複数のコード置換ライブラリの登録

function rtwTargetInfo(cm)
cm.registerTargetInfo(@loc_register_crl);
end

function thisCRL = loc_register_crl
  % Register a code replacement library for use with model: rtwdemo_crladdsub
  thisCrl(1) = RTW.TflRegistry;
  thisCrl(1).Name = 'Addition & Subtraction Examples';
  thisCrl(1).Description = 'Example of addition/subtraction op replacement';
  thisCrl(1).TableList = {'crl_table_addsub'};
  thisCrl(1).TargetHWDeviceType = {'*'};

  % Register a code replacement library for use with model: rtwdemo_crlmuldiv
  thisCrl(2) = RTW.TflRegistry;
  thisCrl(2).Name = 'Multiplication & Division Examples';
  thisCrl(2).Description = 'Example of mult/div op repl for built-in integers';
  thisCrl(2).TableList = {'c:/work_crl/crl_table_muldiv'};
  thisCrl(2).TargetHWDeviceType = {'*'};

  % Register a code replacement library for use with model: rtwdemo_crlfixpt
  thisCrl(3) = RTW.TflRegistry;
  thisCrl(3).Name = 'Fixed-Point Examples';
  thisCrl(3).Description = 'Example of fixed-point operator replacement';
  thisCrl(3).TableList = {fullfile('$(MATLAB_ROOT)', ...
     'toolbox','rtw','rtwdemos','crl_demo','crl_table_fixpt')};
   thisCrl(3).TargetHWDeviceType = {'*'};

end

コード置換階層の登録

function rtwTargetInfo(cm)
 
cm.registerTargetInfo(@loc_register_crl);
end
 
function thisCRL = loc_register_crl 
  % Register a code replacement library that includes common entries
  thisCrl(1) = RTW.TflRegistry;
  thisCrl(1).Name = 'Common Replacements';
  thisCrl(1).Description = 'Common code replacement entries shared by other libraries';
  thisCrl(1).TableList = {'crl_table_general'};
  thisCrl(1).TargetHWDeviceType = {'*'};
 
  % Register a code replacement library for TI devices
  thisCrl(2) = RTW.TflRegistry;
  thisCrl(2).Name = 'TI Device Replacements';
  thisCrl(2).Description = 'Code replacement entries shared across TI devices';
  thisCrl(2).TableList = {'crl_table_TI_devices'};
  thisCrl(2).TargetHWDeviceType = {'TI C28x', 'TI C55x', 'TI C62x', 'TI C64x', 'TI 67x'};
  thisCrl(1).BaseTfl = 'Common Replacements'
 
  % Register a code replacement library for TI c6xx devices
  thisCrl(3) = RTW.TflRegistry;
  thisCrl(3).Name = 'TI c6xx Device Replacements';
  thisCrl(3).Description = 'Code replacement entries shared across TI C6xx devices';
  thisCrl(3).TableList = {'crl_table_TIC6xx_devices'};
  thisCrl(3).TargetHWDeviceType = {'TI C62x', 'TI C64x', 'TI 67x'};
 
  % Register a code replacement library for the TI c67x device
  thisCrl(4) = RTW.TflRegistry;
  thisCrl(4).Name = 'TI c67x Device Replacements';
  thisCrl(4).Description = 'Code replacement entries for the TI C67x device';
  thisCrl(4).TableList = {'crl_table_TIC67x_device'};
  thisCrl(4).TargetHWDeviceType = {'TI 67x'};

 
end

関連するトピック