説明
ヒント: このプラグマまたは指示子は、DSP のマルチ演算マッチング (MULADD、AMA、ADDMUL、および該当する減算演算) には関係ありません。実際、演算子を DSP に割り当てる際に BIND_OP を使用すると、HLS コンパイラが複数の演算式をマッチングできなくなることがあります。
Vitis HLS では、コードのさまざまな演算が特定ハードウェア リソース (またはインプリメンテーション) を使用してインプリメントされます。使用するリソースは自動的に決定されますが、syn.op を定義すると、演算子のコンフィギュレーション で説明するように、インプリメンテーションを指定できます。
syn.directive.bind_op コマンドは、指定した変数に対し、演算 (たとえば mul、add、sub) を RTL で特定のインプリメンテーション (impl) にマップする必要があるこということを指示します。たとえば、syn.directive.bind_op コマンドを使用すると、特定の乗算 (mul) を DSP ではなくデバイス ファブリックにインプリメントするよう指定できます。
syn.directive.bind_op に latency オプションを使用すると、レイテンシを指定することもできます。
重要:
latency オプションを使用するには、使用可能な複数段のインプリメンテーションを演算に含める必要があります。HLS ツールでは、基本的な算術演算 (加算、減算、乗算、除算) およびすべての浮動小数点演算に複数段インプリメンテーションが提供されています。構文
syn.directive.bind_op=[OPTIONS] <location> <variable>
-
<location>: 変数を含める場所をfunction[/label]の形式で指定します。 -
<variable>: 割り当てる変数を指定します。この場合の変数は、この指示子のターゲットである演算の結果が割り当てられた変数のことです。
オプション
-
op=<value> - 指定したインプリメンテーション リソースにマップする演算を定義します。サポートされる機能演算は、
mul、add、subなどです。 -
impl=<value> - 指定した演算に使用するインプリメンテーションを定義します。
-
latency=<int> - 演算のインプリメンテーションのデフォルト レイテンシを定義します。有効なレイテンシは、
opおよびimplの指定によって異なります。デフォルトは -1 で、Vitis HLS によりレイテンシが選択されます。
| 演算 | インプリメンテーション | 最小レイテンシ | 最大レイテンシ |
|---|---|---|---|
| add | fabric | 0 | 4 |
| add | dsp | 0 | 4 |
| mul | fabric | 0 | 4 |
| mul | dsp | 0 | 4 |
| sub | fabric | 0 | 4 |
| sub | dsp | 0 | 0 |
ヒント:
dcmp などの比較演算子は LUT にインプリメントされるため、ファブリック外部にインプリメントしたり、DSP にマップしたりすることはできません。このため、config_op または bind_op コマンドでは設定できません。| 演算 | インプリメンテーション | 最小レイテンシ | 最大レイテンシ |
|---|---|---|---|
| fadd | fabric | 0 | 13 |
| fadd | fulldsp | 0 | 12 |
| fadd | primitivedsp | 0 | 3 |
| fsub | fabric | 0 | 13 |
| fsub | fulldsp | 0 | 12 |
| fsub | primitivedsp | 0 | 3 |
| fdiv | fabric | 0 | 29 |
| fexp | fabric | 0 | 24 |
| fexp | meddsp | 0 | 21 |
| fexp | fulldsp | 0 | 30 |
| flog | fabric | 0 | 24 |
| flog | meddsp | 0 | 23 |
| flog | fulldsp | 0 | 29 |
| fmul | fabric | 0 | 9 |
| fmul | meddsp | 0 | 9 |
| fmul | fulldsp | 0 | 9 |
| fmul | maxdsp | 0 | 7 |
| fmul | primitivedsp | 0 | 4 |
| fsqrt | fabric | 0 | 29 |
| frsqrt | fabric | 0 | 38 |
| frsqrt | fulldsp | 0 | 33 |
| frecip | fabric | 0 | 37 |
| frecip | fulldsp | 0 | 30 |
| dadd | fabric | 0 | 13 |
| dadd | fulldsp | 0 | 15 |
| dsub | fabric | 0 | 13 |
| dsub | fulldsp | 0 | 15 |
| ddiv | fabric | 0 | 58 |
| dexp | fabric | 0 | 40 |
| dexp | meddsp | 0 | 45 |
| dexp | fulldsp | 0 | 57 |
| dlog | fabric | 0 | 38 |
| dlog | meddsp | 0 | 49 |
| dlog | fulldsp | 0 | 65 |
| dmul | fabric | 0 | 10 |
| dmul | meddsp | 0 | 13 |
| dmul | fulldsp | 0 | 13 |
| dmul | maxdsp | 0 | 14 |
| dsqrt | fabric | 0 | 58 |
| drsqrt | fulldsp | 0 | 111 |
| drecip | fulldsp | 0 | 36 |
| hadd | fabric | 0 | 9 |
| hadd | meddsp | 0 | 12 |
| hadd | fulldsp | 0 | 12 |
| hsub | fabric | 0 | 9 |
| hsub | meddsp | 0 | 12 |
| hsub | fulldsp | 0 | 12 |
| hdiv | fabric | 0 | 16 |
| hmul | fabric | 0 | 7 |
| hmul | fulldsp | 0 | 7 |
| hmul | maxdsp | 0 | 9 |
| hsqrt | fabric | 0 | 16 |
例
次の例は、関数 foo の変数 c の乗算をインプリメントするのに、ファブリック ロジックを使用する 2 段のパイプライン乗算器を指定します。
int foo (int a, int b) {
int c, d;
c = a*b;
d = a*c;
return d;
}
syn.directive.bind_op コマンドは次のとおりです。syn.directive.bind_op=op=mul impl=fabric latency=2 foo c
ヒント: 変数
d には syn.directive.bind_op が指定されていないため、HLS ツールで使用するインプリメンテーションが選択されます。