RTL(Verilog/HLS)変換

学習が完了したネットは結果パラメータに基づいて、ユーザ側で自由に実装可能ですが、 BinaryBrainでも若干のサポート関数を備えています。

binarybrain.verilog.dump_verilog_lut_cnv_layers(f, module_name: str, net, device='')

dump verilog source of Convolutional LUT layers

畳み込み層を含むネットを AXI4 Stream Video 形式のVerilogソースコードして 出力する。 縮小を伴う MaxPooling 層は最後に1個だけ挿入を許される

パラメータ
  • f (StreamIO) -- 出力先ストリーム

  • module_name (str) -- モジュール名

  • net (Model) -- 変換するネット

binarybrain.verilog.dump_verilog_lut_layers(f, module_name: str, net, device='')

dump verilog source of LUT layers 変換できないモデルは影響ない層とみなして無視するので注意

パラメータ
  • f (StreamIO) -- 出力先ストリーム

  • module_name (str) -- モジュール名

  • net (Model) -- 変換するネット

binarybrain.verilog.dump_verilog_readmemb_image_classification(f, loader, *, class_digits=8)

verilog用データダンプ verilog の $readmemb() での読み込み用データ作成

クラスID + 画像データの形式で出力する

パラメータ
  • f (StreamIO) -- 出力先

  • loader (Loader) -- モジュール名

  • class_digits (int) -- クラス分類のbit数

binarybrain.verilog.make_image_tile(rows, cols, img_gen)

画像をタイル状に並べて大きな画像にする

学習用の c, h, w 順の画像データをタイル状に結合する

パラメータ
  • rows (int)) -- 縦の結合枚数

  • cols (int)) -- 横の結合枚数

  • gen (ndarray) -- 画像を返すジェネレータ

戻り値

作成した画像

戻り値の型

img (ndarray)

binarybrain.verilog.make_verilog_lut_layers(module_name: str, net, device='')

make verilog source of LUT layers 変換できないモデルは影響ない層とみなして無視するので注意

パラメータ
  • module_name (str) -- モジュール名

  • net (Model) -- 変換するネット

戻り値

Verilog source code (str)

binarybrain.verilog.write_ppm(fname, img)

ppmファイルの出力

学習用の c, h, w 順の画像データを ppm形式で保存する

パラメータ
  • fname (str) -- 出力ファイル名

  • img (ndarray) -- モジュール名

binarybrain.hls.dump_hls_lut_layer(f, name, lut)

dump HLS source of LUT layer

パラメータ
  • f (StreamIO) -- 出力先ストリーム

  • name (str) -- 関数名

  • lut (Model) -- 変換するネット

binarybrain.hls.make_hls_lut_layer(name, lut)

make HLS source of LUT layer

パラメータ
  • name (str) -- 関数名

  • lut (Model) -- 変換するネット

戻り値

HLS source code (str)