ストリーミング カーネルのコーディング ガイドライン - 2023.2 日本語

Vitis 統合ソフトウェア プラットフォームの資料: アプリケーション アクセラレーション開発 (UG1393)

Document ID
UG1393
Release Date
2023-12-13
Version
2023.2 日本語

PL カーネルでは、別のカーネル ストリーミング インターフェイスへのデータの直接送信または受信が、ap_axiu<D,0,0,0> 型の hls::stream で定義されます。ap_axiu<D,0,0,0> データ型には、ap_axi_sdata.h ヘッダー ファイルを使用する必要があります。

次の例は、プロデューサーおよびコンシューマー カーネルのストリーミング インターフェイスを示しています。

// Producer kernel - provides output as a data stream
// For simplicity the example only shows the streaming output.

void kernel1 (.... , hls::stream<ap_axiu<32, 0, 0, 0> >& stream_out) {
      
  for(int i = 0; i < ...; i++) {
    int a = ...... ;         // Internally generated data
    ap_axiu<32, 0, 0, 0> v;  // temporary storage for ap_axiu
    v.data = a;              // Writing the data
    stream_out.write(v);         // Writing to the output stream.
  }
}
 
// Consumer kernel - reads data stream as input
// For simplicity the example only shows the streaming input.

void kernel2 (hls::stream<ap_axiu<32, 0, 0, 0> >& stream_in, .... ) {
 
  for(int i = 0; i < ....; i++) {
    ap_axiu<32, 0, 0, 0> v = stream_in.read(); // Reading the input stream
    int a = v.data; // Extract the data
          
    // Do further processing
  }
}

hls::stream 型が定義されているので、Vitis HLS ツールで axis インターフェイスが推論されます。例として次の INTERFACE プラグマを示していますが、コードには必要ありません。

#pragma HLS INTERFACE axis port=stream_out
#pragma HLS INTERFACE axis port=stream_in
ヒント: これらのサンプル カーネルは、カーネル シグネチャのストリーミング入力/出力ポートの定義と、カーネル コード内の入力/出力ストリームの処理方法を示しています。kernel1 から kernel2 へのストリーミング インターフェイスの接続は、ストリーミング接続の指定 で説明するように、リンク プロセス中に定義する必要があります。