Main Content

スクリプトを使用した HDL ワークフローの実行

HDL ワークフロー アドバイザーは、次のような Simulink® サブシステムの HDL コードを生成する各段階と、FPGA 設計プロセスをサポートします。

  • モデルに HDL コード生成との互換性があるか確認し、非互換設定を自動的に修正。

  • HDL コード、テスト ベンチ、コードとテスト ベンチをビルドして実行するスクリプトの生成。

  • コシミュレーションまたは SystemVerilog DPI テスト ベンチ、コード カバレッジの生成 (HDL Verifier™ が必要)。

  • サードパーティ製の合成ツールとの統合による合成とタイミング解析。

  • 合成時に取得したクリティカル パスなどの情報によるモデルのバックアノテーション。

  • FPGA インザループ シミュレーション (HDL Verifier が必要) を含む、選択した FPGA 開発ターゲット デバイスと Simulink Real-Time™ FPGA I/O ワークフローに対する完全な自動ワークフロー。

HDL ワークフロー アドバイザーは Simulink Online™ では使用できません。

HDL ワークフローをコマンド ライン スクリプトとして実行するには、Simulink 設計により HDL ワークフロー アドバイザーを構成し、実行してからスクリプトをエクスポートします。このスクリプトは HDL ワークフロー CLI コマンドを使用して、FPGA ビットストリームまたは合成プロジェクトの生成を含む、HDL ワークフロー アドバイザーと同じタスクを実行します。

次のターゲット ワークフロー向けの HDL ワークフロー スクリプトをエクスポートできます。

  • Generic ASIC/FPGA

  • [FPGA-in-the-Loop] (HDL Verifier ライセンスが必要)

  • IP コアの生成

  • [Simulink Real-Time FPGA I/O] (Simulink Real-Time が必要)

既存のスクリプトを更新するには、それを HDL ワークフロー アドバイザーにインポートして、タスクを変更してから更新したスクリプトをエクスポートします。あるいは、スクリプトを手動で編集できます。

HDL ワークフロー スクリプトのエクスポート

  1. HDL ワークフロー アドバイザーで、すべてのタスクを設定して実行します。

  2. [ファイル][スクリプトにエクスポート] を選択します。

  3. [Export Workflow Configuration] ダイアログ ボックスで、ファイル名を入力してスクリプトを保存します。

    スクリプトは、コマンド ラインから実行できる MATLAB® ファイルです。

メモ

スクリプトにエクスポートする場合、[リセット タイプ]Asynchronous など、既定値はエクスポートされません。スクリプトからインポートする場合、モデルに変更がなければ、スクリプトの既定の設定は表示されません。

ワークフロー スクリプトの詳細の指定

関数 hdlcoder.runWorkflowVerbosity プロパティを使用して、コード生成および展開処理の進行に合わせて生成される進捗メッセージの詳細レベルを指定できます。hdlcoder.WorkflowConfig ワークフロー構成オブジェクトの hWC および Simulink 設定の model/DUTname のワークフローを実行中に詳細メッセージを生成するには、Verbosityon に設定します。

hdlcoder.runWorkflow('model/DUTname', hWC, 'Verbosity', 'on');

HDL ワークフロー スクリプトでのタスクの有効化または無効化

すべてのワークフロー タスクを無効にするには、clearAllTasks メソッドを使用してワークフロー構成オブジェクトを更新します。

すべてのワークフロー タスクを再度有効にするには、setAllTasks メソッドを使用してワークフロー構成オブジェクトを更新します。

1 つのワークフロー タスクを実行

他のワークフロー タスクを再実行せずに 1 つのワークフロー タスクを実行するには、次の手順に従います。

  1. clearAllTasks メソッドを実行して、ワークフロー構成オブジェクトのすべてのタスクを無効にします。

  2. ワークフロー構成オブジェクトで、実行するタスクを有効にします。

