- 一、函数介绍
- 二、流水线仿真
- 三、代码实现
- 没加流水线(没有使用排队函数)
- 使用流水线仿真
①
ihc_hls_enqueue(void *retptr, void *funcptr,)
参数:
retptr:返回值
funcptr:将要调用的HLS component
这个函数对HLS组件的一次调用进行排队。返回值存储在第一个实参中,该实参应该是指向返回类型的指针。在调用ihc_hls_component_run_all()之前,组件不会运行。
②
ihc_hls_enqueue_noret(void* funcptr,)
参数:
funcptr:将要调用的HLS component
这个函数对HLS组件的一次调用进行排队。当HLS组件的返回类型为void时,应该使用这个函数。在调用ihc_hls_component_run_all()之前,组件不会运行。
③
ihc_hls_component_run_all(void* funcptr)
参数:
funcptr:将要调用的HLS component
这个函数接受一个指向HLS组件函数的指针。组件的所有排队调用在运行时将被推入,当组件能够接受新的调用时,HDL模拟器就能以最快的速度运行。
二、流水线仿真默认情况下,对模拟器的函数调用是顺序的
也就是新的调用不会发起在前一个调用没有返回前
HLS允许模块以流水线方式进行仿真,但在ihc_hls_component_run_all()被唤醒前,排队函数调用不会运行
使用排队函数调用流数据到模块,但不是模块调用
#include "HLS/hls.h" #includecomponent int acc(int a,int b) { return a+b; } int main() { int x1,x2,x3; #if 1 x1=acc(1,2); x2=acc(3,4); x3=acc(5,6); #else ihc_hls_enqueue(&x1,&acc,1,2); ihc_hls_enqueue(&x2,&acc,3,4); ihc_hls_enqueue(&x3,&acc,5,6); ihc_hls_component_run_all(acc); #endif return 0; }
i++ -march=x86-64 ihc_hls_enqueue.cpp i++ -march=CycloneV ihc_hls_enqueue.cpp -ghdl -v a vsim a.prjverificationvsim.wlf
从波形看出 就是函数调用一次,等结果输出一次,然后才能再次调用函数
#include "HLS/hls.h" #includecomponent int acc(int a,int b) { return a+b; } int main() { int x1,x2,x3; #if 0 x1=acc(1,2); x2=acc(3,4); x3=acc(5,6); #else ihc_hls_enqueue(&x1,&acc,1,2); ihc_hls_enqueue(&x2,&acc,3,4); ihc_hls_enqueue(&x3,&acc,5,6); ihc_hls_component_run_all(acc); #endif return 0; }
先累计调用函数acc,在等到ihc_hls_component_run_all函数调用玩,一次运行之前的排队函数。



