Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

分散型パイプライン方式: 速度の最適化

この例では、分散型パイプライン方式の最適化を使用して Simulink® 設計を速度に対して最適化する方法を説明します。

はじめに

分散型パイプライン方式は、クリティカル パスを減らし、高クロック速度のハードウェアを実現するために、HDL Coder でサポートされているサブシステム全体の最適化です。分散型パイプライン方式をオンにすると、サブシステムの入力パイプライン レジスタ、出力パイプライン レジスタ、およびサブシステム内のレジスタが、レジスタ間の組み合わせ論理が最小限に抑えられ、生成された HDL コードから合成されるチップのクロック速度が最大限に高まる位置に、HDL Coder によって再分布されます。分散型パイプライン方式の詳細については、分散型パイプライン方式を参照してください。

次の対称 FIR フィルターのモデル例について考えます。入力 (レジスタ) から出力 (別のレジスタ) への組み合わせ論理に、Product ブロックと加算器ツリーが含まれています。分散型パイプライン方式により、サブシステム レベルで設定されている出力レジスタが移動され、組み合わせ論理のレベル数が減ります。

load_system('sfir_fixed');
open_system('sfir_fixed/symmetric_fir');

出力パイプライン ステージの設定

クロック速度を上げるには、任意のサブシステムに対していくつかのパイプライン ステージを設定します。分散型パイプライン方式をオンにしない場合は、指定した数のレジスタがサブシステムの各出力端子に追加されます。一部の合成ツールでは、合成時にレジスタの位置を最適化するリタイミングなどの最適化がサポートされています。

クリティカル パスを減らしてクロック周波数を高める分散型パイプライン方式の効果を確認するには、CriticalPathEstimation を有効にして設計のクリティカル パスを推定します。クリティカル パスの推定を有効にすると、HDL Coder でターゲット固有のタイミング データベースを使用してクリティカル パスが推定されます。合成ツール チップ ファミリと合成ツール速度値を特定のターゲットのタイミング データベースに設定していない場合、HDL Coder で両方のパラメーターの既定値がクリティカル パスの推定用に設定され、HDL コードの生成時に警告が生成されます。この警告を回避するには、合成ツール チップ ファミリと合成ツール速度値を指定します。これは合成ツールの指定とは関係なく実行できます。詳細については、合成実行なしのクリティカル パスの推定を参照してください。

hdlset_param('sfir_fixed', 'CriticalPathEstimation', 'on');
hdlset_param('sfir_fixed', 'SynthesisToolChipFamily', 'virtex7', 'SynthesisToolSpeedValue', '-1')

この例では、サブシステムの出力パイプライン レジスタは 2 に設定されています。

コード生成モデルには、サブシステムの出力端子に挿入されたレジスタが明示的に反映されます (オレンジで強調表示)。

hdlset_param('sfir_fixed/symmetric_fir', 'OutputPipeline', 2);
makehdl('sfir_fixed/symmetric_fir');
open_system('gm_sfir_fixed/symmetric_fir');
set_param('gm_sfir_fixed', 'SimulationCommand', 'update');
### Generating HDL for 'sfir_fixed/symmetric_fir'.
### Using the config set for model <a href="matlab:configset.showParameterGroup('sfir_fixed', { 'HDL Code Generation' } )">sfir_fixed</a> for HDL code generation parameters.
### Running HDL checks on the model 'sfir_fixed'.
### Begin compilation of the model 'sfir_fixed'...
### Working on the model 'sfir_fixed'...
### The code generation and optimization options you have chosen have introduced additional pipeline delays.
### The delay balancing feature has automatically inserted matching delays for compensation.
### The DUT requires an initial pipeline setup latency. Each output port experiences these additional delays.
### Output port 1: 2 cycles.
### Output port 2: 2 cycles.
### Working on... <a href="matlab:configset.internal.open('sfir_fixed', 'GenerateModel')">GenerateModel</a>
### Begin model generation 'gm_sfir_fixed' ....
### Rendering DUT with optimization related changes (IO, Area, Pipelining)...
### Model generation complete.
### Estimated critical path for design: <a href="matlab:run('hdlsrc/sfir_fixed/criticalPathEstimated')">hdlsrc/sfir_fixed/criticalPathEstimated.m</a>
### To clear highlighting, click the following MATLAB script: <a href="matlab:run('hdlsrc/sfir_fixed/clearhighlighting.m')">hdlsrc/sfir_fixed/clearhighlighting.m</a>
### Begin VHDL Code Generation for 'sfir_fixed'.
### Working on sfir_fixed/symmetric_fir as hdlsrc/sfir_fixed/symmetric_fir.vhd.
### Generating package file hdlsrc/sfir_fixed/symmetric_fir_pkg.vhd.
### Code Generation for 'sfir_fixed' completed.
### Generating HTML files for code generation report at <a href="matlab:web('/tmp/Bdoc23b_2395265_1898772/tp4a9a68cc/hdlcoder-ex37495842/hdlsrc/sfir_fixed/html/sfir_fixed_codegen_rpt.html')">sfir_fixed_codegen_rpt.html</a>
### Creating HDL Code Generation Check Report file:///tmp/Bdoc23b_2395265_1898772/tp4a9a68cc/hdlcoder-ex37495842/hdlsrc/sfir_fixed/symmetric_fir_report.html
### HDL check for 'sfir_fixed' complete with 0 errors, 0 warnings, and 1 messages.
### HDL code generation complete.