たとえば、以前に HDL ワークフロー スクリプトを実行して、ビットストリームを生成していた場合、他のワークフロー タスクを再実行せずにターゲット ハードウェアをプログラムできます。hdlcoder.WorkflowConfig ワークフロー構成オブジェクトの hWC および Simulink 設計の model/DUTname に対してターゲット デバイスのプログラミング タスクを実行するには、次を行います。

  1. clearAllTasks メソッドを実行します。

    hWC.clearAllTasks;

  2. ターゲット デバイスのプログラミング タスクを有効にします。

    hWC.RunTaskProgramTargetDevice = true;

  3. ワークフローを実行します。

    hdlcoder.runWorkflow('model/DUTname', hWC);

HDL ワークフロー スクリプトのインポート

  1. HDL ワークフロー アドバイザーで、[ファイル][スクリプトからインポート] を選択します。

  2. [ワークフロー コンフィギュレーションのインポート] ダイアログ ボックスで、スクリプト ファイルを選択して [開く] をクリックします。

    HDL ワークフロー アドバイザーは、インポートされたスクリプト設定を使用してタスクを更新します。

メモ

HDL ワークフロー アドバイザー スクリプトをインポートするときは、HDL ワークフロー アドバイザー UI からエクスポートしたのと同じスクリプトを使用してください。

汎用 ASIC/FPGA ワークフロー スクリプトの例

この例では、エクスポートされた HDL ワークフロー スクリプトを構成して実行する方法を説明します。

このスクリプトは、Xilinx® Virtex® 7 デバイスをターゲットとする汎用 ASIC/FPGA ワークフロー スクリプトです。Xilinx Vivado® 合成ツールを使用します。

エクスポートされた HDL ワークフロー スクリプトを開いて表示します。

% Export Workflow Configuration Script
% Generated with MATLAB 9.5 (R2018b Prerelease) at 14:42:37 on 29/03/2018
% This script was generated using the following parameter values:
%     Filename  : 'S:\generic_workflow_example.m'
%     Overwrite : true
%     Comments  : true
%     Headers   : true
%     DUT       : 'sfir_fixed/symmetric_fir'
% To view changes after modifying the workflow, run the following command:
% >> hWC.export('DUT','sfir_fixed/symmetric_fir');
%--------------------------------------------------------------------------

%% Load the Model
load_system('sfir_fixed');

%% Restore the Model to default HDL parameters
%hdlrestoreparams('sfir_fixed/symmetric_fir');

%% Model HDL Parameters
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'GenerateCoSimModel', 'ModelSim');
hdlset_param('sfir_fixed', 'GenerateHDLTestBench', 'off');
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed/symmetric_fir');
hdlset_param('sfir_fixed', 'SynthesisTool', 'Xilinx Vivado');
hdlset_param('sfir_fixed', 'SynthesisToolChipFamily', 'Virtex7');
hdlset_param('sfir_fixed', 'SynthesisToolDeviceName', 'xc7vx485t');
hdlset_param('sfir_fixed', 'SynthesisToolPackageName', 'ffg1761');
hdlset_param('sfir_fixed', 'SynthesisToolSpeedValue', '-2');
hdlset_param('sfir_fixed', 'TargetDirectory', 'hdl_prj\hdlsrc');


%% Workflow Configuration Settings
% Construct the Workflow Configuration Object with default settings
hWC = hdlcoder.WorkflowConfig('SynthesisTool','Xilinx Vivado','TargetWorkflow','Generic ASIC/FPGA');

% Specify the top level project directory
hWC.ProjectFolder = 'hdl_prj';

%Set Properties related to synthesis tool version
hWC.AllowUnsupportedToolVersion  = true;

% Set Workflow tasks to run
hWC.RunTaskGenerateRTLCodeAndTestbench = true;
hWC.RunTaskVerifyWithHDLCosimulation = true;
hWC.RunTaskCreateProject = true;
hWC.RunTaskRunSynthesis = true;
hWC.RunTaskRunImplementation = false;
hWC.RunTaskAnnotateModelWithSynthesisResult = true;

