メインコンテンツ

coder.float2fixed.skip

関数を固定小数点変換の対象から除外

R2024b 以降

    説明

    coder.float2fixed.skip({'fcn'}) は、codegen (MATLAB Coder)またはfiaccel-float2fixed オプションを使用するときや HDL Coder™ ワークフロー アドバイザーを使用するときに、関数 fcn を固定小数点変換の対象から除外します。

    coder.float2fixed.skip は、固定小数点入力をサポートしない関数を含む設計、あるいは固定小数点に変換する必要がないカスタムの浮動小数点または固定小数点の関数を含む設計に使用します。

    すべて折りたたむ

    サポートされていない構造体を含む固定小数点変換の設計を選択します。この例では、以下に示す skipFcn という設計を使用します。

    function out = skipFcn(inp)
    out = localFcn(inp);
    end
    
    
    function y = localFcn(u)
    y = 2*exp(u);
    end
    

    skipFcn 設計で、固定小数点データ型をサポートしない MATLAB® 関数 exp が呼び出されています。exp を固定小数点変換の対象から除外するには、coder.float2fixed.skip の呼び出しを追加します。除外する関数として、exp の呼び出しを含む localFcn を指定します。

    function out = skipFcn(inp)
    coder.float2fixed.skip({'localFcn'});
    out = localFcn(inp);
    end
    
    
    function y = localFcn(u)
    y = 2*exp(u);
    end
    

    固定小数点コードを生成するには、coder.FixPtConfig オブジェクト fixptcfg を既定の設定で作成します。

    fixptcfg = coder.config("fixpt");

    テスト ベンチを指定します。この例で使用しているテスト ベンチは skipFcn_tb です。

    fixptcfg.TestBenchName = 'skipFcn_tb';

    固定小数点コードを生成します。

    codegen -float2fixed fixptcfg skipFcn
    ===================================================
    Design Name: skipFcn
    Test Bench Name: skipFcn_tb
    ===================================================
    
    Input types not specified for design(s) 'skipFcn', inferring types by simulating the first test bench: 'skipFcn_tb' in the base workspace.
    
    ============= Step1: Analyze floating-point code ==============
    
    Code generation successful.
    
    
    
    ============= Step1a: Verify Floating Point ==============
    
    ### Analyzing the design 'skipFcn'
    ### Analyzing the test bench(es) 'skipFcn_tb'
    ### Begin Floating Point Simulation (Instrumented)
    ### Floating Point Simulation Completed in   1.6164 sec(s)
    ### Elapsed Time:             2.2562 sec(s)
    
    ============= Step2: Propose Types based on Range Information ==============
    
    
    ============= Step3: Generate Fixed Point Code ==============
    
    ### Generating Fixed Point MATLAB Code skipFcn_fixpt using Proposed Types
    ### Generating Fixed Point MATLAB Design Wrapper skipFcn_wrapper_fixpt
    ### Generating Mex file for ' skipFcn_wrapper_fixpt '
    Code generation successful: View report
    ### Generating Type Proposal Report for 'skipFcn' skipFcn_report.html
    
    ===================================================
    Code generation successful.
    

    コード生成出力で View report をクリックしてコード生成レポート ビューアーを開きます。

    左側にある [MATLAB ソース] の関数リストから skipFcn_fixpt を選択し、生成された固定小数点コードを確認します。localFcn をポイントして式の情報を確認します。クラスが double になっていることに注意してください。この関数は localFcn の出力を固定小数点に変換して固定小数点出力を返します。

    The Code Generation Report Viewer displays the generated code. The function output of skipFcn is highlighted, showing that the input to localFcn is converted to double precision. The output of localFcn is then converted to fi inside of skipFcn.

    入力引数

    すべて折りたたむ

    固定小数点変換の対象から除外する関数の名前。cell 配列として指定します。複数の関数を指定できます。

    例: coder.float2fixed.skip({'fcn1','fcn2'})

    データ型: cell

    バージョン履歴

    R2024b で導入