分散型パイプライン方式を有効化しない場合の推定クリティカル パスは 10.269 ナノ秒です。推定クリティカル パスは、[コード生成レポート]、[タイミングおよび面積レポート]、[クリティカル パスの推定] タブに表示されます。

分散型パイプライン方式の設定

次を入力して、モデルの分散型パイプライン方式を有効にします。

 hdlset_param('sfir_fixed', 'DistributedPipelining', 'on');

指定された生成モデル名を使用して HDL コードを生成し、生成されたモデルを開きます。生成されたモデルには、サブシステム内で分布されたレジスタが明示的に反映されます (オレンジで強調表示)。

makehdl('sfir_fixed/symmetric_fir', 'GeneratedModelNamePrefix', 'gm2_');
open_system('gm2_sfir_fixed/symmetric_fir');
set_param('gm2_sfir_fixed', 'SimulationCommand', 'update');
### Generating HDL for 'sfir_fixed/symmetric_fir'.
### Using the config set for model <a href="matlab:configset.showParameterGroup('sfir_fixed', { 'HDL Code Generation' } )">sfir_fixed</a> for HDL code generation parameters.
### Running HDL checks on the model 'sfir_fixed'.
### Begin compilation of the model 'sfir_fixed'...
### Working on the model 'sfir_fixed'...
### The code generation and optimization options you have chosen have introduced additional pipeline delays.
### The delay balancing feature has automatically inserted matching delays for compensation.
### The DUT requires an initial pipeline setup latency. Each output port experiences these additional delays.
### Output port 1: 2 cycles.
### Output port 2: 2 cycles.
### Working on... <a href="matlab:configset.internal.open('sfir_fixed', 'GenerateModel')">GenerateModel</a>
### Begin model generation 'gm2_sfir_fixed' ....
### Rendering DUT with optimization related changes (IO, Area, Pipelining)...
### Model generation complete.
### Estimated critical path for design: <a href="matlab:run('hdlsrc/sfir_fixed/criticalPathEstimated')">hdlsrc/sfir_fixed/criticalPathEstimated.m</a>
### To clear highlighting, click the following MATLAB script: <a href="matlab:run('hdlsrc/sfir_fixed/clearhighlighting.m')">hdlsrc/sfir_fixed/clearhighlighting.m</a>
### Begin VHDL Code Generation for 'sfir_fixed'.
### Working on sfir_fixed/symmetric_fir as hdlsrc/sfir_fixed/symmetric_fir.vhd.
### Generating package file hdlsrc/sfir_fixed/symmetric_fir_pkg.vhd.
### Code Generation for 'sfir_fixed' completed.
### Generating HTML files for code generation report at <a href="matlab:web('/tmp/Bdoc23b_2395265_1898772/tp4a9a68cc/hdlcoder-ex37495842/hdlsrc/sfir_fixed/html/sfir_fixed_codegen_rpt.html')">sfir_fixed_codegen_rpt.html</a>
### Creating HDL Code Generation Check Report file:///tmp/Bdoc23b_2395265_1898772/tp4a9a68cc/hdlcoder-ex37495842/hdlsrc/sfir_fixed/symmetric_fir_report.html
### HDL check for 'sfir_fixed' complete with 0 errors, 0 warnings, and 1 messages.
### HDL code generation complete.

分散型パイプライン方式を使用した場合の推定クリティカル パスは 7.443 ナノ秒になります。

分散型パイプライン方式での合成タイミング推定の使用

ハードウェアに対するコンポーネントの機能をより正確に反映することで、設計における分散型パイプラインの精度を高めてターゲット デバイスのクロック周波数を最大化するには、モデル コンフィギュレーション パラメーター [分散型パイプラインに合成推定値を使用] またはコマンド ラインを使用して分散型パイプライン方式の合成タイミング推定を有効にします。

hdlset_param('sfir_fixed', 'UseSynthesisEstimatesForDistributedPipelining', 'on');

指定された生成モデル名を使用して HDL コードを生成し、生成されたモデルを開きます。