% Set properties related to 'RunTaskGenerateRTLCodeAndTestbench' Task
hWC.GenerateRTLCode = true;
hWC.GenerateTestbench = false;
hWC.GenerateValidationModel = false;

% Set properties related to 'RunTaskCreateProject' Task
hWC.Objective = hdlcoder.Objective.None;
hWC.AdditionalProjectCreationTclFiles = '';

% Set properties related to 'RunTaskRunSynthesis' Task
hWC.SkipPreRouteTimingAnalysis = false;

% Set properties related to 'RunTaskRunImplementation' Task
hWC.IgnorePlaceAndRouteErrors = false;

% Set properties related to 'RunTaskAnnotateModelWithSynthesisResult' Task
hWC.CriticalPathSource = 'pre-route';
hWC.CriticalPathNumber =  1;
hWC.AnnotateModel = 'original';
hWC.ShowAllPaths = false;
hWC.ShowDelayData = true;
hWC.ShowUniquePaths = false;
hWC.ShowEndsOnly = false;

% Validate the Workflow Configuration Object
hWC.validate;

%% Run the workflow
hdlcoder.runWorkflow('sfir_fixed/symmetric_fir', hWC);

必要に応じて、スクリプトを編集します。

たとえば、hdlcoder.WorkflowConfig オブジェクト hWC 内のタスクを有効または無効にします。

HDL ワークフロー スクリプトを実行します。

たとえば、スクリプト ファイル名が generic_workflow_example.m である場合、コマンド ラインで以下のように入力します。

generic_workflow_example

FPGA インザループ スクリプトの例

この例では、エクスポートされた HDL ワークフロー スクリプトを構成して実行する方法を説明します。

HDL ワークフロー スクリプトを生成するには、Simulink 設計で HDL ワークフロー アドバイザーを設定および実行してから、スクリプトをエクスポートします。

このスクリプトは Xilinx Virtex 5 開発ボードをターゲットとする FPGA インザループ ワークフロー スクリプトで、Xilinx ISE 合成ツールを使用します。

エクスポートされた HDL ワークフロー スクリプトを開いて表示します。

%--------------------------------------------------------------------------
% HDL Workflow Script
% Generated with MATLAB 9.5 (R2018b Prerelease) at 15:11:23 on 04/05/2018
% This script was generated using the following parameter values:
%     Filename  : 'C:\Users\ggnanase\Desktop\R2018b\18b_models\ipcore_timing_failure\hdlworkflow_FIL.m'
%     Overwrite : true
%     Comments  : true
%     Headers   : true
%     DUT       : 'sfir_fixed/symmetric_fir'
% To view changes after modifying the workflow, run the following command:
% >> hWC.export('DUT','sfir_fixed/symmetric_fir');
%--------------------------------------------------------------------------

%% Load the Model
load_system('sfir_fixed');

%% Restore the Model to default HDL parameters
%hdlrestoreparams('sfir_fixed/symmetric_fir');

%% Model HDL Parameters
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed/symmetric_fir');
hdlset_param('sfir_fixed', 'SynthesisTool', 'Xilinx Vivado');
hdlset_param('sfir_fixed', 'SynthesisToolChipFamily', 'Kintex7');
hdlset_param('sfir_fixed', 'SynthesisToolDeviceName', 'xc7k325t');
hdlset_param('sfir_fixed', 'SynthesisToolPackageName', 'ffg900');
hdlset_param('sfir_fixed', 'SynthesisToolSpeedValue', '-2');
hdlset_param('sfir_fixed', 'TargetDirectory', 'hdl_prj\hdlsrc');
hdlset_param('sfir_fixed', 'TargetFrequency', 25);
hdlset_param('sfir_fixed', 'TargetPlatform', 'Xilinx Kintex-7 KC705 development board');
hdlset_param('sfir_fixed', 'Workflow', 'FPGA-in-the-Loop');


%% Workflow Configuration Settings
% Construct the Workflow Configuration Object with default settings
hWC = hdlcoder.WorkflowConfig('SynthesisTool','Xilinx Vivado','TargetWorkflow','FPGA-in-the-Loop');

