描述
提示: 此编译指示或指令在 DSP 多重运算匹配(MULADD、AMA、ADDMUL 和相应的减法运算)中不起作用。事实上,使用 BIND_OP 为 DSP 分配运算符会妨碍 HLS 编译器匹配多重运算表达式。
Vitis HLS 使用特定硬件资源或实现来实现代码中的不同运算。该工具会自动判定要使用的资源,或者您可定义 syn.op 用于广泛指定实现,如 运算符配置 中所述。
syn.directive.bind_op 命令会指出,对于指定变量,应将运算(例如,mul、add 或 sub)映射到 RTL 中的特定实现 (impl)。例如,您可使用 syn.directive.bind_op 命令来指明在器件互连结构内(而不是在 DSP 内)实现一项特定乘法器运算 (mul)。
您也可以通过 syn.directive.bind_op 使用 latency 选项来指定时延,如下所述。
重要: 要使用
latency 选项,运算必须具有 1 个可用的多阶段实现。HLS 工具可为所有基本算术运算(加减乘除)和所有浮点运算提供 1 个多阶段实现。语法
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 实现乘法运算。
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 工具会选择用于该变量的实现。