veriwell仿真之HelloWorld

1.接上回,编译完veriwell,提取出静态库和头文件

2.在这个基础上进行HelloWorld编写,测试

hello_vpi.c

#include <stdio.h>
#include <stdlib.h>
#include <veriuser.h>
#include <acc_user.h>

char *veriuser_version_str = "Hello Test\n";

int myfun(int data, int reason);

s_tfcell veriusertfs[]={
        {userfunction, 0, myfun, myfun, myfun, 0, "$hello"},
        {0}
};

int myfun(int data, int reason)
{

        printf("%d %d\n",data, reason);
        return 0;
}

s_tfcell veriusertfs是个全局变量,在此处定义,在静态库中被引用,这个结构体定义如下

typedef struct t_tfcell {
    short type;			/* 函数类型,function还是task */
    short data;			/* 数据 */
    int (*checktf) (int, int);	/* routine for checking parameters */
    int (*sizetf) (int, int);	/* for providing size of function return value */
    int (*calltf) (int, int);	/* routine called during simulation */
    int (*misctf) (int, int);	/* miscellaneous routine (see below) */
    char *tfname;		/* the name of the system task or function */
    int forwref;		/* indicates special parameters allowed */
    char *tfveritool;		/* Which Veritool owns the task */
    char *tferrmessage;		/* An optional special case error message
				   which will be printed if the task is skipped */

    /* these components are for system usage only */
    int hash;
    struct t_tfcell *left_p;
    struct t_tfcell *right_p;
    char *namecell_p;
    int warning_printed;	/* Flag is set when skipping warning is printed */
    struct t_call_stats call_stats[18];
    int statsInit;
} s_tfcell, *p_tfcell;

 

3.编写testbench

tb.v

module tb;

integer ret;
        initial 
                ret = $hello(100);
endmodule

4.编译运行

g++ -o hello hello_vpi.c  -I../myveri  ../myveri/libveriwell.a 

运行

./hello  tb.v

转载于:https://my.oschina.net/jjinl/blog/1859428

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值