% Specify the top level project directory
hWC.ProjectFolder = 'hdl_prj';

% Set Workflow tasks to run
hWC.RunTaskGenerateRTLCodeAndTestbench = true;
hWC.RunTaskVerifyWithHDLCosimulation = false;
hWC.RunTaskBuildFPGAInTheLoop = true;

% Set properties related to 'RunTaskGenerateRTLCodeAndTestbench' Task
hWC.GenerateRTLCode = true;
hWC.GenerateTestbench = false;
hWC.GenerateValidationModel = false;

% Set properties related to 'RunTaskBuildFPGAInTheLoop' Task
hWC.IPAddress = '192.168.0.2';
hWC.MACAddress = '00-0A-35-02-21-8A';
hWC.SourceFiles = '';
hWC.Connection = 'Ethernet';
hWC.RunExternalBuild = true;

% Validate the Workflow Configuration Object
hWC.validate;

%% Run the workflow
hdlcoder.runWorkflow('sfir_fixed/symmetric_fir', hWC);
hdlcoder.runWorkflow('hdlcoderUARTServoControllerExample/UART_Servo_on_FPGA', hWC);

必要に応じて、スクリプトを編集します。

たとえば、hdlcoder.WorkflowConfig オブジェクト hWC 内のタスクを有効または無効にします。

HDL ワークフロー スクリプトを実行します。

たとえば、スクリプト ファイル名が FIL_workflow_example.m である場合、コマンド ラインで以下のように入力します。

fil_workflow_example.m

IP コアの生成ワークフロー スクリプトの例

この例では、エクスポートされた HDL ワークフロー スクリプトを構成して実行する方法を説明します。

このスクリプトは、Altera® Cyclone V SoC 開発キットをターゲットとする IP コアの生成ワークフロー スクリプトです。Altera Quartus® II 合成ツールを使用します。

エクスポートされた HDL ワークフロー スクリプトを開いて表示します。

% Export Workflow Configuration Script
% Generated with MATLAB 8.6 (R2015b) at 14:42:16 on 08/07/2015
% Parameter Values:
%     Filename  : 'S:\ip_core_gen_workflow_example.m'
%     Overwrite : true
%     Comments  : true
%     Headers   : true
%     DUT       : 'hdlcoder_led_blinking/led_counter'

%% Load the Model
load_system('hdlcoder_led_blinking');

%% Model HDL Parameters
% Set Model HDL parameters
hdlset_param('hdlcoder_led_blinking', ...
    'HDLSubsystem', 'hdlcoder_led_blinking/led_counter');
hdlset_param('hdlcoder_led_blinking', 'OptimizationReport', 'on');
hdlset_param('hdlcoder_led_blinking', ...
    'ReferenceDesign', 'Default system (Qsys 14.0)');
hdlset_param('hdlcoder_led_blinking', 'ResetType', 'Synchronous');
hdlset_param('hdlcoder_led_blinking', 'ResourceReport', 'on');
hdlset_param('hdlcoder_led_blinking', 'SynthesisTool', 'Altera QUARTUS II');
hdlset_param('hdlcoder_led_blinking', 'SynthesisToolChipFamily', 'Cyclone V');
hdlset_param('hdlcoder_led_blinking', 'SynthesisToolDeviceName', '5CSXFC6D6F31C6');
hdlset_param('hdlcoder_led_blinking', 'TargetDirectory', 'hdl_prj\hdlsrc');
hdlset_param('hdlcoder_led_blinking', ...
    'TargetPlatform', 'Altera Cyclone V SoC development kit - Rev.D');
hdlset_param('hdlcoder_led_blinking', 'Traceability', 'on');
hdlset_param('hdlcoder_led_blinking', 'Workflow', 'IP Core Generation');

% Set SubSystem HDL parameters
hdlset_param('hdlcoder_led_blinking/led_counter', ...
    'ProcessorFPGASynchronization', 'Free running');

% Set Inport HDL parameters
hdlset_param('hdlcoder_led_blinking/led_counter/Blink_frequency', ...
    'IOInterface', 'AXI4');
