Mac上vcs编写C语言,3、linux环境下,使用VCS进行Verilog和C语言联编译

/**********************************************************************

* $hello example -- Verilog HDL test bench.

*

* For the book, "The Verilog PLI Handbook" by Stuart Sutherland

* Copyright 1999 & 2001, Kluwer Academic Publishers, Norwell, MA, USA

* Contact: www.wkap.il

* Example copyright 1998, Sutherland HDL Inc, Portland, Oregon, USA

* Contact: www.sutherland-hdl.com

*********************************************************************/

`timescale 1ns / 1ns

module test;

initial

begin

$hello;

// #10 $stop;

#10 $finish;

end

endmodule

/**********************************************************************/

文件名为hello_test.v

/**********************************************************************

* $hello example -- PLI application using VPI routines

*

* C source to print "Hello World" as a PLI application.

*

* Usage: $hello;

*

* For the book, "The Verilog PLI Handbook" by Stuart Sutherland

* Copyright 1999 & 2001, Kluwer Academic Publishers, Norwell, MA, USA

* Contact: www.wkap.il

* Example copyright 1998, Sutherland HDL Inc, Portland, Oregon, USA

* Contact: www.sutherland-hdl.com

*********************************************************************/

#include /* ANSI C standard library */

#include /* ANSI C standard input/output library */

#include /* ANSI C standard arguments library */

#include "vpi_user.h" /* IEEE 1364 PLI VPI routine library */

/**********************************************************************

* calltf routine

*********************************************************************/

PLI_INT32 PLIbook_hello_calltf(PLI_BYTE8 *user_data)

{

vpi_printf("\nHello World!\n\n");

return(0);

}

/**********************************************************************

* $hello Registration Data

* (add this function name to the vlog_startup_routines array)

*********************************************************************/

void PLIbook_hello_register()

{

s_vpi_systf_data tf_data;

tf_data.type = vpiSysTask;

tf_data.sysfunctype = 0;

tf_data.tfname = "$hello";

tf_data.calltf = PLIbook_hello_calltf;

tf_data.compiletf = NULL;

tf_data.sizetf = NULL;

tf_data.user_data = NULL;

vpi_register_systf(&tf_data);

}

文件名为hello_vpi.c

/**********************************************************************

* Example vpi_user.c file

*

* vpi_user.c file to register PLI applications using the VPI library.

*

* For the book, "The Verilog PLI Handbook" by Stuart Sutherland

* Copyright 1999 & 2001, Kluwer Academic Publishers, Norwell, MA, USA

* Contact: www.wkap.il

* Example copyright 1998, Sutherland HDL Inc, Portland, Oregon, USA

* Contact: www.sutherland-hdl.com

*********************************************************************/

#include "vpi_user.h"

/* prototypes of the PLI registration routines */

extern void PLIbook_hello_register();

void (*vlog_startup_routines[])() =

{

/*** add user entries here ***/

PLIbook_hello_register,

0 /*** final entry must be 0 ***/

};

文件名为 vpi_user.c

gcc -m32 vpi_user.c hello_vpi.c -fPIC -shared -o hello.so

vcs +cli+3 +vpi -R -load ./hello.so:PLIbook_hello_register ./hello_test.v

前提:存在vpi_user.h文件

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值