makehdl('sfir_fixed/symmetric_fir', 'GeneratedModelNamePrefix', 'gm3_');
open_system('gm3_sfir_fixed/symmetric_fir');
set_param('gm3_sfir_fixed', 'SimulationCommand', 'update');
### Generating HDL for 'sfir_fixed/symmetric_fir'.
### Using the config set for model <a href="matlab:configset.showParameterGroup('sfir_fixed', { 'HDL Code Generation' } )">sfir_fixed</a> for HDL code generation parameters.
### Running HDL checks on the model 'sfir_fixed'.
### Begin compilation of the model 'sfir_fixed'...
### Working on the model 'sfir_fixed'...
### The code generation and optimization options you have chosen have introduced additional pipeline delays.
### The delay balancing feature has automatically inserted matching delays for compensation.
### The DUT requires an initial pipeline setup latency. Each output port experiences these additional delays.
### Output port 1: 2 cycles.
### Output port 2: 2 cycles.
### Working on... <a href="matlab:configset.internal.open('sfir_fixed', 'GenerateModel')">GenerateModel</a>
### Begin model generation 'gm3_sfir_fixed' ....
### Rendering DUT with optimization related changes (IO, Area, Pipelining)...
### Model generation complete.
### Estimated critical path for design: <a href="matlab:run('hdlsrc/sfir_fixed/criticalPathEstimated')">hdlsrc/sfir_fixed/criticalPathEstimated.m</a>
### To clear highlighting, click the following MATLAB script: <a href="matlab:run('hdlsrc/sfir_fixed/clearhighlighting.m')">hdlsrc/sfir_fixed/clearhighlighting.m</a>
### Begin VHDL Code Generation for 'sfir_fixed'.
### Working on sfir_fixed/symmetric_fir as hdlsrc/sfir_fixed/symmetric_fir.vhd.
### Generating package file hdlsrc/sfir_fixed/symmetric_fir_pkg.vhd.
### Code Generation for 'sfir_fixed' completed.
### Generating HTML files for code generation report at <a href="matlab:web('/tmp/Bdoc23b_2395265_1898772/tp4a9a68cc/hdlcoder-ex37495842/hdlsrc/sfir_fixed/html/sfir_fixed_codegen_rpt.html')">sfir_fixed_codegen_rpt.html</a>
### Creating HDL Code Generation Check Report file:///tmp/Bdoc23b_2395265_1898772/tp4a9a68cc/hdlcoder-ex37495842/hdlsrc/sfir_fixed/symmetric_fir_report.html
### HDL check for 'sfir_fixed' complete with 0 errors, 0 warnings, and 1 messages.
### HDL code generation complete.

合成タイミング推定を使用すると、関数 makehdl の実行時間は長くなりますが、クリティカル パスを減らして設計のクロック周波数を高めることができます。詳細については、Distributed Pipelining Using Synthesis Timing Estimatesを参照してください。

クリティカル パスの推定レポートに表示されるクリティカル パスが 6.320 ナノ秒になります。クリティカル パスの推定は、ターゲット固有のタイミング データベースに基づくクリティカル パスの推定値にすぎません。ターゲット ハードウェアにおける実際のクリティカル パスが必要な場合は、合成を通じてモデルを実行する必要があります。

合成タイミング推定を使用した場合と使用しない場合の分散型パイプライン方式による合成の比較

HDL ワークフロー アドバイザーで、HDL コードを生成し、汎用 ASIC/FPGA ワークフローで次のように設定して FPGA 合成を実行します。

  • [合成ツール]Xilinx Vivado に設定

  • 合成ツールの [ファミリ]virtex7 に設定

  • 合成ツールの [速度]-1 に設定

  • [ターゲット周波数 (MHz)]120 に設定

コード生成と合成の手順の詳細については、Simulink モデルからの HDL コード生成と FPGA 合成を参照してください。

分散型パイプライン方式を有効にしていない場合の合成結果は次のようになります。

合成結果に、タイミング制約を満たしていないことを示す負のスラックが示されます。タイミング制約を満たしていない場合、クロック周波数は計算されません。

分散型パイプライン方式を有効にした場合の合成結果は次のようになります。

合成結果に、タイミング制約を満たしていることを示す正のスラックが示されます。また、クロック周波数は 178.05 MHz で、ターゲット クロック周波数の 120 MHz を満たしています。

分散型パイプライン方式で合成タイミング推定を使用した場合の合成結果は次のようになります。

合成結果に、クロック周波数が 222.40 MHz と表示され、タイミング制約を満たしていることが示されます。分散型パイプライン方式で合成タイミング推定を使用することでクロック速度が向上しています。

サブシステムの階層全体への分散型パイプライン方式の適用

DUT サブシステムにサブシステム階層がある場合、つまり下位レベルのサブシステムが含まれている場合は、モデル パラメーター [分散型パイプライン]on に設定して、DUT 全体で分散型パイプライン方式を実行します。DUT および DUT 内の各サブシステムに対して DistributedPipelining を有効にする必要はありません。サブシステムの HDL ブロック プロパティ [DistributedPipelining] は既定で inherit に設定されています。これは、各サブシステムがその親サブシステムの [DistributedPipelining] の値を取ることを意味します。最上位 DUT サブシステムは、モデル パラメーター [分散型パイプライン] で指定された値を取ります。

サブシステムの HDL ブロック プロパティ [DistributedPipelining]On または Off に設定すると、下位レベルのサブシステムの分散型パイプライン方式を具体的に有効または無効にすることができます。詳細については、DistributedPipeliningを参照してください。

関連する例

詳細