hdlset_param('hdlcoder_led_blinking/led_counter/Blink_frequency', ...
    'IOInterfaceMapping', 'x"100"');
hdlset_param('hdlcoder_led_blinking/led_counter/Blink_frequency', ...
    'IOInterfaceOptions', {'RegisterInitialValue', 5});

% Set Inport HDL parameters
hdlset_param('hdlcoder_led_blinking/led_counter/Blink_direction', ...
    'IOInterface', 'AXI4');
hdlset_param('hdlcoder_led_blinking/led_counter/Blink_direction', ...
    'IOInterfaceMapping', 'x"104"');
hdlset_param('hdlcoder_led_blinking/led_counter/Blink_direction, ...
    'IOInterfaceOptions', {'RegisterInitialValue', 1});

% Set Outport HDL parameters
hdlset_param('hdlcoder_led_blinking/led_counter/LED', 'IOInterface', 'External Port');

% Set Outport HDL parameters
hdlset_param('hdlcoder_led_blinking/led_counter/Read_back', 'IOInterface', 'AXI4');
hdlset_param('hdlcoder_led_blinking/led_counter/Read_back', ...
    'IOInterfaceMapping', 'x"108"');
hdlset_param('hdlcoder_led_blinking/led_counter/Read_back, ...
    'IOInterfaceOptions', {'RegisterInitialValue', 3});

%% Workflow Configuration Settings
% Construct the Workflow Configuration Object with default settings
hWC = hdlcoder.WorkflowConfig('SynthesisTool','Altera QUARTUS II', ...
    'TargetWorkflow','IP Core Generation');

% Specify the top level project directory
hWC.ProjectFolder = 'hdl_prj';

%Set Properties related to synthesis tool version
hWC.AllowUnsupportedToolVersion  = true;

% Set Workflow tasks to run
hWC.RunTaskGenerateRTLCodeAndIPCore = true;
hWC.RunTaskCreateProject = true;
hWC.RunTaskGenerateSoftwareInterface = false;
hWC.RunTaskBuildFPGABitstream = true;
hWC.RunTaskProgramTargetDevice = false;

% Set Properties related to Generate RTL Code And IP Core Task
hWC.IPCoreRepository = '';
hWC.GenerateIPCoreReport = true;

% Set Properties related to Create Project Task
hWC.Objective = hdlcoder.Objective.AreaOptimized;

% Set Properties related to Generate Software Interface Model Task
hWC.OperatingSystem = '';
hWC.AddLinuxDeviceDriver = false;

% Set Properties related to Build FPGA Bitstream Task
hWC.RunExternalBuild = true;
hWC.TclFileForSynthesisBuild = hdlcoder.BuildOption.Default;

% Validate the Workflow Configuration Object
hWC.validate;

%% Run the workflow
hdlcoder.runWorkflow('hdlcoder_led_blinking/led_counter', hWC);

必要に応じて、スクリプトを編集します。

たとえば、hdlcoder.WorkflowConfig オブジェクト hWC 内のタスクを有効または無効にします。

HDL ワークフロー スクリプトを実行します。

たとえば、スクリプト ファイル名が ip_core_workflow_example.m である場合、コマンド ラインで以下のように入力します。

ip_core_gen_workflow_example

Simulink Real-Time FPGA I/O ワークフローの例

この例では、エクスポートされた HDL ワークフロー スクリプトを構成して実行する方法を説明します。

HDL ワークフロー スクリプトを生成するには、Simulink 設計で HDL ワークフロー アドバイザーを設定および実行してから、スクリプトをエクスポートします。

このスクリプトは、Xilinx Vivado 合成ツールを使用する Speedgoat IO333-325K ボードをターゲットとする Simulink Real-Time FPGA I/O ワークフロー スクリプトです。

エクスポートされた HDL ワークフロー スクリプトを開いて表示します。

