コード置換ライブラリの登録
登録ファイルにライブラリ名、コード置換テーブル、およびその他の情報を定義して、コード置換ライブラリを作成します。ライブラリを定義して登録すると、そのライブラリはコード ジェネレーターでコード置換のために使用できるようになります。
登録ファイルの対話的な開発と読み込み
コード置換ツールで、[登録ファイルの作成] をクリックします。

[登録ファイルの作成] ダイアログ ボックスで、登録情報を指定します。次に、[OK] をクリックします。
パラメーター 説明 レジストリ名 (必須) コード置換ライブラリ名。 テーブル リスト (必須) ライブラリに含める 1 つ以上のコード置換テーブルのコンマ区切りリスト。テーブルを指定するには、その名前 (MATLAB 検索パス上にある場合)、絶対パス、または相対パスのいずれかを使用します。ライブラリの登録では、名前空間ディレクトリ内のテーブルはサポートされません。 基本 CRL ライブラリ階層を指定できます。現在登録しているライブラリのベースにする登録済みライブラリの名前を指定します。たとえば、TI デバイス ライブラリを TI C28x ライブラリのベースにすることができます。 ターゲット HW デバイス このライブラリでサポートされている 1 つ以上のハードウェア デバイスのコンマ区切りリスト。すべてのデバイスのサポートを示すには、アスタリスク (*) を指定します。 説明 ライブラリの目的と内容に関する説明。 データ配置の仕様の生成 データ配置を有効にするフラグ。 登録されたコード置換ライブラリを使用するには、現在の MATLAB セッションを次のコマンドで更新します。
sl_refresh_customizations
プログラムによる登録ファイルの開発と読み込み
MATLAB 関数ファイルを開きます。MATLAB メニューから、[新規]、[関数] を選択します。
関数ファイルを
rtwTargetInfo.mという名前で保存します。ファイルに次のコードをコピーして貼り付け、テンプレートとして使用します。
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
テンプレートで、次の登録情報を指定します。
パラメーター 説明 レジストリ名 (必須) コード置換ライブラリ名。 テーブル リスト (必須) ライブラリに含める 1 つ以上のコード置換テーブルのコンマ区切りリスト。テーブルを指定するには、その名前 (MATLAB 検索パス上にある場合)、絶対パス、または相対パスのいずれかを使用します。ライブラリの登録では、パッケージ ディレクトリ内のテーブルはサポートされません。 基本 CRL ライブラリ階層を指定できます。現在登録しているライブラリのベースにする登録済みライブラリの名前を指定します。たとえば、TI デバイス ライブラリを TI C28x ライブラリのベースにすることができます。 ターゲット HW デバイス このライブラリでサポートされている 1 つ以上のハードウェア デバイスのコンマ区切りリスト。すべてのデバイスのサポートを示すには、アスタリスク (*) を指定します。 説明 ライブラリの目的と内容に関する説明。 データ配置の仕様の生成 データ配置を有効にするフラグ。 ファイルを MATLAB パス上に保存します。
登録されたコード置換ライブラリを使用するには、現在の 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
複数のコード置換ライブラリの登録. このセクションのモデルは、コード置換ライブラリの開発と使用による生成コードの最適化 - Simulinkの例に属しています。
function rtwTargetInfo(cm) cm.registerTargetInfo(@loc_register_crl); end function thisCRL = loc_register_crl % Register a code replacement library for use with model: CRLAdditionSubtraction 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: CRLMultiplicationDivision 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: CRLFixedPointOperators thisCrl(3) = RTW.TflRegistry; thisCrl(3).Name = 'Fixed-Point Examples'; thisCrl(3).Description = 'Example of fixed-point operator replacement'; thisCrl(3).TableList = {fullfile('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