①
ihc_hls_enqueue(void *retptr, void *funcptr,/*function arguments*/)
参数:
retptr:返回值
funcptr:将要调用的HLS component
这个函数对HLS组件的一次调用进行排队。返回值存储在第一个实参中,该实参应该是指向返回类型的指针。在调用ihc_hls_component_run_all()之前,组件不会运行。
②
ihc_hls_enqueue_noret(void* funcptr,/*function arguments*/)
参数:
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"
#include
component 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.prj\verification\vsim.wlf
从波形看出 就是函数调用一次,等结果输出一次,然后才能再次调用函数
#include "HLS/hls.h"
#include
component 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;
}