RTL プログラマブル ロジックを使用したデザイン フロー - 2023.2 日本語

AI エンジン カーネルおよびグラフ プログラミング ガイド (UG1079)

Document ID
UG1079
Release Date
2023-12-04
Version
2023.2 日本語

ADF グラフ内では、RTL ブロックはサポートされません。RTL ブロックと ADF グラフの通信には、PLIO インターフェイスを使用する必要があります。次の例で、interpolator および classifyAI エンジン カーネルです。interpolator AI エンジン カーネルは PL RTL ブロックにデータをストリーミングし、PL RTL ブロックは AI エンジン classify カーネルにストリーム データを戻します。

class clipped : public graph {  
  private:
    kernel interpolator;
    kernel classify;
   
  public: 
    input_plio in;
    output_plio out;
    output_plio clip_in;
    input_plio clip_out; 

    clipped() {
      in  = input_plio::create("DataIn1", plio_32_bits,"data/input.txt");
      out = output_plio::create("DataOut1", plio_32_bits,"data/output.txt");
      clip_out = input_plio::create("clip_out",plio_32_bits,"data/input1.txt");
      clip_in  = output_plio::create("clip_in", plio_32_bits,"data/output1.txt"); 

      interpolator = kernel::create(fir_27t_sym_hb_2i);
      classify     = kernel::create(classifier);

      connect(in.out[0], interpolator.in[0]);
      connect(interpolator.out[0], clip_in.in[0]);
      connect(clip_out.out[0], classify.in[0]);
      connect(classify.out[0], out.in[0]);

      std::vector<std::string> myheaders;
      myheaders.push_back("include.h");

      adf::headers(interpolator) = myheaders;
      adf::headers(classify) = myheaders;

      source(interpolator) = "kernels/interpolators/hb27_2i.cc";
      source(classify)    = "kernels/classifiers/classify.cc";

      runtime<ratio>(interpolator) = 0.8;
      runtime<ratio>(classify) = 0.8;
    };
};

clip_in および clip_out は、グラフの AI エンジン カーネルに接続されている polar_clip PL RTL カーネルとの通信に使用するポートです。clip_in ポートは interpolator AI エンジン カーネルの出力で、polar_clip RTL カーネルの入力に接続されます。clip_out ポートは、classify AI エンジン カーネルの入力および polar_clip RTL カーネルの出力です。

RTL ブロックと AI エンジン

次に、アプリケーション コードの例を示します。

#include "graph.h"

clipped clipgraph;

#if defined(__AIESIM__ ) || defined(__X86SIM__)
int main(int argc, char ** argv) {
    clipgraph.init();
    clipgraph.run();
    clipgraph.end();
    return 0;
}
#endif

aiesimulator を機能させるには、RTL カーネルに関連する入力テストベンチ ファイルを作成する必要があります。data/output_interp.txt は、RTL カーネルへのテストベンチ入力です。aiesimulator により、interpolator AI エンジン カーネルから出力ファイルが生成されます。data/input_classify.txt ファイルには、polar_clip カーネルからのデータが含まれ、これが AI エンジン classify カーネルへの入力となります。PLIO にはオプションの属性として PL のクロック周波数を指定でき、polar_clip ではこれは 100 です。

ハードウェア エミュレーションおよびハードウェア フローの RTL ブロック

ハードウェア エミュレーションおよびハードウェア フローでは、RTL カーネルが完全にサポートされます。次のコード例に示すように、nk オプションを使用して RTL カーネルを追加し、sc オプションを使用してインターフェイスをリンクする必要があります。必要に応じて、freqHz を使用してクロック周波数を調整します。次に、Vitis コンフィギュレーション ファイルの例を示します。

[connectivity]
nk=mm2s:1:mm2s
nk=s2mm:1:s2mm
nk=polar_clip:1:polar_clip
sc=mm2s.s:ai_engine_0.DataIn1
sc=ai_engine_0.clip_in:polar_clip.in_sample
sc=polar_clip.out_sample:ai_engine_0.clip_out
sc=ai_engine_0.DataOut1:s2mm.s
[clock]
freqHz=100000000:polar_clip.ap_clk

RTL カーネルおよび Vitis フローの詳細は、 『AI エンジン ツールおよびフロー ユーザー ガイド』 (UG1076)システムのビルドと実行を参照してください。エミュレーションのみの場合は、SystemC カーネルも使用できます。このフローの詳細は、 『Vitis 統合ソフトウェア プラットフォーム資料: アプリケーション アクセラレーション開発』 (UG1393)SystemC モデルの操作を参照してください。

AI エンジン グラフ内の PL カーネル

AI エンジン グラフおよび PL カーネルとのシステム リンク後、AI エンジン グラフ ビューに AI エンジン グラフと PL カーネル接続のシステム図を表示させるには、次のコマンドを使用して、Vitis IDE でリンカー サマリを開きます。

vitis -a <USER_NAME>.xsa.link_summary
図 1. AI エンジン グラフ内の PL カーネル