%--------------------------------------------------------------------------
% HDL Workflow Script
% Generated with MATLAB 9.5 (R2018b Prerelease) at 18:14:33 on 08/05/2018
% This script was generated using the following parameter values:
%     Filename  : 'C:\Users\ggnanase\Desktop\R2018b\18b_models\ipcore_timing_failure\hdlworkflow_IO333.m'
%     Overwrite : true
%     Comments  : true
%     Headers   : true
%     DUT       : 'sfir_fixed/symmetric_fir'
% To view changes after modifying the workflow, run the following command:
% >> hWC.export('DUT','sfir_fixed/symmetric_fir');
%--------------------------------------------------------------------------

%% Load the Model
load_system('sfir_fixed');

%% Restore the Model to default HDL parameters
%hdlrestoreparams('sfir_fixed/symmetric_fir');

%% Model HDL Parameters
%% Set Model 'sfir_fixed' HDL parameters
hdlset_param('sfir_fixed', 'HDLSubsystem', 'sfir_fixed/symmetric_fir');
hdlset_param('sfir_fixed', 'SynthesisTool', 'Xilinx Vivado');
hdlset_param('sfir_fixed', 'SynthesisToolChipFamily', 'Kintex7');
hdlset_param('sfir_fixed', 'SynthesisToolDeviceName', 'xc7k325t');
hdlset_param('sfir_fixed', 'SynthesisToolPackageName', 'ffg900');
hdlset_param('sfir_fixed', 'SynthesisToolSpeedValue', '-2');
hdlset_param('sfir_fixed', 'TargetDirectory', 'hdl_prj\hdlsrc');
hdlset_param('sfir_fixed', 'TargetFrequency', 100);
hdlset_param('sfir_fixed', 'TargetPlatform', 'Speedgoat IO333-325K');
hdlset_param('sfir_fixed', 'Workflow', 'Simulink Real-Time FPGA I/O');


%% Workflow Configuration Settings
% Construct the Workflow Configuration Object with default settings
hWC = hdlcoder.WorkflowConfig('SynthesisTool','Xilinx Vivado','TargetWorkflow','Simulink Real-Time FPGA I/O');

% Specify the top level project directory
hWC.ProjectFolder = 'hdl_prj';
hWC.ReferenceDesignToolVersion = '2017.4';
hWC.IgnoreToolVersionMismatch = false;

% Set Workflow tasks to run
hWC.RunTaskGenerateRTLCodeAndIPCore = true;
hWC.RunTaskCreateProject = true;
hWC.RunTaskBuildFPGABitstream = true;
hWC.RunTaskGenerateSimulinkRealTimeInterface = true;

% Set properties related to 'RunTaskGenerateRTLCodeAndIPCore' Task
hWC.IPCoreRepository = '';
hWC.GenerateIPCoreReport = true;
hWC.GenerateIPCoreTestbench = false;
hWC.CustomIPTopHDLFile = '';
hWC.AXI4RegisterReadback = false;
hWC.IPDataCaptureBufferSize = '128';

% Set properties related to 'RunTaskCreateProject' Task
hWC.Objective = hdlcoder.Objective.None;
hWC.AdditionalProjectCreationTclFiles = '';
hWC.EnableIPCaching = true;

% Set properties related to 'RunTaskBuildFPGABitstream' Task
hWC.RunExternalBuild = false;
hWC.TclFileForSynthesisBuild = hdlcoder.BuildOption.Default;
hWC.CustomBuildTclFile = '';
hWC.ReportTimingFailure = hdlcoder.ReportTiming.Error;

% Validate the Workflow Configuration Object
hWC.validate;

%% Run the workflow
hdlcoder.runWorkflow('sfir_fixed/symmetric_fir', hWC);

必要に応じて、スクリプトを編集します。

たとえば、hdlcoder.WorkflowConfig オブジェクト hWC 内のタスクを有効または無効にします。

HDL ワークフロー スクリプトを実行します。

たとえば、スクリプト ファイル名が slrt_workflow_example.m である場合、コマンド ラインで以下のように入力します。

slrt_workflow_example.m

参考

関数

クラス

関連するトピック