verilog pli相关,请帮忙,谢~~!

aboy85 2009-05-14 03:19:35
开发环境如下:
os:xp sp2
modlesim: modlesim se 6.3f

我写了一个misctf的函数,声明:int clkReactive (int data, int reason),
s_tfcell veriusertfs[] = {
{usertask, 0, clkInit, 0, clkGen, clkReactive, "$clkGen"},
{0}
};
编译通不过,因为veriuser.h头文件中定义如下:
typedef PLI_INT32 (*p_tffn)();
typedef struct t_tfcell
{
PLI_INT16 type; /* USERTASK, USERFUNCTION, or USERREALFUNCTION */
PLI_INT16 data; /* passed as data argument of callback function */
p_tffn checktf; /* argument checking callback function */
p_tffn sizetf; /* function return size callback function */
p_tffn calltf; /* task or function call callback function */
p_tffn misctf; /* miscellaneous reason callback function */
char * tfname; /* name of system task or function */
.....................
}
我知道参数个数不对,肯定编译不过,但是我看网上一些源代码中checktf,sizetf misctf都是可以带参数的,也能编译通过,运行,不知道他们是怎么办的的,这个链接(http://www.project-veripage.com/bfm8051.php)上给的源代码中misctf中也是带参数的,同样是modelsim,不知道为啥人家就能运行....难道是版本的问题?
我想捕获reason_reactivate这个事件,所以想问问大家有没有类似的经历,怎么解决的...谢!!
...全文
150 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
aboy85 2009-05-18
  • 打赏
  • 举报
回复
现在的问题更奇怪了,为什么这样声明,定义居然能正常运行?
我把自己的代码贴出来:
clkGen.h
//空文件
clkGen.c
#include "acc_user.h"
#include "veriuser.h"
#include <malloc.h>
#include "clkGen.h"
// Define the ON and OFF time of clock
#define PERIOD 5

extern int clkGen();
extern int clkInit();
extern int clkReactive (int data, int reason, int paramvc);


// Data structure
struct clkData {
int clk;
int clkCnt;
};
struct clkData *data;
int count = 0;
// Main routine which toggles the clock
int clkGen()
{
acc_initialize();
// Get the stored workarea
//struct clkData *data = ( struct clkData * )tf_igetworkarea(tf_getinstance());
if (data->clkCnt == PERIOD)
{
data->clk = (data->clk == 0) ? 1 : 0;
data->clkCnt = 0;
io_printf("%d Current clk = %d\n",tf_gettime(), data->clk);
}
else
{
data->clkCnt ++;
io_printf("%d Current clk = %d\n",tf_gettime(), data->clk);
}
// Drive the clock signal in HDL
tf_putp (1, data->clk);
acc_close();
return 0;
}

// checktf() routine
// This function inits the objects and also stores the object in workarea
//extern "C"
int clkInit()
{
acc_initialize();
data = ( struct clkData * )malloc( sizeof( struct clkData ) );
data->clkCnt = 0;
data->clk = 0;
tf_setworkarea(data);
acc_close();
return 0;
}

// misctf() routine
// This routine is called after 1 tick
int clkReactive (int data, int reason, int paramvc)
{
acc_initialize();
// if callback reason is reactive, then call clkGen function
if (reason == reason_reactivate)
{
clkGen();
}
// Set the callback delay to 1 tick
tf_setdelay(1);
acc_close();
return 0;
}

s_tfcell veriusertfs[] = {
{usertask, 0, clkInit, 0, clkGen, clkReactive, "$clkGen"},
{0}
};
//cl -c -I C:/Modeltech_6.3f/include clkGen.c
//link -dll -export:veriusertfs clkGen.obj C:/Modeltech_6.3f/win32/mtipli.lib /out:clkGen.dll
//vsim -c -pli D:/modelsimPROJ/counterv4/clkGen.dll clkGen_tb

clkGen.v

module clkGen_tb(clk);
output clk;
reg clk;

initial
begin
$clkGen(clk);
end
always @(posedge clk)
begin
$display("hello world !");
end
endmodule

用命令行编译没问题,也能运行,但是用modelsim提供的编译按钮编译不通过
我想问,clkReactive 明明是不符合veriuser.h中函数指针要求的,问什么能编译通过呢,还能运行,求高手解答~~!
benjaminweber 2009-05-15
  • 打赏
  • 举报
回复
那个代码在头文件里把函数指针给申明了一遍,用的是没有参数的。
aboy85 2009-05-15
  • 打赏
  • 举报
回复
在uc.h文件中声明如下:
extern int ucMisc_tf();

在ucpli.c 文件中定义如下:
int ucMisc_tf(int data , int reason)
{
switch(reason){
case reason_endofcompile:
// io_printf("called from misctf- Reason End Of Compile \n");
break;
case reason_synch:
ucSynchronize();
break;
default:
// io_printf("default Misctf\n");
break;
}

}
这两者不矛盾么?
请指教,3Q~~!

2,425

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 其他硬件开发
社区管理员
  • 其他硬件开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